diff options
Diffstat (limited to 'quantum/process_keycode/process_leader.c')
-rw-r--r-- | quantum/process_keycode/process_leader.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index f787e6b01..58a615d85 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -16,64 +16,64 @@ #ifdef LEADER_ENABLE -#include "process_leader.h" -#include <string.h> +# include "process_leader.h" +# include <string.h> -#ifndef LEADER_TIMEOUT - #define LEADER_TIMEOUT 300 -#endif +# ifndef LEADER_TIMEOUT +# define LEADER_TIMEOUT 300 +# endif -__attribute__ ((weak)) -void leader_start(void) {} +__attribute__((weak)) void leader_start(void) {} -__attribute__ ((weak)) -void leader_end(void) {} +__attribute__((weak)) void leader_end(void) {} // Leader key stuff -bool leading = false; +bool leading = false; uint16_t leader_time = 0; -uint16_t leader_sequence[5] = {0, 0, 0, 0, 0}; -uint8_t leader_sequence_size = 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; - memset(leader_sequence, 0, sizeof(leader_sequence)); + if (leading) { + return; + } + leader_start(); + leading = true; + leader_time = timer_read(); + leader_sequence_size = 0; + memset(leader_sequence, 0, sizeof(leader_sequence)); } 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 - if ( leader_sequence_size < ( sizeof(leader_sequence) / sizeof(leader_sequence[0]) ) ) { - leader_sequence[leader_sequence_size] = keycode; - leader_sequence_size++; + // 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 + if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) { + leader_sequence[leader_sequence_size] = keycode; + leader_sequence_size++; + } else { + leading = false; + leader_end(); + } +# ifdef LEADER_PER_KEY_TIMING + leader_time = timer_read(); +# endif + return false; + } } else { - leading = false; - leader_end(); + if (keycode == KC_LEAD) { + qk_leader_start(); + } } -#ifdef LEADER_PER_KEY_TIMING - leader_time = timer_read(); -#endif - return false; - } - } else { - if (keycode == KC_LEAD) { - qk_leader_start(); - } } - } - return true; + return true; } #endif |