Skip to content

Commit

Permalink
Retro Tapping Re-Write; Key Roll Fix (#23641)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRigoni authored Feb 16, 2025
1 parent 3ab2b3b commit b69bf4b
Show file tree
Hide file tree
Showing 2 changed files with 446 additions and 12 deletions.
50 changes: 38 additions & 12 deletions quantum/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit b69bf4b

Please sign in to comment.