diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/process_keycode/process_leader.c | 51 | ||||
-rw-r--r-- | quantum/process_keycode/process_leader.h | 2 |
2 files changed, 32 insertions, 21 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; diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h index 59c3eed1be..15bccc3f67 100644 --- a/quantum/process_keycode/process_leader.h +++ b/quantum/process_keycode/process_leader.h @@ -24,7 +24,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record); void leader_start(void); void leader_end(void); - +void qk_leader_start(void); #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0) |