diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 8fbe877db..d71e7ce44 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
| @@ -62,7 +62,7 @@ extern keymap_config_t keymap_config; | |||
| 62 | 62 | ||
| 63 | uint8_t keyboard_idle __attribute__((aligned(2))) = 0; | 63 | uint8_t keyboard_idle __attribute__((aligned(2))) = 0; |
| 64 | uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; | 64 | uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; |
| 65 | uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; | 65 | uint8_t keyboard_led_stats = 0; |
| 66 | volatile uint16_t keyboard_idle_count = 0; | 66 | volatile uint16_t keyboard_idle_count = 0; |
| 67 | static virtual_timer_t keyboard_idle_timer; | 67 | static virtual_timer_t keyboard_idle_timer; |
| 68 | static void keyboard_idle_timer_cb(void *arg); | 68 | static void keyboard_idle_timer_cb(void *arg); |
| @@ -381,14 +381,17 @@ static uint16_t get_hword(uint8_t *p) { | |||
| 381 | * Other Device Required Optional Optional Optional Optional Optional | 381 | * Other Device Required Optional Optional Optional Optional Optional |
| 382 | */ | 382 | */ |
| 383 | 383 | ||
| 384 | #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) | ||
| 385 | static uint8_t set_report_buf[2] __attribute__((aligned(2))); | 384 | static uint8_t set_report_buf[2] __attribute__((aligned(2))); |
| 386 | static void set_led_transfer_cb(USBDriver *usbp) { | 385 | static void set_led_transfer_cb(USBDriver *usbp) { |
| 387 | if ((set_report_buf[0] == REPORT_ID_KEYBOARD) || (set_report_buf[0] == REPORT_ID_NKRO)) { | 386 | if (usbp->setup[6] == 2) { /* LSB(wLength) */ |
| 388 | keyboard_led_stats = set_report_buf[1]; | 387 | uint8_t report_id = set_report_buf[0]; |
| 388 | if ((report_id == REPORT_ID_KEYBOARD) || (report_id == REPORT_ID_NKRO)) { | ||
| 389 | keyboard_led_stats = set_report_buf[1]; | ||
| 390 | } | ||
| 391 | } else { | ||
| 392 | keyboard_led_stats = set_report_buf[0]; | ||
| 389 | } | 393 | } |
| 390 | } | 394 | } |
| 391 | #endif | ||
| 392 | 395 | ||
| 393 | /* Callback for SETUP request on the endpoint 0 (control) */ | 396 | /* Callback for SETUP request on the endpoint 0 (control) */ |
| 394 | static bool usb_request_hook_cb(USBDriver *usbp) { | 397 | static bool usb_request_hook_cb(USBDriver *usbp) { |
| @@ -444,18 +447,12 @@ static bool usb_request_hook_cb(USBDriver *usbp) { | |||
| 444 | case USB_RTYPE_DIR_HOST2DEV: | 447 | case USB_RTYPE_DIR_HOST2DEV: |
| 445 | switch (usbp->setup[1]) { /* bRequest */ | 448 | switch (usbp->setup[1]) { /* bRequest */ |
| 446 | case HID_SET_REPORT: | 449 | case HID_SET_REPORT: |
| 447 | switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0 and wLength==1?) */ | 450 | switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0?) */ |
| 451 | case KEYBOARD_INTERFACE: | ||
| 448 | #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) | 452 | #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) |
| 449 | case SHARED_INTERFACE: | 453 | case SHARED_INTERFACE: |
| 450 | usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); | ||
| 451 | return TRUE; | ||
| 452 | break; | ||
| 453 | #endif | 454 | #endif |
| 454 | 455 | usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); | |
| 455 | case KEYBOARD_INTERFACE: | ||
| 456 | /* keyboard_led_stats = <read byte from next OUT report> | ||
| 457 | * keyboard_led_stats needs be word (or dword), otherwise we get an exception on F0 */ | ||
| 458 | usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL); | ||
| 459 | return TRUE; | 456 | return TRUE; |
| 460 | break; | 457 | break; |
| 461 | } | 458 | } |
| @@ -613,7 +610,7 @@ static void keyboard_idle_timer_cb(void *arg) { | |||
| 613 | } | 610 | } |
| 614 | 611 | ||
| 615 | /* LED status */ | 612 | /* LED status */ |
| 616 | uint8_t keyboard_leds(void) { return (uint8_t)(keyboard_led_stats & 0xFF); } | 613 | uint8_t keyboard_leds(void) { return keyboard_led_stats; } |
| 617 | 614 | ||
| 618 | /* prepare and start sending a report IN | 615 | /* prepare and start sending a report IN |
| 619 | * not callable from ISR or locked state */ | 616 | * not callable from ISR or locked state */ |
