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

Add a key for replacing the top layer #942

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Conversation

xs5871
Copy link
Collaborator

@xs5871 xs5871 commented Feb 26, 2024

Reference: chat discussion

def _df_pressed(self, key, keyboard, *args, **kwargs):
'''
Switches the default layer
'''
self.activate_layer(keyboard, key.meta.layer, as_default=True)
self.activate_layer(keyboard, key.meta.layer, idx=-1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just really want to say I really like this!

Copy link
Member

@regicidalplutophage regicidalplutophage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ronsmits
Copy link

ronsmits commented Mar 3, 2024

so Using this change I expected that the base layer and the current layer are active, thet are not. It changes the default layer and it seems other layers are not active. Running it from thonny shows that indeed all other layers are deactivated:

200175719 kmk.keyboard: coordkeys_pressed={0: Key(code=1010, has_modifiers=None)}
200175725 kmk.modules.layers: active_layers=[1]
200175849 kmk.keyboard: <Event: key_number 0 released>: Key(code=1010, has_modifiers=None)
200175855 kmk.keyboard: coordkeys_pressed={}
200178848 kmk.keyboard: <Event: key_number 0 pressed>: Key(code=1011, has_modifiers=None)
200178854 kmk.keyboard: coordkeys_pressed={0: Key(code=1011, has_modifiers=None)}
200178860 kmk.modules.layers: active_layers=[2]
200178980 kmk.keyboard: <Event: key_number 0 released>: Key(code=1011, has_modifiers=None)
200178986 kmk.keyboard: coordkeys_pressed={}
200180793 kmk.keyboard: <Event: key_number 0 pressed>: Key(code=1012, has_modifiers=None)
200180797 kmk.keyboard: coordkeys_pressed={0: Key(code=1012, has_modifiers=None)}
200180803 kmk.modules.layers: active_layers=[0]
200180924 kmk.keyboard: <Event: key_number 0 released>: Key(code=1012, has_modifiers=None)
200180931 kmk.keyboard: coordkeys_pressed={}

@xs5871
Copy link
Collaborator Author

xs5871 commented Mar 3, 2024

KC.FD replaces the top most layer. If only the "base" layer (i.e. lowest layer) is active, then that layer is also the top layer -- in that case KC.DF(...) and KC.FD(...) have identical behavior. Btw just to clarify, there's no such thing as a default or current layer, those are colloquialisms; there's a list of active layers with key positions being resolved by layer order and key transparency.

I'm guessing you probably want to keep layer 0 as the lowest layer. If so, you want to add another layer on top first, and then switch out that top layer, then activating only layer 0 to complete the cycle. Example snippet for 1 base and 3 overlay layers:

keymap = [
[KC.TG(1)],
[KC.FD(2)],
[KC.FD(3)],
[KC.TO(0)],
]

@ronsmits
Copy link

ronsmits commented Mar 3, 2024

Thank you very much for explaining this, it works now :)

@xs5871 xs5871 merged commit 68914d1 into master Mar 7, 2024
3 checks passed
@xs5871 xs5871 deleted the feature-layer-replace-top branch March 7, 2024 09:32
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.

3 participants