diff options
| author | Pete Sevander <pete.sevander@gmail.com> | 2021-08-14 07:45:52 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-14 14:45:52 +1000 |
| commit | fd3dc3a997d86be0ab9cdccd0099c4f4c219747a (patch) | |
| tree | b2021695a424f2e18dbe53eecd9e45e53fbae28c /quantum/process_keycode | |
| parent | e80772da401e545887b84b8addc4169b090cfa3e (diff) | |
| download | qmk_firmware-fd3dc3a997d86be0ab9cdccd0099c4f4c219747a.tar.gz qmk_firmware-fd3dc3a997d86be0ab9cdccd0099c4f4c219747a.zip | |
Fix `combo_disable` (#13988)
- Dump key buffer when combos are disabled.
- Recursive calls to `dump_key_buffer` need to start dumping the buffer
from index i+1 to avoid possible infinite loops.
- Handle combo key releases even though combo processing is disabled.
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_combo.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index b4e698dec..e8661839c 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
| @@ -164,11 +164,15 @@ void clear_combos(void) { | |||
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | static inline void dump_key_buffer(void) { | 166 | static inline void dump_key_buffer(void) { |
| 167 | /* First call start from 0 index; recursive calls need to start from i+1 index */ | ||
| 168 | static uint8_t key_buffer_next = 0; | ||
| 169 | |||
| 167 | if (key_buffer_size == 0) { | 170 | if (key_buffer_size == 0) { |
| 168 | return; | 171 | return; |
| 169 | } | 172 | } |
| 170 | 173 | ||
| 171 | for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) { | 174 | for (uint8_t key_buffer_i = key_buffer_next; key_buffer_i < key_buffer_size; key_buffer_i++) { |
| 175 | key_buffer_next = key_buffer_i + 1; | ||
| 172 | 176 | ||
| 173 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; | 177 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; |
| 174 | keyrecord_t *record = &qrecord->record; | 178 | keyrecord_t *record = &qrecord->record; |
| @@ -189,7 +193,7 @@ static inline void dump_key_buffer(void) { | |||
| 189 | record->event.time = 0; | 193 | record->event.time = 0; |
| 190 | } | 194 | } |
| 191 | 195 | ||
| 192 | key_buffer_size = 0; | 196 | key_buffer_next = key_buffer_size = 0; |
| 193 | } | 197 | } |
| 194 | 198 | ||
| 195 | #define NO_COMBO_KEYS_ARE_DOWN (0 == COMBO_STATE(combo)) | 199 | #define NO_COMBO_KEYS_ARE_DOWN (0 == COMBO_STATE(combo)) |
| @@ -340,9 +344,9 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 340 | return false; | 344 | return false; |
| 341 | } | 345 | } |
| 342 | 346 | ||
| 343 | bool key_is_part_of_combo = !COMBO_DISABLED(combo); | 347 | bool key_is_part_of_combo = !COMBO_DISABLED(combo) && is_combo_enabled(); |
| 344 | 348 | ||
| 345 | if (record->event.pressed && !COMBO_DISABLED(combo)) { | 349 | if (record->event.pressed && key_is_part_of_combo) { |
| 346 | uint16_t time = _get_combo_term(combo_index, combo); | 350 | uint16_t time = _get_combo_term(combo_index, combo); |
| 347 | if (!COMBO_ACTIVE(combo)) { | 351 | if (!COMBO_ACTIVE(combo)) { |
| 348 | KEY_STATE_DOWN(combo->state, key_index); | 352 | KEY_STATE_DOWN(combo->state, key_index); |
| @@ -472,10 +476,6 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { | |||
| 472 | return true; | 476 | return true; |
| 473 | } | 477 | } |
| 474 | 478 | ||
| 475 | if (!is_combo_enabled()) { | ||
| 476 | return true; | ||
| 477 | } | ||
| 478 | |||
| 479 | #ifdef COMBO_ONLY_FROM_LAYER | 479 | #ifdef COMBO_ONLY_FROM_LAYER |
| 480 | /* Only check keycodes from one layer. */ | 480 | /* Only check keycodes from one layer. */ |
| 481 | keycode = keymap_key_to_keycode(COMBO_ONLY_FROM_LAYER, record->event.key); | 481 | keycode = keymap_key_to_keycode(COMBO_ONLY_FROM_LAYER, record->event.key); |
| @@ -550,6 +550,8 @@ void combo_disable(void) { | |||
| 550 | #endif | 550 | #endif |
| 551 | b_combo_enable = false; | 551 | b_combo_enable = false; |
| 552 | combo_buffer_read = combo_buffer_write; | 552 | combo_buffer_read = combo_buffer_write; |
| 553 | clear_combos(); | ||
| 554 | dump_key_buffer(); | ||
| 553 | } | 555 | } |
| 554 | 556 | ||
| 555 | void combo_toggle(void) { | 557 | void combo_toggle(void) { |
