philipl / evdevremapkeys

Daemon to remap events on linux input devices
MIT License
134 stars 42 forks source link

suppress additional scancodes #22

Open kolAflash opened 4 years ago

kolAflash commented 4 years ago

Originally posted here: https://github.com/philipl/evdevremapkeys/issues/4#issuecomment-639738690  

@pronobis @philipl This is very much what I need! So I'd really like to see the changes from @pronobis merged. https://github.com/philipl/evdevremapkeys/issues/4

I quickly hacked a way to handle N:N mappings: https://github.com/pronobis/evdevremapkeys

 

Just one thing is left for me: I need to handle keys which emit a unique scancode, plus additional scancodes which overlap with other keys.

I took some time to extend the changes made by @pronobis to fit my needs. Feel free to have a look at it and give me feedback: https://github.com/kolAflash/evdevremapkeys/commits/master  

Background:

I got some strange keys on my HP EliteBook 735 G6 notebook. They emit multiple keycodes at the same time (less than 10 milliseconds):

LEFTCTRL + LEFTALT + F13
LEFTCTRL + LEFTALT + F14
LEFTCTRL + LEFTMETA + F15
LEFTCTRL + LEFTALT + F16

 

I remapped those keys to HOME, END, PAGEUP and PAGEDOWN.

    (KEY_LEFTALT, KEY_LEFTCTRL, KEY_F13):
      - KEY_HOME
    (KEY_LEFTALT, KEY_LEFTCTRL, KEY_F14):
      - KEY_END
    (KEY_LEFTALT, KEY_LEFTMETA, KEY_F15):
      - KEY_PAGEUP
    (KEY_LEFTALT, KEY_LEFTCTRL, KEY_F16):
      - KEY_PAGEDOWN

This works perfect, except I actually want to press LEFTCTRL + HOME. Sadly there's seems to be no indicator if the "real" LEFTCTRL has been pressed or not.

 


 

P.S. Only take the following into account if you want all details. It's mostly confusing and shouldn't be helpful to consider.

The third keycode is actually an unknown keycode. But I use /etc/udev/hwdb.d/90-custom-keyboard.hwdb to remap it to a known key.

evdev:atkbd:dmi:bvn*:bvr*:bd*:svn*:pn*:pvr*
 KEYBOARD_KEY_64=f13
 KEYBOARD_KEY_65=f16
 KEYBOARD_KEY_66=f15
 KEYBOARD_KEY_6d=f14

Side note: Find some related stuff here. https://h30434.www3.hp.com/t5/Business-Notebooks/remap-special-keys-with-Linux-presentation-start-call-end/td-p/7610721 https://h30434.www3.hp.com/t5/Business-Notebooks/left-CTRL-key-gets-logically-virtually-stuck-sometimes-Alt/m-p/7639737#M159561

DanielJoyce commented 3 years ago

This is gonna be kinda messy because whenever it sees LEFTCTRL pressed, it will have to delay emitting it until sees if the next code matches, this will delay emitting the LEFTCTRL until it knows known of the others have been pressed. That could be a long time. You'd need to add a timeout.