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

Enable 2 layers at the same time? #78

Closed
DidierLoiseau opened this issue Jan 9, 2016 · 6 comments
Closed

Enable 2 layers at the same time? #78

DidierLoiseau opened this issue Jan 9, 2016 · 6 comments

Comments

@DidierLoiseau
Copy link
Contributor

I am currently designing a layout in which layer 2 should be the same as layer 1 + some keys.

Layer 2 is designed to be a momentary layer, while layer 1 would be a toggle layer.

To avoid duplicating layer 1 in layer 2, I would like to configure a key that momentarily toggles both layers 1 & 2.

Should I implement it as a macro or is there a simpler way?

@DidierLoiseau
Copy link
Contributor Author

I implemented it as a macro and it was quite simple in the end. In action_get_macro():

switch(id) {
    case 2:
        layer_state ^= (1 << LAYERA) | (1 << LAYERB);
        break;
}

and use it with M(2) in the layout.

I don't check whether it is a key pressed or released since I need to toggle the layer states in both cases.

Anyway I would still be interested to know if there is an alternative without macro.

@ezuk
Copy link
Contributor

ezuk commented Jan 10, 2016

I think there's something I don't understand here. If layer 2 is designed to be mostly the same as layer 1, why not make the keys in layer 2 transparent? I mean, those that should stay the same. Doesn't that work?

@DidierLoiseau
Copy link
Contributor Author

That's indeed what I did, see https://github.com/DidierLoiseau/qmk_firmware/blob/typematrix/keyboard/ergodox_ez/keymaps/keymap_typematrix.c

The thing is that enabling layer 2 does not automatically enable layer 1. I thus needed a way to enable both layers at the same time.

@jackhumbert
Copy link
Member

This is a pretty cool implementation! That's the only way I know to do something like this - I can't really see it becoming a core feature right now because of keymap readability concerns.

@DidierLoiseau
Copy link
Contributor Author

Ok, thanks. I'm happy to know that's the proper way to implement it and that I didn't miss something.

I don't think this needs to be a core feature either, but it could be useful to document it somewhere.

@DidierLoiseau
Copy link
Contributor Author

Playing with layer_state directly appears to be a bad idea in the end. I quite often end up with keys stuck from the temporary layers.

In fact, it appears I should have used layer_invert() instead, which does the proper cleanup if some keys are still held while switching a layer off. This appears to also be the cause of my problem in #81.

DidierLoiseau added a commit to DidierLoiseau/qmk_firmware that referenced this issue Feb 7, 2016
- fixes stuck keys from the temporary layers
  (see also qmk#78)
- removed the workaround for qmk#81
  (using layer_invert() fixes the problem)
lucashecht pushed a commit to lucashecht/qmk_firmware that referenced this issue Mar 10, 2016
- fixes stuck keys from the temporary layers
  (see also qmk/qmk_firmware#78)
- removed the workaround for qmk/qmk_firmware#81
  (using layer_invert() fixes the problem)
matthewdias pushed a commit to matthewdias/qmk_firmware that referenced this issue Nov 13, 2021
lowlevl pushed a commit to lowlevl/qmk_firmware that referenced this issue Jan 15, 2023
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

No branches or pull requests

3 participants