diff --git a/quantum/action_util.c b/quantum/action_util.c index 9a85bd504069..08b5f5b18d5f 100644 --- a/quantum/action_util.c +++ b/quantum/action_util.c @@ -35,6 +35,7 @@ static uint8_t suppressed_mods = 0; // TODO: pointer variable is not needed // report_keyboard_t keyboard_report = {}; report_keyboard_t *keyboard_report = &(report_keyboard_t){}; +static bool keyboard_report_dirty = false; extern inline void add_key(uint8_t key); extern inline void del_key(uint8_t key); @@ -217,7 +218,7 @@ bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; } /** \brief Send keyboard report * - * FIXME: needs doc + * Flags the keyboard report to be sent at the soonest availability */ void send_keyboard_report(void) { keyboard_report->mods = real_mods; @@ -246,7 +247,18 @@ void send_keyboard_report(void) { keyboard_report->mods |= weak_override_mods; #endif - host_keyboard_send(keyboard_report); + keyboard_report_dirty = true; +} + +/** \brief Send keyboard report immediate + * + * Checks if the keyboard report is different from the last one sent, and if so, sends the updated one + */ +void send_keyboard_report_immediate(void) { + if (keyboard_report_dirty) { + host_keyboard_send(keyboard_report); + keyboard_report_dirty = false; + } } /** \brief Get mods diff --git a/quantum/action_util.h b/quantum/action_util.h index f2b3897ae501..cdb42da010b9 100644 --- a/quantum/action_util.h +++ b/quantum/action_util.h @@ -27,6 +27,7 @@ extern "C" { extern report_keyboard_t *keyboard_report; void send_keyboard_report(void); +void send_keyboard_report_immediate(void); /* key */ inline void add_key(uint8_t key) { add_key_to_report(keyboard_report, key); } diff --git a/quantum/keyboard.c b/quantum/keyboard.c index f2a0889c12bc..dd40b3fa3aa2 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -31,6 +31,7 @@ along with this program. If not, see . #include "sendchar.h" #include "eeconfig.h" #include "action_layer.h" +#include "action_util.h" #ifdef BACKLIGHT_ENABLE # include "backlight.h" #endif @@ -425,6 +426,8 @@ void keyboard_task(void) { MATRIX_LOOP_END: + send_keyboard_report_immediate(); + #ifdef DEBUG_MATRIX_SCAN_RATE matrix_scan_perf_task(); #endif