@@ -127,20 +127,23 @@ const uint8_t hid_report_desc_extra[] = {
127127 HID_RI_FEATURE (8 , HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE ),
128128 HID_RI_END_COLLECTION (0 ),
129129
130+ #ifdef NKRO_ENABLE
130131 HID_RI_USAGE_PAGE (8 , 0x01 ), // Generic Desktop
131132 HID_RI_USAGE (8 , 0x06 ), // Keyboard
132133 HID_RI_COLLECTION (8 , 0x01 ), // Application
133134 HID_RI_REPORT_ID (8 , REPORT_ID_NKRO ),
134135 // Modifiers (8 bits)
135136 HID_RI_USAGE_PAGE (8 , 0x07 ), // Keyboard/Keypad
136- HID_RI_USAGE_MINIMUM (8 , 0x04 ),
137- HID_RI_USAGE_MAXIMUM (8 , 0x70 ),
137+ HID_RI_USAGE_MINIMUM (8 , 0x00 ), // was 0x04
138+ HID_RI_USAGE_MAXIMUM (8 , NKRO_REPORT_BITS * 8 - 1 ), // was 0x70
138139 HID_RI_LOGICAL_MINIMUM (8 , 0x00 ),
139140 HID_RI_LOGICAL_MAXIMUM (8 , 0x01 ),
140141 HID_RI_REPORT_SIZE (8 , 1 ),
141- HID_RI_REPORT_COUNT (8 , 120 ),
142+ HID_RI_REPORT_COUNT (8 , NKRO_REPORT_BITS * 8 ), // was 120
142143 HID_RI_INPUT (8 , HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE ),
143144 HID_RI_END_COLLECTION (0 ),
145+ #endif // NKRO_ENABLE
146+
144147 // clang-format on
145148};
146149
@@ -358,6 +361,20 @@ void usb_send_report(report_keyboard_t *report)
358361 SET_EP1_IN_RDY ;
359362}
360363
364+ void usb_send_nkro (report_nkro_t * report )
365+ {
366+ uint8_t timeout = 0 ;
367+ while (timeout < 255 && EP2CON & _IEP2RDY ) {
368+ delay_us (40 );
369+ timeout ++ ;
370+ }
371+
372+ set_ep2_in_buffer (report -> raw , sizeof (report_nkro_t ));
373+
374+ SET_EP2_CNT (sizeof (report_nkro_t ));
375+ SET_EP2_IN_RDY ;
376+ }
377+
361378void usb_send_extra (report_extra_t * report )
362379{
363380 uint8_t timeout = 0 ;
@@ -366,12 +383,17 @@ void usb_send_extra(report_extra_t *report)
366383 timeout ++ ;
367384 }
368385
369- set_ep2_in_buffer (( uint8_t * ) report , sizeof (report_extra_t ));
386+ set_ep2_in_buffer (report -> raw , sizeof (report_extra_t ));
370387
371388 SET_EP2_CNT (sizeof (report_extra_t ));
372389 SET_EP2_IN_RDY ;
373390}
374391
392+ uint8_t usb_device_state_get_protocol ()
393+ {
394+ return interface0_protocol ;
395+ }
396+
375397static void usb_setup_irq ()
376398{
377399 usb_req_setup_x req ;
0 commit comments