sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.8k stars 156 forks source link

Support for keyboard layers #91

Open matt-vdv opened 3 years ago

matt-vdv commented 3 years ago

Firstly, thanks for the great software!

I think it would be great if you could set up one key (say, right alt) that would toggle between two different keyboard layers. So, you would press the key to go to the second layer, where you could have a numberpad, for example for people without one, then press the same key again to return to normal QWERTY mappings.

sezanzeb commented 3 years ago

Thanks.

I think this is a duplicate of https://github.com/sezanzeb/key-mapper/issues/72, or at least it can be solved like that if implemented.

If you would like to propose a different solution, feel free to reopen this

sezanzeb commented 3 years ago

lets keep the layers discussion here https://github.com/sezanzeb/key-mapper/issues/72#issuecomment-818501992

what do you think is a good way to configure such a feature in the gui?

matt-vdv commented 3 years ago

Here are some simple mock-ups I quickly made (sorry for the poor GIMP usage, not really used it before): key-mapper-mockup1 key-mapper-mockup2

Basically, when the layers selector is set to Main layer, the key map alteration would behave like normal. If the layer selector was set to Secondary layer, you could then set up a mapping for something like w to up arrow. These keybindings wouldn't come into affect until the Layer toggle key was pressed, maybe there would be an option somewhere for this to be a toggle or momentary?

Not sure if this is the best idea, just the first thing that came into my head...

sezanzeb commented 3 years ago

nice, well done!

And while a certain layer is active, other keys that are not specific for that layer (i.e. not mapped in that layer again) remain at their previous mapping? Otherwise it would be exactly like a key to switch presets. And when switching back from a layer A to the "Main Layer" mappings from A would be disabled, until A is enabled again.


I'm a bit afraid of adding features to the gui that make it look more complex though. An easy to implement solution that I just thought of might be via macros that can set variables.

A: toggle(1)
B: on(1, k(a), k(b))

writes "a" if 1 is active, otherwise b.

It certainly is harder to discover via macros, but that system provides the easiest way to add features for sure, while the gui remains as simple as possible.

or

A: set(foo, 1)
B: ifeq(foo, 1, k(a), k(b))

which one do you like more? I guess the second one with ifeq would potentially add lots of flexibility in the future. I think I'm gonna do set and ifeq. And I might need to add a popup with more space to write macros.

matt-vdv commented 3 years ago

Yeah the second one seems good! As for the GUI, you could maybe have the layers feature disabled by default (i.e the GUI would look the same as at the moment) then the layers toggle would only appear if the user enabled the feature, maybe in an advanced settings tab in the about dialog?

Having the key bindings from the main layer still used if no alternative seems a good idea, especially if it actually makes it feasible to implement!

sezanzeb commented 3 years ago

not very fun to configure, but it can work now

Does that work for you?

A toggle button could work with if_eq($layer, 1, set(layer, 2), set(layer, 1))