Skip to content

Generate keycodes/evdev from libevdev

I've been thinking about this after a Fedora bug filed for a new keycode not being handled correctly.

The various keycodes in keycodes/evdev simply match the kernel defines + offset 8. Every time we want a new keycode to actually do something, we add them to keycodes/evdev and the new symbol to symbols/inet or wherever. That's of course after having to update xproto, but that's a different issue.

At least for keycodes, there is no need to maintain these manually, we can just generate them and update them when necessary. This means the various <I123> codes are readily available for the user keymaps without having to modify multiple files, a simple symbols entry is enough.

This MR adds a new tool to geerate the keycodes/evdev file from a template, and compare it against an existing one (it relies on markers put into the file though). Where it finds previously unassigned keycodes (new #defines added to the middle somewhere) it'll fail the test. Where the highest keycode is higher than the current one in keycodes/evdev, it'll fail. Otherwise it succeeds or skips the test.

The actual updating is still a manual action, but it's a matter of cp builddir/evdev.keycodes keycodes/evdev && git commit -m 'Updated evdev keycodes'. It's primarily a manual action because it's not often necessary and because the key names are compiled into libevdev, so unless you build libevdev against the most recent kernel headers, you may get false updates.

I've hooked this up via meson for now, but arguably this should just be in .gitlab-ci/<custom> to be executed as specific CI job.

Anyway - I'll take suggestions or other comments :)

cc @bluetech, @svu

Edited by Peter Hutterer

Merge request reports