rvaiya / keyd

A key remapping daemon for linux.
MIT License
2.72k stars 157 forks source link

Questions: numpad remapping and numlock state #790

Open Jahfry opened 2 months ago

Jahfry commented 2 months ago

I'm working up a guide for getting 'keyd' to run on a Steam Deck as a World of Warcraft macro pad in both Desktop and Game mode and have a few questions.

To further explain, for game macro pad usage I am using the NumLock as one of the macro keys (not really sending a macro at this point, just remapping it to send a different key so that it can be bound in the game). So I want the number keys with alternate functions when numlock isn't ON to still just always send the kp# code ... regardless of numlock LED state on the numpad.


  1. Is there a way to force 'numlock' to always be toggled on? Even if reconnecting a USB numpad during a session.

    • I know in Plasma settings I can force the numpad to work like MacOS where keys always send numeric values (instead of things like "home" and "arrow left/right/etc"). But for the Steam Deck this only works in Desktop mode. When using Game mode the Plasma settings aren't loaded so the numpad defaults to sending "kp home" when 7 is pressed (same for other dual function keys)
    • I would prefer to simply tell keyd 'numlock state is always on' as it makes the layer configuration simple, can stick to only using [main] instead of multiple layers
    • I had this working in the past using 'kmonad' but 'keyd' suits this use case much better for working seamlessly in Game mode

  1. Can I remap numpad # keys in their unlocked state?

I could avoid the problem in "1." above (wanting to force numlock ON) if I knew what to remap in 'keyd' to say "when numlock is off and '7 / home' is pressed, send 'kp7'".

Examples:

Jahfry commented 2 months ago

I have a working but somewhat kludgy solution worked out.

details here in case anyone finds this from a search looking for similar.

I would like to improve the solution if there's something I can do based on the questions at top.

rvaiya commented 1 month ago
  1. Is there a way to force 'numlock' to always be toggled on? Even if reconnecting a USB numpad during a session.

[...]

I could avoid the problem in "1." above (wanting to force numlock ON) if I knew what to remap in 'keyd' to say "when numlock is off and '7 / home' is pressed, send 'kp7'".

Numlock is implemented at the display server level. When you press the numlock key, numlock is emitted and the display server flips a bit of state which is used to decide how to interpret the raw kp1, kp2, etc keycodes.

Since keyd operates at the level of the keycode, what you want to achieve should be as simple as remapping the numlock codes to their corresponding numbers:

[main]

kp1 = 1
kp2 = 2
kp3 = 3
kp4 = 4
kp5 = 5
kp6 = 6
kp7 = 7
kp8 = 8
kp9 = 9