Skip to content

Commit 6e2a694

Browse files
DamnWidgetgregkh
authored andcommitted
HID: corsair: Add driver Scimitar Pro RGB gaming mouse 1b1c:1b3e support to hid-corsair
[ Upstream commit 01adc47 ] This mouse sold by Corsair as Scimitar PRO RGB defines two consecutive Logical Minimum items in its Application (Consumer.0001) report making it non parseable. This patch fixes the report descriptor overriding byte 77 in rdesc from 0x16 (Logical Minimum with 16 bits value) to 0x26 (Logical Maximum with 16 bits value). Signed-off-by: Oscar Campos <oscar.campos@member.fsf.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e93ea3a commit 6e2a694

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

drivers/hid/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ config HID_CORSAIR
190190

191191
Supported devices:
192192
- Vengeance K90
193+
- Scimitar PRO RGB
193194

194195
config HID_PRODIKEYS
195196
tristate "Prodikeys PC-MIDI Keyboard support"

drivers/hid/hid-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18721872
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
18731873
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
18741874
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },
1875+
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) },
18751876
{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
18761877
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
18771878
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },

drivers/hid/hid-corsair.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
*
44
* Supported devices:
55
* - Vengeance K90 Keyboard
6+
* - Scimitar PRO RGB Gaming Mouse
67
*
78
* Copyright (c) 2015 Clement Vuchener
9+
* Copyright (c) 2017 Oscar Campos
810
*/
911

1012
/*
@@ -670,10 +672,51 @@ static int corsair_input_mapping(struct hid_device *dev,
670672
return 0;
671673
}
672674

675+
/*
676+
* The report descriptor of Corsair Scimitar RGB Pro gaming mouse is
677+
* non parseable as they define two consecutive Logical Minimum for
678+
* the Usage Page (Consumer) in rdescs bytes 75 and 77 being 77 0x16
679+
* that should be obviousy 0x26 for Logical Magimum of 16 bits. This
680+
* prevents poper parsing of the report descriptor due Logical
681+
* Minimum being larger than Logical Maximum.
682+
*
683+
* This driver fixes the report descriptor for:
684+
* - USB ID b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
685+
*/
686+
687+
static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
688+
unsigned int *rsize)
689+
{
690+
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
691+
692+
if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
693+
/*
694+
* Corsair Scimitar RGB Pro report descriptor is broken and
695+
* defines two different Logical Minimum for the Consumer
696+
* Application. The byte 77 should be a 0x26 defining a 16
697+
* bits integer for the Logical Maximum but it is a 0x16
698+
* instead (Logical Minimum)
699+
*/
700+
switch (hdev->product) {
701+
case USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB:
702+
if (*rsize >= 172 && rdesc[75] == 0x15 && rdesc[77] == 0x16
703+
&& rdesc[78] == 0xff && rdesc[79] == 0x0f) {
704+
hid_info(hdev, "Fixing up report descriptor\n");
705+
rdesc[77] = 0x26;
706+
}
707+
break;
708+
}
709+
710+
}
711+
return rdesc;
712+
}
713+
673714
static const struct hid_device_id corsair_devices[] = {
674715
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90),
675716
.driver_data = CORSAIR_USE_K90_MACRO |
676717
CORSAIR_USE_K90_BACKLIGHT },
718+
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR,
719+
USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) },
677720
{}
678721
};
679722

@@ -686,10 +729,14 @@ static struct hid_driver corsair_driver = {
686729
.event = corsair_event,
687730
.remove = corsair_remove,
688731
.input_mapping = corsair_input_mapping,
732+
.report_fixup = corsair_mouse_report_fixup,
689733
};
690734

691735
module_hid_driver(corsair_driver);
692736

693737
MODULE_LICENSE("GPL");
738+
/* Original K90 driver author */
694739
MODULE_AUTHOR("Clement Vuchener");
740+
/* Scimitar PRO RGB driver author */
741+
MODULE_AUTHOR("Oscar Campos");
695742
MODULE_DESCRIPTION("HID driver for Corsair devices");

0 commit comments

Comments
 (0)