diff options
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 14 | ||||
-rw-r--r-- | quantum/process_keycode/process_caps_word.c | 67 | ||||
-rw-r--r-- | quantum/process_keycode/process_combo.c | 12 | ||||
-rw-r--r-- | quantum/process_keycode/process_dynamic_macro.c | 10 | ||||
-rw-r--r-- | quantum/process_keycode/process_dynamic_macro.h | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_steno.c | 6 |
6 files changed, 87 insertions, 24 deletions
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index aad1a164ae..62c347ae0c 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -400,12 +400,10 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { // If Retro Shift is disabled, possible custom actions shouldn't happen. // clang-format off # if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) -# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) +# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY const bool is_hold_on_interrupt = get_hold_on_other_key_press(keycode, record); -# elif defined(IGNORE_MOD_TAP_INTERRUPT) - const bool is_hold_on_interrupt = false; # else - const bool is_hold_on_interrupt = IS_QK_MOD_TAP(keycode); + const bool is_hold_on_interrupt = false; # endif # endif if (IS_RETRO(keycode) @@ -443,12 +441,8 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { # endif ) { // Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set. -# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY) - if (autoshift_flags.in_progress -# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY - && get_hold_on_other_key_press(keycode, record) -# endif - ) { +# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY + if (autoshift_flags.in_progress && get_hold_on_other_key_press(keycode, record)) { autoshift_end(KC_NO, now, false, &autoshift_lastrecord); } # endif diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index 94302b29ae..d4382680bf 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -14,6 +14,54 @@ #include "process_caps_word.h" +#ifdef CAPS_WORD_INVERT_ON_SHIFT +static uint8_t held_mods = 0; + +static bool handle_shift(uint16_t keycode, keyrecord_t* record) { + switch (keycode) { + case OSM(MOD_LSFT): + keycode = KC_LSFT; + break; + case OSM(MOD_RSFT): + keycode = KC_RSFT; + break; + +# ifndef NO_ACTION_TAPPING + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + if (record->tap.count == 0) { // Mod-tap key is held. + switch (QK_MOD_TAP_GET_MODS(keycode)) { + case MOD_LSFT: + keycode = KC_LSFT; + break; + case MOD_RSFT: + keycode = KC_RSFT; + break; + } + } +# endif // NO_ACTION_TAPPING + } + + if (keycode == KC_LSFT || keycode == KC_RSFT) { + const uint8_t mod = MOD_BIT(keycode); + + if (is_caps_word_on()) { + if (record->event.pressed) { + held_mods |= mod; + } else { + held_mods &= ~mod; + } + return false; + } else if ((held_mods & mod) != 0) { + held_mods &= ~mod; + del_mods(mod); + return record->event.pressed; + } + } + + return true; +} +#endif // CAPS_WORD_INVERT_ON_SHIFT + bool process_caps_word(uint16_t keycode, keyrecord_t* record) { if (keycode == QK_CAPS_WORD_TOGGLE) { if (record->event.pressed) { @@ -21,6 +69,11 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { } return false; } +#ifdef CAPS_WORD_INVERT_ON_SHIFT + if (!handle_shift(keycode, record)) { + return false; + } +#endif // CAPS_WORD_INVERT_ON_SHIFT #ifndef NO_ACTION_ONESHOT const uint8_t mods = get_mods() | get_oneshot_mods(); @@ -95,6 +148,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: + case QK_TRI_LAYER_LOWER ... QK_TRI_LAYER_UPPER: // Ignore AltGr. case KC_RALT: case OSM(MOD_RALT): @@ -111,12 +165,14 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { if (record->tap.count == 0) { // Mod-tap key is held. const uint8_t mods = QK_MOD_TAP_GET_MODS(keycode); switch (mods) { +# ifndef CAPS_WORD_INVERT_ON_SHIFT case MOD_LSFT: keycode = KC_LSFT; break; case MOD_RSFT: keycode = KC_RSFT; break; +# endif // CAPS_WORD_INVERT_ON_SHIFT case MOD_RSFT | MOD_RALT: keycode = RSFT(KC_RALT); break; @@ -124,6 +180,9 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { return true; default: caps_word_off(); +# ifdef CAPS_WORD_INVERT_ON_SHIFT + add_mods(held_mods); +# endif // CAPS_WORD_INVERT_ON_SHIFT return true; } } else { @@ -163,12 +222,20 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { clear_weak_mods(); #endif // AUTO_SHIFT_ENABLE if (caps_word_press_user(keycode)) { +#ifdef CAPS_WORD_INVERT_ON_SHIFT + if (held_mods) { + set_weak_mods(get_weak_mods() ^ MOD_BIT(KC_LSFT)); + } +#endif // CAPS_WORD_INVERT_ON_SHIFT send_keyboard_report(); return true; } } caps_word_off(); +#ifdef CAPS_WORD_INVERT_ON_SHIFT + add_mods(held_mods); +#endif // CAPS_WORD_INVERT_ON_SHIFT return true; } diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 8597649c92..2670ccabed 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -14,6 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "keymap_common.h" #include "print.h" #include "process_combo.h" #include "action_tapping.h" @@ -144,7 +145,7 @@ static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH]; static inline void release_combo(uint16_t combo_index, combo_t *combo) { if (combo->keycode) { keyrecord_t record = { - .event = MAKE_KEYEVENT(KEYLOC_COMBO, KEYLOC_COMBO, false), + .event = MAKE_COMBOEVENT(false), .keycode = combo->keycode, }; #ifndef NO_ACTION_TAPPING @@ -232,7 +233,7 @@ static inline void dump_key_buffer(void) { process_record(record); #endif } - record->event.time = 0; + record->event.type = TICK_EVENT; #if defined(CAPS_WORD_ENABLE) && defined(AUTO_SHIFT_ENABLE) // Edge case: preserve the weak Left Shift mod if both Caps Word and @@ -332,8 +333,9 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { KEY_STATE_DOWN(state, key_index); if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) { // this in the end executes the combo when the key_buffer is dumped. - record->keycode = combo->keycode; - record->event.key = MAKE_KEYPOS(KEYLOC_COMBO, KEYLOC_COMBO); + record->keycode = combo->keycode; + record->event.type = COMBO_EVENT; + record->event.key = MAKE_KEYPOS(0, 0); qrecord->combo_index = combo_index; ACTIVATE_COMBO(combo); @@ -342,7 +344,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { } else { // key was part of the combo but not the last one, "disable" it // by making it a TICK event. - record->event.time = 0; + record->event.type = TICK_EVENT; } } drop_combo_from_buffer(combo_index); diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c index c2e7e7716f..bf6af566e2 100644 --- a/quantum/process_keycode/process_dynamic_macro.c +++ b/quantum/process_keycode/process_dynamic_macro.c @@ -29,7 +29,7 @@ void dynamic_macro_led_blink(void) { /* User hooks for Dynamic Macros */ -__attribute__((weak)) void dynamic_macro_record_start_user(void) { +__attribute__((weak)) void dynamic_macro_record_start_user(int8_t direction) { dynamic_macro_led_blink(); } @@ -62,10 +62,10 @@ __attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrec * @param[out] macro_pointer The new macro buffer iterator. * @param[in] macro_buffer The macro buffer used to initialize macro_pointer. */ -void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer) { +void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer, int8_t direction) { dprintln("dynamic macro recording: started"); - dynamic_macro_record_start_user(); + dynamic_macro_record_start_user(direction); clear_keyboard(); layer_clear(); @@ -213,11 +213,11 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) { if (!record->event.pressed) { switch (keycode) { case QK_DYNAMIC_MACRO_RECORD_START_1: - dynamic_macro_record_start(¯o_pointer, macro_buffer); + dynamic_macro_record_start(¯o_pointer, macro_buffer, +1); macro_id = 1; return false; case QK_DYNAMIC_MACRO_RECORD_START_2: - dynamic_macro_record_start(¯o_pointer, r_macro_buffer); + dynamic_macro_record_start(¯o_pointer, r_macro_buffer, -1); macro_id = 2; return false; case QK_DYNAMIC_MACRO_PLAY_1: diff --git a/quantum/process_keycode/process_dynamic_macro.h b/quantum/process_keycode/process_dynamic_macro.h index 39036541b8..ab70726897 100644 --- a/quantum/process_keycode/process_dynamic_macro.h +++ b/quantum/process_keycode/process_dynamic_macro.h @@ -35,7 +35,7 @@ void dynamic_macro_led_blink(void); bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record); -void dynamic_macro_record_start_user(void); +void dynamic_macro_record_start_user(int8_t direction); void dynamic_macro_play_user(int8_t direction); void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record); void dynamic_macro_record_end_user(int8_t direction); diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c index 8ba98bd4bb..d5ad61ba85 100644 --- a/quantum/process_keycode/process_steno.c +++ b/quantum/process_keycode/process_steno.c @@ -173,13 +173,13 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) { switch (keycode) { #ifdef STENO_ENABLE_ALL case QK_STENO_BOLT: - if (IS_PRESSED(record->event)) { + if (record->event.pressed) { steno_set_mode(STENO_MODE_BOLT); } return false; case QK_STENO_GEMINI: - if (IS_PRESSED(record->event)) { + if (record->event.pressed) { steno_set_mode(STENO_MODE_GEMINI); } return false; @@ -193,7 +193,7 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) { } #endif // STENO_COMBINEDMAP case STN__MIN ... STN__MAX: - if (IS_PRESSED(record->event)) { + if (record->event.pressed) { n_pressed_keys++; switch (mode) { #ifdef STENO_ENABLE_BOLT |