DPF
DPF copied to clipboard
Add keycodes support
This is an initial attempt at adding keycodes support to DPF.
These allow to deal with keyboard keys in a layout-independent manner. It's particularly useful for piano-style widgets, to map keyboard keys to piano notes in the correct order.
This code is based on https://github.com/depp/keycode, especially the <os>_tohid.c
files and keycode.h
in the src
directory.
Tested with the piano widget on Linux, MacOS and Windows, with a couple of different layouts (Colemak, AZERTY, QWERTY).
The keycodes would be wrong when running the UI in Wine, but they would work fine on a real Windows 10 machine. I'm not sure if this is normal.
Perhaps it would be good to test this feature a little more before merging.
Looks good, but a few things to do:
- rename COPYING into COPYING.keycode
- make the keycode arrays static
- make KEYCODE_EVDEV_OFFSET static too, and check if opcode < KEYCODE_EVDEV_OFFSET before doing the -= operation (x11 code)
there are a little oddities regarding spaces vs tabs, but I can fix them later myself
also, exposing the keycode API would be nice yes :)
OK, I've made the changes.