From ed9766a7d44cd727dbd59008eff4258745ff87cf Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 20 Sep 2015 14:34:13 +0900 Subject: [PATCH] core: Fix for disabling NKRO in Boot protocol --- tmk_core/common/action_util.c | 6 +++--- tmk_core/common/command.c | 1 + tmk_core/protocol/lufa/lufa.c | 8 +++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index dbee630d..f81877dd 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c @@ -76,7 +76,7 @@ void send_keyboard_report(void) { void add_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { add_key_bit(key); return; } @@ -87,7 +87,7 @@ void add_key(uint8_t key) void del_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { del_key_bit(key); return; } @@ -160,7 +160,7 @@ uint8_t has_anymod(void) uint8_t get_first_key(void) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { uint8_t i = 0; for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) ; diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index a53cac61..420e7eb9 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -315,6 +315,7 @@ static bool command_common(uint8_t code) print_val_hex8(host_keyboard_leds()); print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_idle); + print_val_hex8(keyboard_nkro); print_val_hex32(timer_count); #ifdef PROTOCOL_PJRC diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 188fb7b8..345630aa 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -53,6 +53,7 @@ #include "lufa.h" uint8_t keyboard_idle = 0; +/* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; static uint8_t keyboard_led_stats = 0; @@ -349,10 +350,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); - keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); -#ifdef NKRO_ENABLE - keyboard_nkro = !!keyboard_protocol; -#endif + keyboard_protocol = (USB_ControlRequest.wValue & 0xFF); clear_keyboard(); } } @@ -399,7 +397,7 @@ static void send_keyboard(report_keyboard_t *report) /* Select the Keyboard Report Endpoint */ #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { /* Report protocol - NKRO */ Endpoint_SelectEndpoint(NKRO_IN_EPNUM);