[Bug][Core] Fix for Chordal Hold: stuck mods when mod-taps are pressed in a stuttered sequence. #24878
+88
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I discovered an input sequence where Chordal Hold (#24560) leaves a mod in a stuck state.
Description
Repro example: Suppose keys
LSFT_T(KC_A)
andLCTL_T(KC_B)
are on the same hand, and the following input is made:LSFT_T(KC_A)
downLCTL_T(KC_B)
downLSFT_T(KC_A)
upLSFT_T(KC_A)
downLCTL_T(KC_B)
upLSFT_T(KC_A)
upwhere steps 3-5 are done quickly, within the tapping term. Then even after all keys are released, the Shift mod is stuck. The bug happens similarly with layer-tap keys or a mix of a mod-tap and a layer-tap key.
Fix: Handling goes wrong on step 5 of the example above, in the code
waiting_buffer_chordal_hold_taps_until()
. This function marks buffered events as tapped. The problem is that this inappropriately marks theLSFT_T(KC_A)
-up event from step 4 as tapped, mismatching that the key was considered held on step 1. I realized that in this function it only makes sense to mark buffered press events as tapped. The fix amounts to adding an "if (record->event.pressed)
."To verify, I've added a "two_mod_taps_keys_stuttered_press" unit test simulating the repro example. This test fails before this PR and is fixed after.
Types of Changes
Checklist