-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(behaviors): Make multiple sticky keys work on same key position #2758
base: main
Are you sure you want to change the base?
fix(behaviors): Make multiple sticky keys work on same key position #2758
Conversation
All LGTM, don't think docs changes or copyright stuff is missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@urob thanks for the issue pointers, I had a vague memory of issues with macros but I never thought to search for existing issues! |
Interestingly Okke attempted to solve the issue in #670 by implementing a general trace ID. That might be a more robust solution in general, but this implementation is more self-contained and seems robust enough to me. |
8b8f6ff
to
9501d0b
Compare
Thank you so much @caksoylar! I did some manual testing of this change here to verify it and can confirm it's all working as I would expect. Here are my test notes: Action is the action I took on the keyboard. Result is the key input received by the OS. Key layout is here: https://my.glove80.com/#/layout/user/2a9bbbdb-ca3d-4bab-b0cd-214c59581ae0 Run 1: Before Patch (24.02)Current BehaviorResult: Test 1: Sticky shift -> &sl layer switch -> sticky command (on same key but different layer) -> letter key (on base layer)
Result: 😞 command+h is triggered because the sticky shift is ended when the sticky command is triggered, even though they're on different layers. Test 2: Macro that sets sticky shift then switches to a sticky layer
Result: 😞 lowercase j is outputted instead of an uppercase one due to the sticky layer in the macro ending the sticky shift when triggered Test 3: Macro that sets sticky shift then sticky alt then switches to a sticky layer (layer 2)
Result: 😞 lowercase m (which exists only on layer 2) is typed and the modifiers have no effect because they end when the sticky layer is triggered Run 2: After PatchUpdated BehaviorTest 1: Sticky shift -> &sl layer switch -> sticky command (on same key but different layer) -> letter key (on base layer)
Result: ✅ both sticky modifiers become active and then resolve when the "h" key is pressed, just like they would if they were on different physical keys. Test 2: Macro that sets sticky shift then switches to a sticky layer
Result: ✅ capital J is typed Test 3: Macro that sets sticky shift then sticky alt then switches to a sticky layer
Result: ✅ shift+alt+j shortcut is triggered, just like it would be each sticky modifier and the j key were on different physical keys. Existing FunctionalityTest 4: Sticky shift then a letter
Result: ✅ Test 5: Sticky shift then sticky shift (same key)
Result: ✅ Test 6: Sticky shift then sticky gui (different keys)
Result: ✅ |
Sticky keys have logic implemented so that if you press the same sticky key a second time, it releases the first press before activating a sticky key press again. However, multiple sticky keys are only disambiguated by key position, which means that you currently cannot have active multiple sticky keys that are triggered from the same key position. This scenario occurs under a couple conditions:
&sk LCTRL
), then activate a different sticky key e.g. (&sk LSHIFT
) on a different layer but at the same key positionbindings = <&sk LSHIFT>, <&sl 1>;
)Using only the key position is usually enough to disambiguate multiple active instances of a behavior; for instance for hold-taps, you cannot press the same key position again while one hold-tap is active at that position. However this doesn't apply to sticky keys since they stay active after you release the key that activates them.
In order to support above scenarios, add three tests covering them and modify the implementation to use behavior binding (e.g.
&kp
vs.&mo
) and parameter (e.g.LCTRL
vs.LSHIFT
) in addition to key position to disambiguate between active sticky keys.Also remove the redundant
param2
storage in sticky keys since they only accept one binding cell, can drop this refactor commit if it is unnecessary.Fixes #508 and #1421.
PR check-list