I’ve got a new laptop - MSI Delta 15 - and I’m trying to get all the keys on the keyboard to work so I can bind things to them. A handful of keys generate no keycodes (as shown with showkey -k). I got their scancodes from dmesg logging. I can bind them properly with setkeycodes, but it seems like the “proper” way to do this permanently is with udev. But when I set up /etc/udev/hwdb.d/60-keyboard.hwdb.db with my rules, I can’t get the codes to work.
I’ve done system-hwdb update, and udevadm trigger, and I’ve even rebooted. My first guess is that my pattern isn’t matching. BUT, if I run udevadm info keyboard-device, it lists out the rules that I think I added.
I’ve just dabbled a couple of times, still lots of holes in my knowledge. Making a prototype USB keyboard helped, it forced me to read a lot. Unfortunately the documentation is a bit sparse at times, and often out of date.
showkeys was working as advertised. Relying on dmesg output for scancodes turned out to be the problem evtest reported correct scancodes. The dmesg output was sort of correct. Or I should say related to reality: It seems that where dmesg was reporting e0NN, the real scancode reported by evtest was just NN+0x80.
Just a typo in this post; I had it right in real life.
The first line I had was matching fine.
I knew I could make that work, since “setkeycodes” worked (interesting that the values in dmesg worked in setkeycodes command but not in udev). But my interest, and the reason I considered udev the “right” way is so that I can contribute code to systemd hwdb such that other later MSI Delta 15 linux users (if any) will end up with a more correct keyboard configuration with no tinkering required.
Now I just have to figure out how to submit changes like that
Random note: I had lockscreen above but the proper linux name for that key should be screenlock.
I was also happy to see that (as I suspected) getting the proper linux codes in caused the Xorg events to show up properly, even though the translation between linux and Xorg keycodes remains a mystery, poorly described in all documentation I’ve seen.
Some of these keys are being used in ways that aren’t useful. e.g. the keyboard backlight for this keyboard does not respond properly whatever Manjaro is trying to do to toggle the keyboard backlight. Luckilly I found some code someone wrote to talk to the keyboard RGB. So I can come up with a janky solution now to use the keyboard illum key (previously not working) to run a program to do stuff. Unfortunately it isn’t a proper solution that wlll automatically benefit other users of the same laptop.