diff options
Diffstat (limited to 'quantum/process_keycode/process_leader.c')
-rw-r--r-- | quantum/process_keycode/process_leader.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index b32fc1db6a..57fccdc7e7 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -35,31 +35,42 @@ uint16_t leader_time = 0; uint16_t leader_sequence[5] = {0, 0, 0, 0, 0}; uint8_t leader_sequence_size = 0; +void qk_leader_start(void) { + if (leading) { return; } + leader_start(); + leading = true; + leader_time = timer_read(); + leader_sequence_size = 0; + leader_sequence[0] = 0; + leader_sequence[1] = 0; + leader_sequence[2] = 0; + leader_sequence[3] = 0; + leader_sequence[4] = 0; +} + bool process_leader(uint16_t keycode, keyrecord_t *record) { // Leader key set-up if (record->event.pressed) { + if (leading) { + if (timer_elapsed(leader_time) < LEADER_TIMEOUT) { +#ifndef LEADER_KEY_STRICT_KEY_PROCESSING + if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { + keycode = keycode & 0xFF; + } +#endif // LEADER_KEY_STRICT_KEY_PROCESSING + leader_sequence[leader_sequence_size] = keycode; + leader_sequence_size++; #ifdef LEADER_PER_KEY_TIMING - leader_time = timer_read(); + leader_time = timer_read(); #endif - if (!leading && keycode == KC_LEAD) { - leader_start(); - leading = true; -#ifndef LEADER_PER_KEY_TIMING - leader_time = timer_read(); -#endif - leader_time = timer_read(); - leader_sequence_size = 0; - leader_sequence[0] = 0; - leader_sequence[1] = 0; - leader_sequence[2] = 0; - leader_sequence[3] = 0; - leader_sequence[4] = 0; - return false; - } - if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) { - leader_sequence[leader_sequence_size] = keycode; - leader_sequence_size++; - return false; + return false; + } + } else { + if (keycode == KC_LEAD) { + qk_leader_start(); + return false; + } + break; } } return true; |