Requires:
- linux based OS with systemd
- terminal knowledge
- the evtest program
I will be using arch linux but the links above should apply if you are on a different system. Most of what I will be doing here is as root (the sudo command) you can drop down into the root shell using sudo su -
The first step is to get the device "hardware match" string. The arch wiki had a really confusing way of doing this, so I came up with a more straight forward method. When I run the evtest command from the terminal, I get the following:
Code: Select all
# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Power Button
/dev/input/event1: Power Button
/dev/input/event2: SteelSeries SteelSeries Rival 110 Gaming Mouse
/dev/input/event3: winkeyless.kr ps2avrGB
/dev/input/event4: winkeyless.kr ps2avrGB System Control
/dev/input/event5: winkeyless.kr ps2avrGB Consumer Control
/dev/input/event6: PC Speaker
/dev/input/event7: HDA NVidia HDMI/DP,pcm=3
/dev/input/event8: HDA NVidia HDMI/DP,pcm=7
/dev/input/event9: HDA NVidia HDMI/DP,pcm=8
/dev/input/event10: HDA NVidia HDMI/DP,pcm=9
/dev/input/event11: HDA NVidia HDMI/DP,pcm=10
/dev/input/event12: HDA NVidia HDMI/DP,pcm=11
/dev/input/event13: HDA NVidia HDMI/DP,pcm=12
/dev/input/event14: HD-Audio Generic Front Mic
/dev/input/event15: HD-Audio Generic Rear Mic
/dev/input/event16: HD-Audio Generic Line
/dev/input/event17: HD-Audio Generic Line Out
/dev/input/event18: HD-Audio Generic Front Headphone
/dev/input/event19: SINO WEALTH Gaming KB
/dev/input/event20: SINO WEALTH Gaming KB System Control
/dev/input/event21: SINO WEALTH Gaming KB Consumer Control
/dev/input/event22: SINO WEALTH Gaming KB Keyboard
Select the device event number [0-22]:
Once you figure out what device you want to remap, you take the number that you used to monitor it (in my case 19) and type the following command to get the hardware match string for you keyboard
Code: Select all
cat /sys/class/input/event19/device/modalias
Code: Select all
# cat /sys/class/input/event19/device/modalias
input:b0003v258Ap002Ae0111-e0,1,4,11,14,k71,72,73,74,75,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8C,8E,96,98,9E,9F,A1,A3,A4,A5,A6,AD,B0,B1,B2,B3,B4,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,3,4,sfw
Code: Select all
input:b0003v258Ap002A*
Code: Select all
evdev:input:b0003v258Ap002A*
- indent the directives using a single space
- key reassignment syntax is KEYBOARD_KEY_<scancode>=<keycode> scancode comes from evtest, keycode is the name of a keycode as lowercase from the /usr/include/linux/input-event-codes.h file.
- /etc/udev/hwdb.d/70-keyboard.hwdb file ownership should be under user and group root and with -rw-r--r-- permissions. Double check using the ls -l command.
- removing a remap from the file will not remove the mapping for the key. You need to change the keycode back to what it was originally, then update, then you can remove the directive.
Code: Select all
evdev:input:b0003v258Ap002A*
#capslock -> left control
KEYBOARD_KEY_70039=key_leftctrl
#pause -> numlock
KEYBOARD_KEY_70048=key_numlock
#A -> B
KEYBOARD_KEY_70004=key_b
Code: Select all
Event: time 1592170729.749901, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1592170729.749901, type 1 (EV_KEY), code 30 (KEY_A), value 1
Event: time 1592170729.749901, -------------- SYN_REPORT ------------
aEvent: time 1592170729.852908, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1592170729.852908, type 1 (EV_KEY), code 30 (KEY_A), value 0
Event: time 1592170729.852908, -------------- SYN_REPORT ------------
Once you have finished editing your file run the following command:
Code: Select all
systemd-hwdb update ; udevadm trigger --verbose --sysname-match='event19'
Code: Select all
udevadm info /dev/input/by-path/*-usb-*-kbd | grep -i keyboard_key
Code: Select all
# udevadm info /dev/input/by-path/*-usb-*-kbd | grep -i keyboard_key
E: KEYBOARD_KEY_70004=key_b
E: KEYBOARD_KEY_70039=key_leftctrl
E: KEYBOARD_KEY_70048=key_numlock
Hope this helps anyone else that had issues understanding / getting udev remapping to work, its pretty useful and a nice feature. If anyone isn't able to get it working feel free to post below, I'll try and help you figure out what could be going wrong.