diff options
Diffstat (limited to 'quantum/process_keycode')
30 files changed, 2028 insertions, 2227 deletions
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index 0a25aa5354..3b5fa8490b 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c @@ -2,30 +2,28 @@ #include "process_audio.h" #ifndef VOICE_CHANGE_SONG - #define VOICE_CHANGE_SONG SONG(VOICE_CHANGE_SOUND) +# define VOICE_CHANGE_SONG SONG(VOICE_CHANGE_SOUND) #endif float voice_change_song[][2] = VOICE_CHANGE_SONG; #ifndef PITCH_STANDARD_A - #define PITCH_STANDARD_A 440.0f +# define PITCH_STANDARD_A 440.0f #endif -float compute_freq_for_midi_note(uint8_t note) -{ +float compute_freq_for_midi_note(uint8_t note) { // https://en.wikipedia.org/wiki/MIDI_tuning_standard return pow(2.0, (note - 69) / 12.0) * PITCH_STANDARD_A; } bool process_audio(uint16_t keycode, keyrecord_t *record) { - if (keycode == AU_ON && record->event.pressed) { - audio_on(); - return false; + audio_on(); + return false; } if (keycode == AU_OFF && record->event.pressed) { - audio_off(); - return false; + audio_off(); + return false; } if (keycode == AU_TOG && record->event.pressed) { @@ -52,17 +50,10 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) { return true; } -void process_audio_noteon(uint8_t note) { - play_note(compute_freq_for_midi_note(note), 0xF); -} +void process_audio_noteon(uint8_t note) { play_note(compute_freq_for_midi_note(note), 0xF); } -void process_audio_noteoff(uint8_t note) { - stop_note(compute_freq_for_midi_note(note)); -} +void process_audio_noteoff(uint8_t note) { stop_note(compute_freq_for_midi_note(note)); } -void process_audio_all_notes_off(void) { - stop_all_notes(); -} +void process_audio_all_notes_off(void) { stop_all_notes(); } -__attribute__ ((weak)) -void audio_on_user() {} +__attribute__((weak)) void audio_on_user() {} diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 0d0930ee67..4ae3fe446e 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -16,195 +16,185 @@ #ifdef AUTO_SHIFT_ENABLE -#include <stdio.h> +# include <stdio.h> -#include "process_auto_shift.h" +# include "process_auto_shift.h" -#define TAP(key) \ - register_code(key); \ - unregister_code(key) +# define TAP(key) \ + register_code(key); \ + unregister_code(key) -#define TAP_WITH_MOD(mod, key) \ - register_code(mod); \ - register_code(key); \ - unregister_code(key); \ - unregister_code(mod) +# define TAP_WITH_MOD(mod, key) \ + register_code(mod); \ + register_code(key); \ + unregister_code(key); \ + unregister_code(mod) -uint16_t autoshift_time = 0; +uint16_t autoshift_time = 0; uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; uint16_t autoshift_lastkey = KC_NO; void autoshift_timer_report(void) { - char display[8]; + char display[8]; - snprintf(display, 8, "\n%d\n", autoshift_timeout); + snprintf(display, 8, "\n%d\n", autoshift_timeout); - send_string((const char *)display); + send_string((const char *)display); } void autoshift_on(uint16_t keycode) { - autoshift_time = timer_read(); - autoshift_lastkey = keycode; + autoshift_time = timer_read(); + autoshift_lastkey = keycode; } void autoshift_flush(void) { - if (autoshift_lastkey != KC_NO) { - uint16_t elapsed = timer_elapsed(autoshift_time); + if (autoshift_lastkey != KC_NO) { + uint16_t elapsed = timer_elapsed(autoshift_time); - if (elapsed > autoshift_timeout) { - register_code(KC_LSFT); - } + if (elapsed > autoshift_timeout) { + register_code(KC_LSFT); + } - register_code(autoshift_lastkey); - unregister_code(autoshift_lastkey); + register_code(autoshift_lastkey); + unregister_code(autoshift_lastkey); - if (elapsed > autoshift_timeout) { - unregister_code(KC_LSFT); - } + if (elapsed > autoshift_timeout) { + unregister_code(KC_LSFT); + } - autoshift_time = 0; - autoshift_lastkey = KC_NO; - } + autoshift_time = 0; + autoshift_lastkey = KC_NO; + } } bool autoshift_enabled = true; -void autoshift_enable(void) { - autoshift_enabled = true; -} +void autoshift_enable(void) { autoshift_enabled = true; } void autoshift_disable(void) { - autoshift_enabled = false; - autoshift_flush(); -} - -void autoshift_toggle(void) { - if (autoshift_enabled) { autoshift_enabled = false; autoshift_flush(); - } - else { - autoshift_enabled = true; - } } -bool autoshift_state(void) { - return autoshift_enabled; +void autoshift_toggle(void) { + if (autoshift_enabled) { + autoshift_enabled = false; + autoshift_flush(); + } else { + autoshift_enabled = true; + } } -bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { -#ifndef AUTO_SHIFT_MODIFIERS - static uint8_t any_mod_pressed; -#endif - - if (record->event.pressed) { - switch (keycode) { - case KC_ASUP: - autoshift_timeout += 5; - return false; - - case KC_ASDN: - autoshift_timeout -= 5; - return false; - - case KC_ASRP: - autoshift_timer_report(); - return false; - - case KC_ASTG: - autoshift_toggle(); - return false; - case KC_ASON: - autoshift_enable(); - return false; - case KC_ASOFF: - autoshift_disable(); - return false; - -#ifndef NO_AUTO_SHIFT_ALPHA - case KC_A: - case KC_B: - case KC_C: - case KC_D: - case KC_E: - case KC_F: - case KC_G: - case KC_H: - case KC_I: - case KC_J: - case KC_K: - case KC_L: - case KC_M: - case KC_N: - case KC_O: - case KC_P: - case KC_Q: - case KC_R: - case KC_S: - case KC_T: - case KC_U: - case KC_V: - case KC_W: - case KC_X: - case KC_Y: - case KC_Z: -#endif -#ifndef NO_AUTO_SHIFT_NUMERIC - case KC_1: - case KC_2: - case KC_3: - case KC_4: - case KC_5: - case KC_6: - case KC_7: - case KC_8: - case KC_9: - case KC_0: -#endif -#ifndef NO_AUTO_SHIFT_SPECIAL - case KC_MINUS: - case KC_EQL: - case KC_TAB: - case KC_LBRC: - case KC_RBRC: - case KC_BSLS: - case KC_SCLN: - case KC_QUOT: - case KC_COMM: - case KC_DOT: - case KC_SLSH: - case KC_GRAVE: - case KC_NONUS_BSLASH: - case KC_NONUS_HASH: -#endif +bool autoshift_state(void) { return autoshift_enabled; } - autoshift_flush(); - if (!autoshift_enabled) return true; - -#ifndef AUTO_SHIFT_MODIFIERS - any_mod_pressed = get_mods() & ( - MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)| - MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)| - MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTL)| - MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT) - ); - - if (any_mod_pressed) { - return true; +bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { +# ifndef AUTO_SHIFT_MODIFIERS + static uint8_t any_mod_pressed; +# endif + + if (record->event.pressed) { + switch (keycode) { + case KC_ASUP: + autoshift_timeout += 5; + return false; + + case KC_ASDN: + autoshift_timeout -= 5; + return false; + + case KC_ASRP: + autoshift_timer_report(); + return false; + + case KC_ASTG: + autoshift_toggle(); + return false; + case KC_ASON: + autoshift_enable(); + return false; + case KC_ASOFF: + autoshift_disable(); + return false; + +# ifndef NO_AUTO_SHIFT_ALPHA + case KC_A: + case KC_B: + case KC_C: + case KC_D: + case KC_E: + case KC_F: + case KC_G: + case KC_H: + case KC_I: + case KC_J: + case KC_K: + case KC_L: + case KC_M: + case KC_N: + case KC_O: + case KC_P: + case KC_Q: + case KC_R: + case KC_S: + case KC_T: + case KC_U: + case KC_V: + case KC_W: + case KC_X: + case KC_Y: + case KC_Z: +# endif +# ifndef NO_AUTO_SHIFT_NUMERIC + case KC_1: + case KC_2: + case KC_3: + case KC_4: + case KC_5: + case KC_6: + case KC_7: + case KC_8: + case KC_9: + case KC_0: +# endif +# ifndef NO_AUTO_SHIFT_SPECIAL + case KC_MINUS: + case KC_EQL: + case KC_TAB: + case KC_LBRC: + case KC_RBRC: + case KC_BSLS: + case KC_SCLN: + case KC_QUOT: + case KC_COMM: + case KC_DOT: + case KC_SLSH: + case KC_GRAVE: + case KC_NONUS_BSLASH: + case KC_NONUS_HASH: +# endif + + autoshift_flush(); + if (!autoshift_enabled) return true; + +# ifndef AUTO_SHIFT_MODIFIERS + any_mod_pressed = get_mods() & (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI) | MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT) | MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL) | MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)); + + if (any_mod_pressed) { + return true; + } +# endif + + autoshift_on(keycode); + return false; + + default: + autoshift_flush(); + return true; } -#endif - - autoshift_on(keycode); - return false; - - default: + } else { autoshift_flush(); - return true; } - } else { - autoshift_flush(); - } - return true; + return true; } #endif diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h index a4abf04145..083325d8e3 100644 --- a/quantum/process_keycode/process_auto_shift.h +++ b/quantum/process_keycode/process_auto_shift.h @@ -20,7 +20,7 @@ #include "quantum.h" #ifndef AUTO_SHIFT_TIMEOUT - #define AUTO_SHIFT_TIMEOUT 175 +# define AUTO_SHIFT_TIMEOUT 175 #endif bool process_auto_shift(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c index 43b803afe7..6ab382d4aa 100644 --- a/quantum/process_keycode/process_clicky.c +++ b/quantum/process_keycode/process_clicky.c @@ -3,104 +3,111 @@ #ifdef AUDIO_CLICKY -#ifndef AUDIO_CLICKY_DELAY_DURATION -#define AUDIO_CLICKY_DELAY_DURATION 1 -#endif // !AUDIO_CLICKY_DELAY_DURATION -#ifndef AUDIO_CLICKY_FREQ_DEFAULT -#define AUDIO_CLICKY_FREQ_DEFAULT 440.0f -#endif // !AUDIO_CLICKY_FREQ_DEFAULT -#ifndef AUDIO_CLICKY_FREQ_MIN -#define AUDIO_CLICKY_FREQ_MIN 65.0f -#endif // !AUDIO_CLICKY_FREQ_MIN -#ifndef AUDIO_CLICKY_FREQ_MAX -#define AUDIO_CLICKY_FREQ_MAX 1500.0f -#endif // !AUDIO_CLICKY_FREQ_MAX -#ifndef AUDIO_CLICKY_FREQ_FACTOR -#define AUDIO_CLICKY_FREQ_FACTOR 1.18921f -#endif // !AUDIO_CLICKY_FREQ_FACTOR -#ifndef AUDIO_CLICKY_FREQ_RANDOMNESS -#define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f -#endif // !AUDIO_CLICKY_FREQ_RANDOMNESS +# ifndef AUDIO_CLICKY_DELAY_DURATION +# define AUDIO_CLICKY_DELAY_DURATION 1 +# endif // !AUDIO_CLICKY_DELAY_DURATION +# ifndef AUDIO_CLICKY_FREQ_DEFAULT +# define AUDIO_CLICKY_FREQ_DEFAULT 440.0f +# endif // !AUDIO_CLICKY_FREQ_DEFAULT +# ifndef AUDIO_CLICKY_FREQ_MIN +# define AUDIO_CLICKY_FREQ_MIN 65.0f +# endif // !AUDIO_CLICKY_FREQ_MIN +# ifndef AUDIO_CLICKY_FREQ_MAX +# define AUDIO_CLICKY_FREQ_MAX 1500.0f +# endif // !AUDIO_CLICKY_FREQ_MAX +# ifndef AUDIO_CLICKY_FREQ_FACTOR +# define AUDIO_CLICKY_FREQ_FACTOR 1.18921f +# endif // !AUDIO_CLICKY_FREQ_FACTOR +# ifndef AUDIO_CLICKY_FREQ_RANDOMNESS +# define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f +# endif // !AUDIO_CLICKY_FREQ_RANDOMNESS float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS; // the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky" -float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations +float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations extern audio_config_t audio_config; -#ifndef NO_MUSIC_MODE +# ifndef NO_MUSIC_MODE extern bool music_activated; extern bool midi_activated; -#endif // !NO_MUSIC_MODE +# endif // !NO_MUSIC_MODE void clicky_play(void) { -#ifndef NO_MUSIC_MODE - if (music_activated || midi_activated || !audio_config.enable) return; -#endif // !NO_MUSIC_MODE - clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) ); - clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) ); - PLAY_SONG(clicky_song); +# ifndef NO_MUSIC_MODE + if (music_activated || midi_activated || !audio_config.enable) return; +# endif // !NO_MUSIC_MODE + clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); + clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); + PLAY_SONG(clicky_song); } void clicky_freq_up(void) { - float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR; - if (new_freq < AUDIO_CLICKY_FREQ_MAX) { - clicky_freq = new_freq; - } + float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR; + if (new_freq < AUDIO_CLICKY_FREQ_MAX) { + clicky_freq = new_freq; + } } void clicky_freq_down(void) { - float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR; - if (new_freq > AUDIO_CLICKY_FREQ_MIN) { - clicky_freq = new_freq; - } + float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR; + if (new_freq > AUDIO_CLICKY_FREQ_MIN) { + clicky_freq = new_freq; + } } -void clicky_freq_reset(void) { - clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; -} +void clicky_freq_reset(void) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; } void clicky_toggle(void) { - audio_config.clicky_enable ^= 1; - eeconfig_update_audio(audio_config.raw); + audio_config.clicky_enable ^= 1; + eeconfig_update_audio(audio_config.raw); } void clicky_on(void) { - audio_config.clicky_enable = 1; - eeconfig_update_audio(audio_config.raw); + audio_config.clicky_enable = 1; + eeconfig_update_audio(audio_config.raw); } void clicky_off(void) { - audio_config.clicky_enable = 0; - eeconfig_update_audio(audio_config.raw); + audio_config.clicky_enable = 0; + eeconfig_update_audio(audio_config.raw); } -bool is_clicky_on(void) { - return (audio_config.clicky_enable != 0); -} +bool is_clicky_on(void) { return (audio_config.clicky_enable != 0); } bool process_clicky(uint16_t keycode, keyrecord_t *record) { - if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_toggle(); } - - if (keycode == CLICKY_ENABLE && record->event.pressed) { clicky_on(); } - if (keycode == CLICKY_DISABLE && record->event.pressed) { clicky_off(); } + if (keycode == CLICKY_TOGGLE && record->event.pressed) { + clicky_toggle(); + } - if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq_reset(); } + if (keycode == CLICKY_ENABLE && record->event.pressed) { + clicky_on(); + } + if (keycode == CLICKY_DISABLE && record->event.pressed) { + clicky_off(); + } - if (keycode == CLICKY_UP && record->event.pressed) { clicky_freq_up(); } - if (keycode == CLICKY_DOWN && record->event.pressed) { clicky_freq_down(); } + if (keycode == CLICKY_RESET && record->event.pressed) { + clicky_freq_reset(); + } + if (keycode == CLICKY_UP && record->event.pressed) { + clicky_freq_up(); + } + if (keycode == CLICKY_DOWN && record->event.pressed) { + clicky_freq_down(); + } - if (audio_config.enable && audio_config.clicky_enable) { - if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound - if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM - clicky_play(); - } + if (audio_config.enable && audio_config.clicky_enable) { + if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound + if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM + clicky_play(); + } + } } - } - return true; + return true; } -#endif //AUDIO_CLICKY +#endif // AUDIO_CLICKY diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index d3c3b1673c..f40ca74525 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -21,14 +21,13 @@ __attribute__((weak)) combo_t key_combos[COMBO_COUNT] = { }; -__attribute__((weak)) void process_combo_event(uint8_t combo_index, - bool pressed) {} +__attribute__((weak)) void process_combo_event(uint8_t combo_index, bool pressed) {} -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 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 @@ -38,171 +37,163 @@ static uint16_t key_buffer[MAX_COMBO_LENGTH]; #endif static inline void send_combo(uint16_t action, bool pressed) { - if (action) { - if (pressed) { - register_code16(action); + if (action) { + if (pressed) { + register_code16(action); + } else { + unregister_code16(action); + } } else { - unregister_code16(action); + process_combo_event(current_combo_index, pressed); } - } else { - process_combo_event(current_combo_index, pressed); - } } static inline void dump_key_buffer(bool emit) { - if (buffer_size == 0) { - return; - } + if (buffer_size == 0) { + return; + } - if (emit) { - for (uint8_t i = 0; i < buffer_size; i++) { + if (emit) { + for (uint8_t i = 0; i < buffer_size; i++) { #ifdef COMBO_ALLOW_ACTION_KEYS - const action_t action = store_or_get_action(key_buffer[i].event.pressed, - key_buffer[i].event.key); - process_action(&(key_buffer[i]), action); + const action_t action = store_or_get_action(key_buffer[i].event.pressed, key_buffer[i].event.key); + process_action(&(key_buffer[i]), action); #else - register_code16(key_buffer[i]); - send_keyboard_report(); + register_code16(key_buffer[i]); + send_keyboard_report(); #endif + } } - } - buffer_size = 0; + buffer_size = 0; } #define ALL_COMBO_KEYS_ARE_DOWN (((1 << count) - 1) == combo->state) -#define KEY_STATE_DOWN(key) \ - do { \ - combo->state |= (1 << key); \ - } while (0) -#define KEY_STATE_UP(key) \ - do { \ - combo->state &= ~(1 << key); \ - } while (0) - -static bool process_single_combo(combo_t *combo, uint16_t keycode, - keyrecord_t *record) { - uint8_t count = 0; - uint8_t index = -1; - /* Find index of keycode and number of combo keys */ - for (const uint16_t *keys = combo->keys;; ++count) { - uint16_t key = pgm_read_word(&keys[count]); - if (keycode == key) - index = count; - if (COMBO_END == key) - break; - } - - /* Continue processing if not a combo key */ - if (-1 == (int8_t)index) - return false; - - bool is_combo_active = is_active; - - if (record->event.pressed) { - KEY_STATE_DOWN(index); - - if (is_combo_active) { - if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ - send_combo(combo->keycode, true); - drop_buffer = true; - } +#define KEY_STATE_DOWN(key) \ + do { \ + combo->state |= (1 << key); \ + } while (0) +#define KEY_STATE_UP(key) \ + do { \ + combo->state &= ~(1 << key); \ + } while (0) + +static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record) { + uint8_t count = 0; + uint8_t index = -1; + /* Find index of keycode and number of combo keys */ + for (const uint16_t *keys = combo->keys;; ++count) { + uint16_t key = pgm_read_word(&keys[count]); + if (keycode == key) index = count; + if (COMBO_END == key) break; } - } else { - if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was released */ - send_combo(combo->keycode, false); + + /* Continue processing if not a combo key */ + if (-1 == (int8_t)index) return false; + + bool is_combo_active = is_active; + + if (record->event.pressed) { + KEY_STATE_DOWN(index); + + if (is_combo_active) { + if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ + send_combo(combo->keycode, true); + drop_buffer = true; + } + } } else { - /* continue processing without immediately returning */ - is_combo_active = false; + if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was released */ + send_combo(combo->keycode, false); + } else { + /* continue processing without immediately returning */ + is_combo_active = false; + } + + KEY_STATE_UP(index); } - KEY_STATE_UP(index); - } - - return is_combo_active; + return is_combo_active; } #define NO_COMBO_KEYS_ARE_DOWN (0 == combo->state) bool process_combo(uint16_t keycode, keyrecord_t *record) { - bool is_combo_key = false; - 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]; - is_combo_key |= process_single_combo(combo, keycode, record); - no_combo_keys_pressed = no_combo_keys_pressed && NO_COMBO_KEYS_ARE_DOWN; - } - - if (drop_buffer) { - /* buffer is only dropped when we complete a combo, so we refresh the timer - * here */ - timer = timer_read(); - dump_key_buffer(false); - } else if (!is_combo_key) { - /* if no combos claim the key we need to emit the keybuffer */ - dump_key_buffer(true); + bool is_combo_key = false; + drop_buffer = false; + bool no_combo_keys_pressed = true; + + if (keycode == CMB_ON && record->event.pressed) { + combo_enable(); + return true; + } - // reset state if there are no combo keys pressed at all - if (no_combo_keys_pressed) { - timer = 0; - is_active = true; + if (keycode == CMB_OFF && record->event.pressed) { + combo_disable(); + return true; } - } else if (record->event.pressed && is_active) { - /* otherwise the key is consumed and placed in the buffer */ - timer = timer_read(); - if (buffer_size < MAX_COMBO_LENGTH) { + 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]; + is_combo_key |= process_single_combo(combo, keycode, record); + no_combo_keys_pressed = no_combo_keys_pressed && NO_COMBO_KEYS_ARE_DOWN; + } + + if (drop_buffer) { + /* buffer is only dropped when we complete a combo, so we refresh the timer + * here */ + timer = timer_read(); + dump_key_bu |