@@ -335,36 +335,20 @@ static int asus_raw_event(struct hid_device *hdev,
335
335
if (drvdata -> quirks & QUIRK_MEDION_E1239T )
336
336
return asus_e1239t_event (drvdata , data , size );
337
337
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 ) {
339
345
/*
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 .
342
348
*/
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 ) {
345
350
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
- }
357
351
}
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
-
368
352
}
369
353
370
354
if (drvdata -> quirks & QUIRK_ROG_CLAYMORE_II_KEYBOARD ) {
@@ -402,9 +386,9 @@ static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t bu
402
386
return ret ;
403
387
}
404
388
405
- static int asus_kbd_init (struct hid_device * hdev )
389
+ static int asus_kbd_init (struct hid_device * hdev , u8 report_id )
406
390
{
407
- const u8 buf [] = { FEATURE_KBD_REPORT_ID , 0x41 , 0x53 , 0x55 , 0x53 , 0x20 , 0x54 ,
391
+ const u8 buf [] = { report_id , 0x41 , 0x53 , 0x55 , 0x53 , 0x20 , 0x54 ,
408
392
0x65 , 0x63 , 0x68 , 0x2e , 0x49 , 0x6e , 0x63 , 0x2e , 0x00 };
409
393
int ret ;
410
394
@@ -416,9 +400,10 @@ static int asus_kbd_init(struct hid_device *hdev)
416
400
}
417
401
418
402
static int asus_kbd_get_functions (struct hid_device * hdev ,
419
- unsigned char * kbd_func )
403
+ unsigned char * kbd_func ,
404
+ u8 report_id )
420
405
{
421
- const u8 buf [] = { FEATURE_KBD_REPORT_ID , 0x05 , 0x20 , 0x31 , 0x00 , 0x08 };
406
+ const u8 buf [] = { report_id , 0x05 , 0x20 , 0x31 , 0x00 , 0x08 };
422
407
u8 * readbuf ;
423
408
int ret ;
424
409
@@ -447,51 +432,6 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
447
432
return ret ;
448
433
}
449
434
450
- static int rog_nkey_led_init (struct hid_device * hdev )
451
- {
452
- const u8 buf_init_start [] = { FEATURE_KBD_LED_REPORT_ID1 , 0xB9 };
453
- u8 buf_init2 [] = { FEATURE_KBD_LED_REPORT_ID1 , 0x41 , 0x53 , 0x55 , 0x53 , 0x20 ,
454
- 0x54 , 0x65 , 0x63 , 0x68 , 0x2e , 0x49 , 0x6e , 0x63 , 0x2e , 0x00 };
455
- u8 buf_init3 [] = { FEATURE_KBD_LED_REPORT_ID1 ,
456
- 0x05 , 0x20 , 0x31 , 0x00 , 0x08 };
457
- int ret ;
458
-
459
- hid_info (hdev , "Asus initialise N-KEY Device" );
460
- /* The first message is an init start */
461
- ret = asus_kbd_set_report (hdev , buf_init_start , sizeof (buf_init_start ));
462
- if (ret < 0 ) {
463
- hid_warn (hdev , "Asus failed to send init start command: %d\n" , ret );
464
- return ret ;
465
- }
466
- /* Followed by a string */
467
- ret = asus_kbd_set_report (hdev , buf_init2 , sizeof (buf_init2 ));
468
- if (ret < 0 ) {
469
- hid_warn (hdev , "Asus failed to send init command 1.0: %d\n" , ret );
470
- return ret ;
471
- }
472
- /* Followed by a string */
473
- ret = asus_kbd_set_report (hdev , buf_init3 , sizeof (buf_init3 ));
474
- if (ret < 0 ) {
475
- hid_warn (hdev , "Asus failed to send init command 1.1: %d\n" , ret );
476
- return ret ;
477
- }
478
-
479
- /* begin second report ID with same data */
480
- buf_init2 [0 ] = FEATURE_KBD_LED_REPORT_ID2 ;
481
- buf_init3 [0 ] = FEATURE_KBD_LED_REPORT_ID2 ;
482
-
483
- ret = asus_kbd_set_report (hdev , buf_init2 , sizeof (buf_init2 ));
484
- if (ret < 0 ) {
485
- hid_warn (hdev , "Asus failed to send init command 2.0: %d\n" , ret );
486
- return ret ;
487
- }
488
- ret = asus_kbd_set_report (hdev , buf_init3 , sizeof (buf_init3 ));
489
- if (ret < 0 )
490
- hid_warn (hdev , "Asus failed to send init command 2.1: %d\n" , ret );
491
-
492
- return ret ;
493
- }
494
-
495
435
static void asus_schedule_work (struct asus_kbd_leds * led )
496
436
{
497
437
unsigned long flags ;
@@ -574,17 +514,27 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
574
514
int ret ;
575
515
576
516
if (drvdata -> quirks & QUIRK_ROG_NKEY_KEYBOARD ) {
577
- ret = rog_nkey_led_init (hdev );
517
+ /* Initialize keyboard */
518
+ ret = asus_kbd_init (hdev , FEATURE_KBD_REPORT_ID );
519
+ if (ret < 0 )
520
+ return ret ;
521
+
522
+ /* The LED endpoint is initialised in two HID */
523
+ ret = asus_kbd_init (hdev , FEATURE_KBD_LED_REPORT_ID1 );
524
+ if (ret < 0 )
525
+ return ret ;
526
+
527
+ ret = asus_kbd_init (hdev , FEATURE_KBD_LED_REPORT_ID2 );
578
528
if (ret < 0 )
579
529
return ret ;
580
530
} else {
581
531
/* Initialize keyboard */
582
- ret = asus_kbd_init (hdev );
532
+ ret = asus_kbd_init (hdev , FEATURE_KBD_REPORT_ID );
583
533
if (ret < 0 )
584
534
return ret ;
585
535
586
536
/* Get keyboard functions */
587
- ret = asus_kbd_get_functions (hdev , & kbd_func );
537
+ ret = asus_kbd_get_functions (hdev , & kbd_func , FEATURE_KBD_REPORT_ID );
588
538
if (ret < 0 )
589
539
return ret ;
590
540
@@ -897,7 +847,10 @@ static int asus_input_mapping(struct hid_device *hdev,
897
847
case 0xb3 : asus_map_key_clear (KEY_PROG3 ); break ; /* Fn+Left next aura */
898
848
case 0x6a : asus_map_key_clear (KEY_F13 ); break ; /* Screenpad toggle */
899
849
case 0x4b : asus_map_key_clear (KEY_F14 ); break ; /* Arrows/Pg-Up/Dn toggle */
900
-
850
+ case 0xa5 : asus_map_key_clear (KEY_F15 ); break ; /* ROG Ally left back */
851
+ case 0xa6 : asus_map_key_clear (KEY_F16 ); break ; /* ROG Ally QAM button */
852
+ case 0xa7 : asus_map_key_clear (KEY_F17 ); break ; /* ROG Ally ROG long-press */
853
+ case 0xa8 : asus_map_key_clear (KEY_F18 ); break ; /* ROG Ally ROG long-press-release */
901
854
902
855
default :
903
856
/* ASUS lazily declares 256 usages, ignore the rest,
@@ -1250,6 +1203,19 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1250
1203
rdesc [205 ] = 0x01 ;
1251
1204
}
1252
1205
1206
+ /* match many more n-key devices */
1207
+ if (drvdata -> quirks & QUIRK_ROG_NKEY_KEYBOARD ) {
1208
+ for (int i = 0 ; i < * rsize + 1 ; i ++ ) {
1209
+ /* offset to the count from 0x5a report part always 14 */
1210
+ if (rdesc [i ] == 0x85 && rdesc [i + 1 ] == 0x5a &&
1211
+ rdesc [i + 14 ] == 0x95 && rdesc [i + 15 ] == 0x05 ) {
1212
+ hid_info (hdev , "Fixing up Asus N-Key report descriptor\n" );
1213
+ rdesc [i + 15 ] = 0x01 ;
1214
+ break ;
1215
+ }
1216
+ }
1217
+ }
1218
+
1253
1219
return rdesc ;
1254
1220
}
1255
1221
@@ -1276,6 +1242,12 @@ static const struct hid_device_id asus_devices[] = {
1276
1242
{ HID_USB_DEVICE (USB_VENDOR_ID_ASUSTEK ,
1277
1243
USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD3 ),
1278
1244
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
1245
+ { HID_USB_DEVICE (USB_VENDOR_ID_ASUSTEK ,
1246
+ USB_DEVICE_ID_ASUSTEK_ROG_Z13_LIGHTBAR ),
1247
+ QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
1248
+ { HID_USB_DEVICE (USB_VENDOR_ID_ASUSTEK ,
1249
+ USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY ),
1250
+ QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
1279
1251
{ HID_USB_DEVICE (USB_VENDOR_ID_ASUSTEK ,
1280
1252
USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD ),
1281
1253
QUIRK_ROG_CLAYMORE_II_KEYBOARD },
@@ -1319,4 +1291,4 @@ static struct hid_driver asus_driver = {
1319
1291
};
1320
1292
module_hid_driver (asus_driver );
1321
1293
1322
- MODULE_LICENSE ("GPL" );
1294
+ MODULE_LICENSE ("GPL" );
0 commit comments