-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat: Allow layer behaviors to "lock" layers on #2717
base: main
Are you sure you want to change the base?
Conversation
8845219
to
5bf75a6
Compare
5bf75a6
to
7082133
Compare
If you want to get the state of a conditionally activated Can you lock on a |
I realised that tracking that is unnecessary for this to work as expected. Rather, if both This also has the effect of allowing the |
I will rewind a bit: I have this momentariness tracking feature which is being used to filter layer change events that aren't "permanent". I am hoping to replace the tracking of momentariness by checking the "locked" state of the highest active layer instead. For that to work:
|
7082133
to
db4659f
Compare
I've added what I believe are the necessary parts to get that to work with the locking system. |
657c765
to
317f4a7
Compare
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.
While I haven't tested, implementation looks good to me. I left some clean up remarks and some suggestions to think about. While I like the new default behavior of &tog
and &to
, also worth considering that it will technically constitute a breaking change (alongside the API break in keymap.h
).
Also need to update https://zmk.dev/docs/config/behaviors to add the new property.
int zmk_keymap_layer_activate(zmk_keymap_layer_id_t layer, bool locking); | ||
int zmk_keymap_layer_deactivate(zmk_keymap_layer_id_t layer, bool locking); | ||
int zmk_keymap_layer_toggle(zmk_keymap_layer_id_t layer, bool locking); | ||
int zmk_keymap_layer_to(zmk_keymap_layer_id_t layer, bool locking); |
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.
It might be worth thinking about adding single param variants as compatibility shims.
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.
Thought about this for a bit. While it could be done, of the modules that I know of (aka those in the collection) the only one that is affected is auto-layer, which already has code in it to track momentariness. I think it should be ok to break API here, though @urob maybe can chime in?
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.
Thanks for letting me know. Agree, breaking the API here shouldn't be a big issue for auto-layer
. (I adapted the upstream versioning for the module releases. So as long as users keep them in sync, there shouldn't be any compatibility issues).
As an aside, it would be great if breaking API changes like this one could be flagged in the release notes, ideally detailing how the API changed. Otherwise it could get tricky to figure out why things break given how many commits the next ZMK release is going to have.
3e55050
to
1f890c6
Compare
Just realised that this makes #1984 obsolete. |
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
Adds a
locking
property to momentary, to, and toggle layer behaviors. Enabled by default for&to
and&tog
, a layer being "locked" prevents behaviors without thelocking
property from deactivating the layer.Conditional layer activation and deactivation is always non-locking, which seems to interact nicely.Common use case: with this PR you can place e.g. a
&tog 1
or a&to 1
on layer 1, allowing you to "lock" it in place while it is active.PR check-list