Skip to content
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

Various fixes and improvements to latching behavior #569

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Jules-Bertholet
Copy link

@Jules-Bertholet Jules-Bertholet commented Dec 21, 2024

Any new lock breaks all existing latches

For example, if Caps_Lock is on the second level of some key, and Shift is latched, pressing the key will enable Caps while also breaking the Shift latch, ensuring that the next character is properly uppercase. (Prior to this commit, both Shift and Caps would be active, so the next character would be lowercase.) (Setting a lock via latchToLock or clearing it via clearLocks also breaks all latches.)

New latches break existing latches for non-preserved modifiers in the modifier list of the type of the key that triggered the new latch

For example, if a new latch is triggered by pressing a key of type ALPHABETIC, existing Shift and Lock latches will now be broken, but other latches will be preserved as before.

This ensures the correct behavior when combining sticky keys with ISO_Level5_Latch or latched-group additional symbols layers.

The rules for what does and does not break a latch are also applied before the latch is formed

Notably, pressing two latching keys simultaneously now applies both latches. For example, if I set up sticky keys, and then press Shift and AltGr together, both modifiers now end up latched.


An alternative to #51 that resolves its motivating issue without incurring the problems discussed in the comments there.

@Jules-Bertholet Jules-Bertholet changed the title Make any lock break all latches, and group latches break mod latches Make all locks break all latches, and group latches break mod latches Dec 21, 2024
@Jules-Bertholet Jules-Bertholet marked this pull request as draft December 21, 2024 19:45
@Jules-Bertholet Jules-Bertholet changed the title Make all locks break all latches, and group latches break mod latches Make new locks break all latches, and new latches break some latches Dec 21, 2024
@Jules-Bertholet Jules-Bertholet marked this pull request as ready for review December 21, 2024 21:31
@Jules-Bertholet Jules-Bertholet force-pushed the locks-break-latches branch 4 times, most recently from 03ef230 to cf08189 Compare December 21, 2024 21:38
@Jules-Bertholet Jules-Bertholet changed the title Make new locks break all latches, and new latches break some latches Various fixes and improvements to latching behavior Dec 22, 2024
@wismill wismill marked this pull request as draft January 6, 2025 16:03
@Jules-Bertholet Jules-Bertholet force-pushed the locks-break-latches branch 2 times, most recently from f6923f9 to 6670fe3 Compare January 6, 2025 23:15
@Jules-Bertholet Jules-Bertholet marked this pull request as ready for review January 6, 2025 23:18
@Jules-Bertholet Jules-Bertholet marked this pull request as draft January 7, 2025 15:20
@Jules-Bertholet
Copy link
Author

Jules-Bertholet commented Jan 7, 2025

Sorry for the noise. Every time I think this is ready, I sleep on it and then notice a new edge case…

I have been using this locally for several weeks now, and it makes the latching experience much more pleasant.

The intuition is that each sequence of latches builds up to some lasting effect intended by the user. That effect can either be a change in the application state, or a long-term change in the keyboard state. Once the effect has been achieved, the latches used to accomplish it have served their purpose are no longer desired.

Setting or releasing a lock is one such lasting effect, therefore changes in the lock state should always break all latches.

A user may also latch a modifier only to enable the latching of a different one. In such cases, the first latch has served its purpose as soon as the second one is formed. The “non-preserved modifiers” rule disambiguates between this case and the case where both latches are meant to be active simultaneously. Users can control the behavior precisely by means of preserve.

One change this PR does not make is that new latches continue to not break existing group latches. Because there is no equivalent of preserve for groups, users would have no way to configure this behavior, so I judged it best to preserve compatibility.

@Jules-Bertholet Jules-Bertholet marked this pull request as ready for review January 7, 2025 18:17
For example, if `Caps_Lock` is on the second level of some key,
and `Shift` is latched, pressing the key will lock `Caps`
while also breaking the `Shift` latch, ensuring that the next character
is properly uppercase. (Prior to this commit, both `Shift` and
`Caps` would be active, so the next character would be lowercase.)

Signed-off-by: Jules Bertholet <[email protected]>
Changed latching behavior so that latching a modifier or group now breaks existing modifier latches,
but only if the type of the key responsible for the latter latch
has the modifier of the pre-existing latch in its modifiers list.

For example, if a new latch is triggered by pressing a key of type `ALPHABETIC`,
existing `Shift` and `Lock` latches will now be broken, but other latches
will be preserved as before.

This ensures the correct behavior when combining sticky keys with
`ISO_Level5_Latch` or latched-group additional symbols layers.

Signed-off-by: Jules Bertholet <[email protected]>
Prior to this commit, "latch A down" → "latch B down" →
"latch A up" → "latch B up" would result in only B being latched.
After this commit, both A and B end up latched.

Signed-off-by: Jules Bertholet <[email protected]>
@Jules-Bertholet
Copy link
Author

Jules-Bertholet commented Jan 14, 2025

Rebased. Also squashed a few commits, hopefully making it easier to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant