aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorJohn <[email protected]>2025-02-16 03:50:42 -0600
committerGitHub <[email protected]>2025-02-16 20:50:42 +1100
commitb69bf4b885cd8d597c29f0af64a3faf2aafa54ce (patch)
tree311b18a488548551fe1003a9296972a4d0f1dafb /quantum
parent3ab2b3b6e2ac85c8bc00b81911d73f060e616228 (diff)
downloadqmk_firmware-b69bf4b885cd8d597c29f0af64a3faf2aafa54ce.tar.gz
qmk_firmware-b69bf4b885cd8d597c29f0af64a3faf2aafa54ce.zip
Retro Tapping Re-Write; Key Roll Fix (#23641)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/quantum/action.c b/quantum/action.c
index 395340d9d7..be85192d25 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -47,7 +47,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int tp_buttons;
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
-int retro_tapping_counter = 0;
+bool retro_tap_primed = false;
+uint16_t retro_tap_curr_key = 0;
+# if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
+uint8_t retro_tap_curr_mods = 0;
+uint8_t retro_tap_next_mods = 0;
+# endif
#endif
#if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
@@ -77,7 +82,13 @@ void action_exec(keyevent_t event) {
debug_event(event);
ac_dprintf("\n");
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
- retro_tapping_counter++;
+ uint16_t event_keycode = get_event_keycode(event, false);
+ if (event.pressed) {
+ retro_tap_primed = false;
+ retro_tap_curr_key = event_keycode;
+ } else if (retro_tap_curr_key == event_keycode) {
+ retro_tap_primed = true;
+ }
#endif
}
@@ -531,7 +542,8 @@ void process_action(keyrecord_t *record, action_t action) {
# if defined(RETRO_TAPPING) && defined(DUMMY_MOD_NEUTRALIZER_KEYCODE)
// Send a dummy keycode to neutralize flashing modifiers
// if the key was held and then released with no interruptions.
- if (retro_tapping_counter == 2) {
+ uint16_t ev_kc = get_event_keycode(event, false);
+ if (retro_tap_primed && retro_tap_curr_key == ev_kc) {
neutralize_flashing_modifiers(get_mods());
}
# endif
@@ -829,30 +841,44 @@ void process_action(keyrecord_t *record, action_t action) {
#ifndef NO_ACTION_TAPPING
# if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
- if (!is_tap_action(action)) {
- retro_tapping_counter = 0;
- } else {
+ if (is_tap_action(action)) {
if (event.pressed) {
if (tap_count > 0) {
- retro_tapping_counter = 0;
+ retro_tap_primed = false;
+ } else {
+# if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
+ retro_tap_curr_mods = retro_tap_next_mods;
+ retro_tap_next_mods = get_mods();
+# endif
}
} else {
+ uint16_t event_keycode = get_event_keycode(event, false);
+# if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
+ uint8_t curr_mods = get_mods();
+# endif
if (tap_count > 0) {
- retro_tapping_counter = 0;
- } else {
+ retro_tap_primed = false;
+ } else if (retro_tap_curr_key == event_keycode) {
if (
# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(get_event_keycode(record->event, false), record) &&
+ get_retro_tapping(event_keycode, record) &&
# endif
- retro_tapping_counter == 2) {
+ retro_tap_primed) {
# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
process_auto_shift(action.layer_tap.code, record);
# else
+ register_mods(retro_tap_curr_mods);
+ wait_ms(TAP_CODE_DELAY);
tap_code(action.layer_tap.code);
+ wait_ms(TAP_CODE_DELAY);
+ unregister_mods(retro_tap_curr_mods);
# endif
}
- retro_tapping_counter = 0;
+ retro_tap_primed = false;
}
+# if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
+ retro_tap_next_mods = curr_mods;
+# endif
}
}
# endif