@@ -59,18 +59,18 @@ static bool usb_enumerated = false;
5959 * This descriptor matches the MouthPad BLE device exactly to eliminate scaling
6060 */
6161static const uint8_t hid_report_desc [] = {
62- 0x05 , 0x01 , 0x09 , 0x02 , 0xA1 , 0x01 , 0x85 , 0x01 , 0x09 , 0x01 , 0xA1 , 0x00 ,
63- 0x95 , 0x05 , 0x75 , 0x01 , 0x05 , 0x09 , 0x19 , 0x01 , 0x29 , 0x05 , 0x15 , 0x00 ,
64- 0x25 , 0x01 , 0x81 , 0x02 , 0x95 , 0x01 , 0x75 , 0x03 , 0x81 , 0x01 , 0x75 , 0x08 ,
65- 0x95 , 0x01 , 0x05 , 0x01 , 0x09 , 0x38 , 0x15 , 0x81 , 0x25 , 0x7F , 0x81 , 0x06 ,
66- 0x05 , 0x0C , 0x0A , 0x38 , 0x02 , 0x95 , 0x01 , 0x81 , 0x06 , 0xC0 , 0x85 , 0x02 ,
67- 0x09 , 0x01 , 0xA1 , 0x00 , 0x75 , 0x0C , 0x95 , 0x02 , 0x05 , 0x01 , 0x09 , 0x30 ,
68- 0x09 , 0x31 , 0x16 , 0x01 , 0xF8 , 0x26 , 0xFF , 0x07 , 0x81 , 0x06 , 0xC0 , 0xC0 ,
69- 0x05 , 0x0C , 0x09 , 0x01 , 0xA1 , 0x01 , 0x85 , 0x03 , 0x15 , 0x00 , 0x25 , 0x01 ,
70- 0x75 , 0x01 , 0x95 , 0x01 , 0x09 , 0xCD , 0x81 , 0x06 , 0x0A , 0x83 , 0x01 , 0x81 ,
71- 0x06 , 0x09 , 0xB5 , 0x81 , 0x06 , 0x09 , 0xB6 , 0x81 , 0x06 , 0x09 , 0xEA , 0x81 ,
72- 0x06 , 0x09 , 0xE9 , 0x81 , 0x06 , 0x0A , 0x25 , 0x02 , 0x81 , 0x06 , 0x0A , 0x24 ,
73- 0x02 , 0x81 , 0x06 , 0xC0
62+ 0x05 , 0x01 , 0x09 , 0x02 , 0xA1 , 0x01 , 0x85 , 0x01 , 0x09 , 0x01 , 0xA1 , 0x00 , 0x95 ,
63+ 0x05 , 0x75 , 0x01 , 0x05 , 0x09 , 0x19 , 0x01 , 0x29 , 0x05 , 0x15 , 0x00 , 0x25 , 0x01 ,
64+ 0x81 , 0x02 , 0x95 , 0x01 , 0x75 , 0x03 , 0x81 , 0x01 , 0x75 , 0x08 , 0x95 , 0x01 , 0x05 ,
65+ 0x01 , 0x09 , 0x38 , 0x15 , 0x81 , 0x25 , 0x7F , 0x81 , 0x06 , 0x05 , 0x0C , 0x0A , 0x38 ,
66+ 0x02 , 0x95 , 0x01 , 0x81 , 0x06 , 0xC0 , 0x85 , 0x02 , 0x09 , 0x01 , 0xA1 , 0x00 , 0x75 ,
67+ 0x0C , 0x95 , 0x02 , 0x05 , 0x01 , 0x09 , 0x30 , 0x09 , 0x31 , 0x16 , 0x01 , 0xF8 , 0x26 ,
68+ 0xFF , 0x07 , 0x81 , 0x06 , 0xC0 , 0x85 , 0x03 , 0x05 , 0x0C , 0x19 , 0x00 , 0x2A , 0x3C ,
69+ 0x02 , 0x15 , 0x00 , 0x26 , 0x3C , 0x02 , 0x75 , 0x10 , 0x95 , 0x01 , 0x81 , 0x00 , 0xC0 ,
70+ 0x05 , 0x01 , 0x09 , 0x06 , 0xA1 , 0x01 , 0x85 , 0x04 , 0x05 , 0x07 , 0x19 , 0xE0 , 0x29 ,
71+ 0xE7 , 0x15 , 0x00 , 0x25 , 0x01 , 0x75 , 0x01 , 0x95 , 0x08 , 0x81 , 0x02 , 0x95 , 0x01 ,
72+ 0x75 , 0x08 , 0x81 , 0x01 , 0x95 , 0x06 , 0x75 , 0x08 , 0x15 , 0x00 , 0x25 , 0x65 , 0x05 ,
73+ 0x07 , 0x19 , 0x00 , 0x29 , 0x65 , 0x81 , 0x00 , 0xC0
7474};
7575
7676/* ============================================================================
@@ -453,10 +453,24 @@ int usb_hid_send_release_all(void)
453453 0x00 /* Y high byte = 0 */
454454 };
455455
456- /* Report ID 3: Release all consumer controls */
456+ /* Report ID 3: Release all consumer controls (16-bit usage selector) */
457457 uint8_t report3 [] = {
458458 0x03 , /* Report ID 3 */
459- 0x00 /* No consumer controls pressed */
459+ 0x00 , /* Consumer control usage low byte */
460+ 0x00 /* Consumer control usage high byte */
461+ };
462+
463+ /* Report ID 4: Release all keyboard keys */
464+ uint8_t report4 [] = {
465+ 0x04 , /* Report ID 4 */
466+ 0x00 , /* Modifier keys */
467+ 0x00 , /* Reserved */
468+ 0x00 , /* Key 1 */
469+ 0x00 , /* Key 2 */
470+ 0x00 , /* Key 3 */
471+ 0x00 , /* Key 4 */
472+ 0x00 , /* Key 5 */
473+ 0x00 /* Key 6 */
460474 };
461475
462476 /* Send clear reports 3 times to ensure USB host processes them */
@@ -491,6 +505,16 @@ int usb_hid_send_release_all(void)
491505 } else {
492506 LOG_INF ("Release report 3 sent round %d (consumer controls cleared)" , round + 1 );
493507 }
508+ k_msleep (10 ); /* 10ms delay between reports */
509+
510+ /* Send Report 4 - Release keyboard keys */
511+ ret = usb_hid_send_report (report4 , sizeof (report4 ));
512+ if (ret != 0 ) {
513+ LOG_ERR ("Failed to send release report 4 round %d (err %d)" , round + 1 , ret );
514+ failed_count ++ ;
515+ } else {
516+ LOG_INF ("Release report 4 sent round %d (keyboard cleared)" , round + 1 );
517+ }
494518
495519 if (round < 2 ) {
496520 k_msleep (20 ); /* Longer delay between rounds */
0 commit comments