I'm trying to remap LCtrl and CapsLock on my Microsoft Wired Keyboard 600 with HWDB but for whatever reason the system does not see the changes that I make.
This is how my hwdb
rule looks like:
evdev:input:b*v045Ep07F8*
KEYBOARD_KEY_3a=leftctrl
KEYBOARD_KEY_1d=capslock
The vendor and the model codes come from lsusb
and were reconfirmed in /sys/devices/pci0000:00/*
After copying the config file to /etc/udev/hwdb.d
, running systemd-hwdb update
and issuing udevadm trigger
no changes in the keyboard config are present.
I've also tried:
- Rebooting — didn't help.
- Specifying the bus explicitly as
0003
— didn't help. - Confirming with
evtest
that the key codes I'm using are correct for my keyboard — yep, those are the correct keycodes. - Confirming the applied rules are listed in
sudo udevadm info /sys/class/input/eventX
— yes, the new rules are listed, which should mean they were applied successfully? Yet the keys behave the same way they did before.
E: KEYBOARD_KEY_1d=capslock
E: KEYBOARD_KEY_3a=leftctrl
E: ID_USB_DRIVER=usbhid
When I use evdev:atkbd:dmi:*
as the device identifier instead the change is correctly applied to my laptop keyboard so I know the rule and the process I'm using to remap the keys should be correct, it's got to be an issue with the wrong identifier (though I've quintuple checked it).
Any help will be appreciated.
Turns out I was specifying the wrong kind of scancodes. When getting key codes with
evtest
, you get the following output (assuming the left shift button is pressed):The code I was using was the standard key code (42). But as it turns out, this is wrong.
The actual code you're supposed to specify in the hwdb file is the scancode from the
MSC_SCAN
line (in this example, it is700e1
, preceded by the wordvalue
)This works:
Reference: Rebinding Keyboard Keys @ altlinux.org (it's in Russian but it is the most comprehensive article I've found on the web that stresses that nuance)
I vividly remember using basic scancodes on my laptops and them working. I'm not quite sure why that is the case. Perhaps they happen to match the
EV_MSC
scancodes on some types of keyboards.