On Sat, Dec 04, 2021 at 08:34:49AM +0000, adlo wrote: > Basically the program I’m working on was originally designed for X11, and I’m > trying to adapt it to Wayland. I’m trying to find an equivalent to > XKeysymToKeycode(). > > > it doesn't, but if you look at xkbcli how-to-type and it's source > > (tools/how-to-type.c) that's the closest approximation. > > What does this program do? Does it iterate through all possible keycodes and > lookup the keysym for them?
please look at the source, it's not a huge program. > > > > Main reason is that the keycode->keysym conversion is one-way only and it's > > not 100% reliable to go back. e.g. if a modifier is locked/latched you > > cannot > > access certain keysyms without unlocking that modifier, etc. > > How would I deal with capital letters with regards to getting a keycode from > a keysym? there's no such thing as a capital letter with keycodes, keycodes are really just "this physical key has been pressed". so capital letters usually resolve to a sequence - shift down, keycode, shift up. That is where the difficult bits start. > > > KEY_TAB is defined in linux/input-event-codes.h. XKB uses those keycodes + 8 > > for the evdev ruleset (see /usr/share/X11/xkb/keycodes/evdev for the > > mapping) > > and it goes from there. If you're using a different ruleset you're going to > > get interesting results but evdev is effectively hardcoded everywhere > > anyway, > > so you won't. > > Is linux/input-event-codes.h keycodes or keysyms? keycodes, but they have semantic naming for easier association. Cheers, Peter