From 2c4109394fa9ee71b10b8b2d3d1473a409d7003e Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sat, 12 Jan 2019 12:22:06 +1100 Subject: Fix Caps Lock LEDs once and for all (#4824) * Check the size of the SET_REPORT packet If we have two bytes, that probably means the first is a report ID. The 6KRO interface may or may not have one, but the NKRO interface always does, so we need to check this regardless of whether KEYBOARD_SHARED_EP is defined. * Fix indentation --- tmk_core/protocol/lufa/lufa.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tmk_core/protocol/lufa/lufa.c') diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 27cf51b16..cdabaf16e 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -517,17 +517,20 @@ void EVENT_USB_Device_ControlRequest(void) if (USB_DeviceState == DEVICE_STATE_Unattached) return; } -#ifdef KEYBOARD_SHARED_EP - uint8_t report_id = REPORT_ID_KEYBOARD; - if (keyboard_protocol) { - report_id = Endpoint_Read_8(); - } - if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { + + if (Endpoint_BytesInEndpoint() == 2) { + uint8_t report_id = REPORT_ID_KEYBOARD; + + if (keyboard_protocol) { + report_id = Endpoint_Read_8(); + } + + if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { keyboard_led_stats = Endpoint_Read_8(); + } + } else { + keyboard_led_stats = Endpoint_Read_8(); } -#else - keyboard_led_stats = Endpoint_Read_8(); -#endif Endpoint_ClearOUT(); Endpoint_ClearStatusStage(); -- cgit v1.2.3-24-g4f1b From ae79b60e6bfc03c7fa84076e508f0f2241f087c2 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Tue, 22 Jan 2019 21:43:17 +1100 Subject: Always read two bytes from the endpoint if we have two bytes to read When this if statement is false, it will cause the report ID to be read as the LED state. We already know there are two bytes in the endpoint, which is a reasonably good indicator that it contains a report ID, so we should always read both. --- tmk_core/protocol/lufa/lufa.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tmk_core/protocol/lufa/lufa.c') diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index cdabaf16e..f2ecf2465 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -519,11 +519,7 @@ void EVENT_USB_Device_ControlRequest(void) } if (Endpoint_BytesInEndpoint() == 2) { - uint8_t report_id = REPORT_ID_KEYBOARD; - - if (keyboard_protocol) { - report_id = Endpoint_Read_8(); - } + uint8_t report_id = Endpoint_Read_8(); if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { keyboard_led_stats = Endpoint_Read_8(); -- cgit v1.2.3-24-g4f1b