From 2d596e7060f5bd5db4cab0d9dc8f3432cf273743 Mon Sep 17 00:00:00 2001 From: Pete Sevander Date: Thu, 13 Jan 2022 09:21:29 +0200 Subject: [PATCH 1/3] Add TAP_CODE_DELAY after combo buffer dump. Some software don't like key press and release events too close to each other, so a delay is needed after dumping the key buffer in combo processing. --- quantum/process_keycode/process_combo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 8040ede5289a..590c9a77337f 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -221,6 +221,10 @@ static inline void dump_key_buffer(void) { } key_buffer_next = key_buffer_size = 0; + +#if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +#endif } #define NO_COMBO_KEYS_ARE_DOWN (0 == COMBO_STATE(combo)) From de9d151d8aafba56356365fa43b11d4c358f55a8 Mon Sep 17 00:00:00 2001 From: Pete Sevander Date: Thu, 13 Jan 2022 10:20:22 +0200 Subject: [PATCH 2/3] Clear weak mods after dumping keys from combo buffer. Before, weak mods from combos could leak to the next key press if pressed too fast. --- quantum/process_keycode/process_combo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 590c9a77337f..15410203e8e5 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -218,6 +218,7 @@ static inline void dump_key_buffer(void) { #endif } record->event.time = 0; + clear_weak_mods(); } key_buffer_next = key_buffer_size = 0; From 51a46f6567f87b7b59e251074fa40cdd412f686e Mon Sep 17 00:00:00 2001 From: Pete Sevander Date: Thu, 13 Jan 2022 23:03:18 +0200 Subject: [PATCH 3/3] Only delay once and for a non-tapping key. --- quantum/process_keycode/process_combo.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 15410203e8e5..21fd737ab7db 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -17,6 +17,7 @@ #include "print.h" #include "process_combo.h" #include "action_tapping.h" +#include "action.h" #ifdef COMBO_COUNT __attribute__((weak)) combo_t key_combos[COMBO_COUNT]; @@ -193,6 +194,9 @@ void clear_combos(void) { static inline void dump_key_buffer(void) { /* First call start from 0 index; recursive calls need to start from i+1 index */ static uint8_t key_buffer_next = 0; +#if TAP_CODE_DELAY > 0 + bool delay_done = false; +#endif if (key_buffer_size == 0) { return; @@ -219,13 +223,17 @@ static inline void dump_key_buffer(void) { } record->event.time = 0; clear_weak_mods(); - } - - key_buffer_next = key_buffer_size = 0; #if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); + // only delay once and for a non-tapping key + if (!delay_done && !is_tap_record(record)) { + delay_done = true; + wait_ms(TAP_CODE_DELAY); + } #endif + } + + key_buffer_next = key_buffer_size = 0; } #define NO_COMBO_KEYS_ARE_DOWN (0 == COMBO_STATE(combo))