diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index 99b0ca3c8a3c..7e79ff405756 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -145,7 +145,7 @@ Do not Auto Shift alpha characters, which include A through Z. ### Auto Shift Per Key -There are functions that allows you to determine which keys shold be autoshifted, much like the tap-hold keys. +There are functions that allows you to determine which keys should be autoshifted, much like the tap-hold keys. The first of these, used to simply add a key to Auto Shift, is `get_custom_auto_shifted_key`: @@ -166,15 +166,13 @@ For more granular control, there is `get_auto_shifted_key`. The default function bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { switch (keycode) { # ifndef NO_AUTO_SHIFT_ALPHA - case KC_A ... KC_Z: + case AUTO_SHIFT_ALPHA: # endif # ifndef NO_AUTO_SHIFT_NUMERIC - case KC_1 ... KC_0: + case AUTO_SHIFT_NUMERIC: # endif # ifndef NO_AUTO_SHIFT_SPECIAL - case KC_TAB: - case KC_MINUS ... KC_SLASH: - case KC_NONUS_BACKSLASH: + case AUTO_SHIFT_SPECIAL: # endif return true; } @@ -271,10 +269,16 @@ generating taps on release. For example: #define RETRO_SHIFT 500 ``` +Without a value set, holds of any length without an interrupting key will produce the shifted value. + This value (if set) must be greater than one's `TAPPING_TERM`, as the key press must be designated as a 'hold' by `process_tapping` before we send the modifier. +[Per-key tapping terms](tap_hold.md#tapping-term) can be used as a workaround. There is no such limitation in regards to `AUTO_SHIFT_TIMEOUT` for normal keys. +**Note:** Tap Holds must be added to Auto Shift, see [here.](feature_auto_shift.md#auto-shift-per-key) +`IS_RETRO` may be helpful if one wants all Tap Holds retro shifted. + ### Retro Shift and Tap Hold Configurations Tap Hold Configurations work a little differently when using Retro Shift. diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index 3c8b5678b794..208c71bcbd21 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c @@ -135,19 +135,21 @@ bool process_tapping(keyrecord_t *keyp) { if (WITHIN_TAPPING_TERM(event) # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) || ( + get_auto_shifted_key(tapping_keycode, keyp) && # ifdef RETRO_TAPPING_PER_KEY get_retro_tapping(tapping_keycode, &tapping_key) && # endif - (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0) + // extends TAPPING_TERM: + // indefinitely if RETRO_SHIFT does not have a value (+0 is to compile successfully) + // to RETRO_SHIFT if it is set + // for possibly retro shifted keys + ((RETRO_SHIFT + 0) == 0 || TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0)) ) # endif ) { // clang-format on if (tapping_key.tap.count == 0) { if (IS_TAPPING_RECORD(keyp) && !event.pressed) { -# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) - retroshift_swap_times(); -# endif // first tap! debug("Tapping: First tap(0->1).\n"); tapping_key.tap.count = 1; @@ -180,6 +182,7 @@ bool process_tapping(keyrecord_t *keyp) { // unnecessarily and fixes them for Layer Taps. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) || ( + get_auto_shifted_key(tapping_keycode, keyp) && # ifdef RETRO_TAPPING_PER_KEY get_retro_tapping(tapping_keycode, &tapping_key) && # endif @@ -306,6 +309,9 @@ bool process_tapping(keyrecord_t *keyp) { } else { if (!IS_NOEVENT(event)) { debug("Tapping: key event while last tap(>0).\n"); +# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) + retroshift_swap_times(); +# endif } process_record(keyp); return true; @@ -363,10 +369,15 @@ bool process_tapping(keyrecord_t *keyp) { if (WITHIN_TAPPING_TERM(event) # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) || ( + get_auto_shifted_key(tapping_keycode, keyp) && # ifdef RETRO_TAPPING_PER_KEY get_retro_tapping(tapping_keycode, &tapping_key) && # endif - (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0) + // extends TAPPING_TERM: + // indefinitely if RETRO_SHIFT does not have a value (+0 is to compile successfully) + // to RETRO_SHIFT if it is set + // for possibly retro shifted keys + ((RETRO_SHIFT + 0) == 0 || TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0)) ) # endif ) { diff --git a/quantum/action_tapping.h b/quantum/action_tapping.h index 9b64c9312004..976eef79f046 100644 --- a/quantum/action_tapping.h +++ b/quantum/action_tapping.h @@ -30,6 +30,9 @@ along with this program. If not, see . #define WAITING_BUFFER_SIZE 8 #ifndef NO_ACTION_TAPPING +# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY +bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record); +# endif uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache); uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); void action_tapping_process(keyrecord_t record); diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index e6a7c01f2ae3..606b1b47807e 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -66,7 +66,7 @@ __attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyreco return false; } -/** \brief Called on physical press, returns whether is Auto Shift key */ +/** \brief Called on physical press, returns whether key is an Auto Shift key */ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { switch (keycode) { # ifndef NO_AUTO_SHIFT_ALPHA @@ -165,9 +165,8 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record) } // Store record to be sent to user functions if there's no release record then. - autoshift_lastrecord = *record; - autoshift_lastrecord.event.pressed = false; - autoshift_lastrecord.event.time = 0; + autoshift_lastrecord = *record; + autoshift_lastrecord.event.time = 0; // clang-format off # if defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY) if (keycode == autoshift_lastkey && @@ -489,10 +488,8 @@ void retroshift_poll_time(keyevent_t *event) { } // Used to swap the times of Retro Shifted key and Auto Shift key that interrupted it. void retroshift_swap_times() { - if (last_retroshift_time != 0 && autoshift_flags.in_progress) { - uint16_t temp = retroshift_time; - retroshift_time = last_retroshift_time; - last_retroshift_time = temp; + if (autoshift_flags.in_progress) { + autoshift_time = last_retroshift_time; } } # endif diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h index ac6a143746e6..2a2e69630e31 100644 --- a/quantum/process_keycode/process_auto_shift.h +++ b/quantum/process_keycode/process_auto_shift.h @@ -49,4 +49,5 @@ uint16_t (get_autoshift_timeout)(uint16_t keycode, keyrecord_t *record); void set_autoshift_timeout(uint16_t timeout); void autoshift_matrix_scan(void); bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record); +bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record); // clang-format on