Skip to content

Commit 59d2f5b

Browse files
flukejonesJiri Kosina
authored andcommitted
HID: asus: fix more n-key report descriptors if n-key quirked
Adjusts the report descriptor for N-Key devices to make the output count 0x01 which completely avoids the need for a block of filtering. Signed-off-by: Luke D. Jones <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 3e78a6c commit 59d2f5b

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

drivers/hid/hid-asus.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -335,36 +335,20 @@ static int asus_raw_event(struct hid_device *hdev,
335335
if (drvdata->quirks & QUIRK_MEDION_E1239T)
336336
return asus_e1239t_event(drvdata, data, size);
337337

338-
if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) {
338+
/*
339+
* Skip these report ID, the device emits a continuous stream associated
340+
* with the AURA mode it is in which looks like an 'echo'.
341+
*/
342+
if (report->id == FEATURE_KBD_LED_REPORT_ID1 || report->id == FEATURE_KBD_LED_REPORT_ID2)
343+
return -1;
344+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
339345
/*
340-
* Skip these report ID, the device emits a continuous stream associated
341-
* with the AURA mode it is in which looks like an 'echo'.
346+
* G713 and G733 send these codes on some keypresses, depending on
347+
* the key pressed it can trigger a shutdown event if not caught.
342348
*/
343-
if (report->id == FEATURE_KBD_LED_REPORT_ID1 ||
344-
report->id == FEATURE_KBD_LED_REPORT_ID2) {
349+
if (data[0] == 0x02 && data[1] == 0x30) {
345350
return -1;
346-
/* Additional report filtering */
347-
} else if (report->id == FEATURE_KBD_REPORT_ID) {
348-
/*
349-
* G14 and G15 send these codes on some keypresses with no
350-
* discernable reason for doing so. We'll filter them out to avoid
351-
* unmapped warning messages later.
352-
*/
353-
if (data[1] == 0xea || data[1] == 0xec || data[1] == 0x02 ||
354-
data[1] == 0x8a || data[1] == 0x9e) {
355-
return -1;
356-
}
357351
}
358-
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
359-
/*
360-
* G713 and G733 send these codes on some keypresses, depending on
361-
* the key pressed it can trigger a shutdown event if not caught.
362-
*/
363-
if(data[0] == 0x02 && data[1] == 0x30) {
364-
return -1;
365-
}
366-
}
367-
368352
}
369353

370354
if (drvdata->quirks & QUIRK_ROG_CLAYMORE_II_KEYBOARD) {
@@ -1250,6 +1234,19 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
12501234
rdesc[205] = 0x01;
12511235
}
12521236

1237+
/* match many more n-key devices */
1238+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
1239+
for (int i = 0; i < *rsize + 1; i++) {
1240+
/* offset to the count from 0x5a report part always 14 */
1241+
if (rdesc[i] == 0x85 && rdesc[i + 1] == 0x5a &&
1242+
rdesc[i + 14] == 0x95 && rdesc[i + 15] == 0x05) {
1243+
hid_info(hdev, "Fixing up Asus N-Key report descriptor\n");
1244+
rdesc[i + 15] = 0x01;
1245+
break;
1246+
}
1247+
}
1248+
}
1249+
12531250
return rdesc;
12541251
}
12551252

@@ -1319,4 +1316,4 @@ static struct hid_driver asus_driver = {
13191316
};
13201317
module_hid_driver(asus_driver);
13211318

1322-
MODULE_LICENSE("GPL");
1319+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)