From ab1332bb6cc798c037a0bd58c22d954755226dbf Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 6 May 2025 06:47:44 +0100 Subject: [PATCH] Remove force disable of NKRO when Bluetooth enabled (#25201) --- drivers/bluetooth/bluetooth.c | 4 ++++ drivers/bluetooth/bluetooth.h | 5 +++++ quantum/action_util.c | 9 +++------ tmk_core/protocol.mk | 8 ++------ tmk_core/protocol/host.c | 18 ++++++++++++++++++ tmk_core/protocol/host.h | 1 + 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/bluetooth.c b/drivers/bluetooth/bluetooth.c index 3d41d8b11cd..61a3f0f32a4 100644 --- a/drivers/bluetooth/bluetooth.c +++ b/drivers/bluetooth/bluetooth.c @@ -11,6 +11,10 @@ __attribute__((weak)) bool bluetooth_is_connected(void) { return true; } +__attribute__((weak)) bool bluetooth_can_send_nkro(void) { + return false; +} + __attribute__((weak)) uint8_t bluetooth_keyboard_leds(void) { return 0; } diff --git a/drivers/bluetooth/bluetooth.h b/drivers/bluetooth/bluetooth.h index fe67c0c968f..e50b588db2f 100644 --- a/drivers/bluetooth/bluetooth.h +++ b/drivers/bluetooth/bluetooth.h @@ -37,6 +37,11 @@ void bluetooth_task(void); */ bool bluetooth_is_connected(void); +/** + * \brief Detects if `bluetooth_send_nkro` should be used over `bluetooth_send_keyboard`. + */ +bool bluetooth_can_send_nkro(void); + /** * \brief Get current LED state. */ diff --git a/quantum/action_util.c b/quantum/action_util.c index 9fe17f2124b..e821e113ef3 100644 --- a/quantum/action_util.c +++ b/quantum/action_util.c @@ -21,7 +21,6 @@ along with this program. If not, see . #include "action_layer.h" #include "timer.h" #include "keycode_config.h" -#include "usb_device_state.h" #include extern keymap_config_t keymap_config; @@ -319,14 +318,12 @@ void send_nkro_report(void) { */ void send_keyboard_report(void) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { send_nkro_report(); - } else { - send_6kro_report(); + return; } -#else - send_6kro_report(); #endif + send_6kro_report(); } /** \brief Get mods diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 8f019765484..2930efc2833 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -46,12 +46,8 @@ else endif ifeq ($(strip $(NKRO_ENABLE)), yes) - ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) - $(info NKRO is not currently supported with Bluetooth, and has been disabled.) - else - OPT_DEFS += -DNKRO_ENABLE - SHARED_EP_ENABLE = yes - endif + OPT_DEFS += -DNKRO_ENABLE + SHARED_EP_ENABLE = yes endif ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes) diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 4f3867df08d..e785cb24cc6 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -21,6 +21,7 @@ along with this program. If not, see . #include "host.h" #include "util.h" #include "debug.h" +#include "usb_device_state.h" #ifdef DIGITIZER_ENABLE # include "digitizer.h" @@ -90,6 +91,23 @@ static host_driver_t *host_get_active_driver(void) { return driver; } +bool host_can_send_nkro(void) { +#ifdef CONNECTION_ENABLE + switch (connection_get_host()) { +# ifdef BLUETOOTH_ENABLE + case CONNECTION_HOST_BLUETOOTH: + return bluetooth_can_send_nkro(); +# endif + case CONNECTION_HOST_NONE: + return false; + default: + break; + } +#endif + + return usb_device_state_get_protocol() == USB_PROTOCOL_REPORT; +} + #ifdef SPLIT_KEYBOARD uint8_t split_led_state = 0; void set_split_host_keyboard_leds(uint8_t led_state) { diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index d824fca077b..8e8a18e2ed3 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h @@ -32,6 +32,7 @@ void host_set_driver(host_driver_t *driver); host_driver_t *host_get_driver(void); /* host driver interface */ +bool host_can_send_nkro(void); uint8_t host_keyboard_leds(void); led_t host_keyboard_led_state(void); void host_keyboard_send(report_keyboard_t *report);