diff options
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_combo.c | 43 | ||||
-rw-r--r-- | quantum/process_keycode/process_combo.h | 5 | ||||
-rw-r--r-- | quantum/process_keycode/process_leader.c | 16 | ||||
-rw-r--r-- | quantum/process_keycode/process_space_cadet.c | 12 | ||||
-rw-r--r-- | quantum/process_keycode/process_ucis.c | 5 |
5 files changed, 73 insertions, 8 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 2c6c9d0d5f..d3c3b1673c 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -28,6 +28,7 @@ static uint16_t timer = 0; static uint8_t current_combo_index = 0; static bool drop_buffer = false; static bool is_active = false; +static bool b_combo_enable = true; // defaults to enabled static uint8_t buffer_size = 0; #ifdef COMBO_ALLOW_ACTION_KEYS @@ -128,6 +129,23 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { drop_buffer = false; bool no_combo_keys_pressed = true; + if (keycode == CMB_ON && record->event.pressed) { + combo_enable(); + return true; + } + + if (keycode == CMB_OFF && record->event.pressed) { + combo_disable(); + return true; + } + + if (keycode == CMB_TOG && record->event.pressed) { + combo_toggle(); + return true; + } + + if (!is_combo_enabled()) { return true; } + for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) { combo_t *combo = &key_combos[current_combo_index]; @@ -166,7 +184,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { } void matrix_scan_combo(void) { - if (is_active && timer && timer_elapsed(timer) > COMBO_TERM) { + if (b_combo_enable && is_active && timer && timer_elapsed(timer) > COMBO_TERM) { /* This disables the combo, meaning key events for this * combo will be handled by the next processors in the chain @@ -175,3 +193,26 @@ void matrix_scan_combo(void) { dump_key_buffer(true); } } + +void combo_enable(void) { + b_combo_enable = true; +} + +void combo_disable(void) { + b_combo_enable = is_active = false; + timer = 0; + dump_key_buffer(true); + +} + +void combo_toggle(void) { + if (b_combo_enable) { + combo_disable(); + } else { + combo_enable(); + } +} + +bool is_combo_enabled(void) { + return b_combo_enable; +} diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index f06d2d3454..aab2849572 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h @@ -58,4 +58,9 @@ bool process_combo(uint16_t keycode, keyrecord_t *record); void matrix_scan_combo(void); void process_combo_event(uint8_t combo_index, bool pressed); +void combo_enable(void); +void combo_disable(void); +void combo_toggle(void); +bool is_combo_enabled(void); + #endif diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index 897e9eabf6..f787e6b017 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -17,6 +17,7 @@ #ifdef LEADER_ENABLE #include "process_leader.h" +#include <string.h> #ifndef LEADER_TIMEOUT #define LEADER_TIMEOUT 300 @@ -41,11 +42,7 @@ void qk_leader_start(void) { 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; + memset(leader_sequence, 0, sizeof(leader_sequence)); } bool process_leader(uint16_t keycode, keyrecord_t *record) { @@ -58,8 +55,13 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { keycode = keycode & 0xFF; } #endif // LEADER_KEY_STRICT_KEY_PROCESSING - leader_sequence[leader_sequence_size] = keycode; - leader_sequence_size++; + 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 diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index 089199eee2..c8721d446c 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c @@ -81,11 +81,17 @@ static uint8_t sc_last = 0; static uint16_t sc_timer = 0; +#ifdef SPACE_CADET_MODIFIER_CARRYOVER +static uint8_t sc_mods = 0; +#endif void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { if (record->event.pressed) { sc_last = holdMod; sc_timer = timer_read (); +#ifdef SPACE_CADET_MODIFIER_CARRYOVER + sc_mods = get_mods(); +#endif if (IS_MOD(holdMod)) { register_mods(MOD_BIT(holdMod)); } @@ -100,7 +106,13 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u register_mods(MOD_BIT(tapMod)); } } +#ifdef SPACE_CADET_MODIFIER_CARRYOVER + set_weak_mods(sc_mods); +#endif tap_code(keycode); +#ifdef SPACE_CADET_MODIFIER_CARRYOVER + clear_weak_mods(); +#endif if (IS_MOD(tapMod)) { unregister_mods(MOD_BIT(tapMod)); } diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 5de2e41fc3..fd4508b535 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c @@ -64,6 +64,10 @@ void qk_ucis_symbol_fallback (void) { } } +__attribute__((weak)) +void qk_ucis_cancel(void) { +} + void register_ucis(const char *hex) { for(int i = 0; hex[i]; i++) { uint8_t kc = 0; @@ -130,6 +134,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) { if (keycode == KC_ESC) { qk_ucis_state.in_progress = false; + qk_ucis_cancel(); return false; } |