Skip to content

Commit

Permalink
Do not leak weak mods from tap dance to the interrupting keypress (qm…
Browse files Browse the repository at this point in the history
…k#12471)

Tap dance callbacks may register weak mods; one case when it happens
is when a tap dance registers a key with modifiers.  When the tap
dance is interrupted by pressing another key, these weak mods could
affect the interrupting key (normally any stale weak mods are cleared
at the start of action_exec() when handling a keypress event, but the
tap dance interrupt check code is called later, and the weak mods left
by that code were not cleared).  Add another clear_weak_mods() call to
preprocess_tap_dance() to make sure that the interrupting keypress is
not affected by unrelated weak mods from the previous tap dance.

Fixes qmk#12445.
  • Loading branch information
sigprof committed Apr 25, 2021
1 parent d3bf3d3 commit da6e888
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions quantum/process_keycode/process_tap_dance.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action);
reset_tap_dance(&action->state);

// Tap dance actions can leave some weak mods active (e.g., if the tap dance is mapped to a keycode with
// modifiers), but these weak mods should not affect the keypress which interrupted the tap dance.
clear_weak_mods();
}
}
}
Expand Down

0 comments on commit da6e888

Please sign in to comment.