Skip to content

Commit a5e913c

Browse files
brayeJiri Kosina
authored andcommitted
HID: glorious: fix Glorious Model I HID report
The Glorious Model I mouse has a buggy HID report descriptor for its keyboard endpoint (used for programmable buttons). For report ID 2, there is a mismatch between Logical Minimum and Usage Minimum in the array that reports keycodes. The offending portion of the descriptor: (from hid-decode) 0x95, 0x05, // Report Count (5) 30 0x75, 0x08, // Report Size (8) 32 0x15, 0x00, // Logical Minimum (0) 34 0x25, 0x65, // Logical Maximum (101) 36 0x05, 0x07, // Usage Page (Keyboard) 38 0x19, 0x01, // Usage Minimum (1) 40 0x29, 0x65, // Usage Maximum (101) 42 0x81, 0x00, // Input (Data,Arr,Abs) 44 This bug shifts all programmed keycodes up by 1. Importantly, this causes "empty" array indexes of 0x00 to be interpreted as 0x01, ErrorRollOver. The presence of ErrorRollOver causes the system to ignore all keypresses from the endpoint and breaks the ability to use the programmable buttons. Setting byte 41 to 0x00 fixes this, and causes keycodes to be interpreted correctly. Also, USB_VENDOR_ID_GLORIOUS is changed to USB_VENDOR_ID_SINOWEALTH, and a new ID for Laview Technology is added. Glorious seems to be white-labeling controller boards or mice from these vendors. There isn't a single canonical vendor ID for Glorious products. Signed-off-by: Brett Raye <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent fc43e9c commit a5e913c

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

drivers/hid/hid-glorious.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ MODULE_DESCRIPTION("HID driver for Glorious PC Gaming Race mice");
2121
* Glorious Model O and O- specify the const flag in the consumer input
2222
* report descriptor, which leads to inputs being ignored. Fix this
2323
* by patching the descriptor.
24+
*
25+
* Glorious Model I incorrectly specifes the Usage Minimum for its
26+
* keyboard HID report, causing keycodes to be misinterpreted.
27+
* Fix this by setting Usage Minimum to 0 in that report.
2428
*/
2529
static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2630
unsigned int *rsize)
@@ -32,6 +36,10 @@ static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc,
3236
rdesc[85] = rdesc[113] = rdesc[141] = \
3337
HID_MAIN_ITEM_VARIABLE | HID_MAIN_ITEM_RELATIVE;
3438
}
39+
if (*rsize == 156 && rdesc[41] == 1) {
40+
hid_info(hdev, "patching Glorious Model I keyboard report descriptor\n");
41+
rdesc[41] = 0;
42+
}
3543
return rdesc;
3644
}
3745

@@ -44,6 +52,8 @@ static void glorious_update_name(struct hid_device *hdev)
4452
model = "Model O"; break;
4553
case USB_DEVICE_ID_GLORIOUS_MODEL_D:
4654
model = "Model D"; break;
55+
case USB_DEVICE_ID_GLORIOUS_MODEL_I:
56+
model = "Model I"; break;
4757
}
4858

4959
snprintf(hdev->name, sizeof(hdev->name), "%s %s", "Glorious", model);
@@ -66,10 +76,12 @@ static int glorious_probe(struct hid_device *hdev,
6676
}
6777

6878
static const struct hid_device_id glorious_devices[] = {
69-
{ HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS,
79+
{ HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH,
7080
USB_DEVICE_ID_GLORIOUS_MODEL_O) },
71-
{ HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS,
81+
{ HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH,
7282
USB_DEVICE_ID_GLORIOUS_MODEL_D) },
83+
{ HID_USB_DEVICE(USB_VENDOR_ID_LAVIEW,
84+
USB_DEVICE_ID_GLORIOUS_MODEL_I) },
7385
{ }
7486
};
7587
MODULE_DEVICE_TABLE(hid, glorious_devices);

drivers/hid/hid-ids.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,6 @@
511511
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
512512
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100
513513

514-
#define USB_VENDOR_ID_GLORIOUS 0x258a
515-
#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033
516-
#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036
517-
518514
#define I2C_VENDOR_ID_GOODIX 0x27c6
519515
#define I2C_DEVICE_ID_GOODIX_01F0 0x01f0
520516

@@ -745,6 +741,9 @@
745741
#define USB_VENDOR_ID_LABTEC 0x1020
746742
#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
747743

744+
#define USB_VENDOR_ID_LAVIEW 0x22D4
745+
#define USB_DEVICE_ID_GLORIOUS_MODEL_I 0x1503
746+
748747
#define USB_VENDOR_ID_LCPOWER 0x1241
749748
#define USB_DEVICE_ID_LCPOWER_LC1000 0xf767
750749

@@ -1160,6 +1159,10 @@
11601159
#define USB_VENDOR_ID_SIGMATEL 0x066F
11611160
#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
11621161

1162+
#define USB_VENDOR_ID_SINOWEALTH 0x258a
1163+
#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033
1164+
#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036
1165+
11631166
#define USB_VENDOR_ID_SIS_TOUCH 0x0457
11641167
#define USB_DEVICE_ID_SIS9200_TOUCH 0x9200
11651168
#define USB_DEVICE_ID_SIS817_TOUCH 0x0817

0 commit comments

Comments
 (0)