I'm creating an on-screen keyboard for Linux integrated in a simple Window Manager. I'm currently using XCB, and now I want to make the fake keystrokes. Everything works fine using xtest extension, except for the detail that I can't get the true keycodes from the keysyms I want to put.
Currently I'm using xcb_key_symbols_get_keycode, and then I use xcb_key_symbols_get_keysym to know which modifier I need to get that symbol. This works fine when the configured keyboard is the USA one. But I have a spanish keyboard, and this call only returns the USA configurations. In spanish keyboards several symbols are obtained with the right alt (altgr), but the former calls doesn't seem to support it.
So, how can I get the keycodes needed to get any keysym? I presume that I need the XKB extensions, but I've been unable to find them for XCB, and I don't want to rewrite the whole window manager for XLib.
Thanks.
It's probably an outdated issue, but I find it still valid.
You can enable xkb extensions via xcb and then get the keymap, it's layout and the appropriate keysym for that layout via the xcb API (or more specifically from the xkb keymap's state).
Links:
xcb_x11calls). (with the device id you can callxkb_x11_keymap_new_from_deviceto return axkb_keymappointer).xkb_state_key_get_sym()) here you can use the xkb_state to get the sym for the corresponding key.I have to admit, that I did not actually do this in full, yet (only up to the keymap/layout/state thing). But it should be enough to get you started. :)