Support control keys in different keyboard layouts
As of the latest commit (09d94dc), a key press event contains the following information about what key is being pressed:
-
value: A representation of the physical button pressed; -
sym: The textual representation of the single pressed key, if it's printable.
On X11, which is what I tested, for keys that do not represent a printable character, such as Esc, the sym field will always contain 0. Therefore, the only way for an application to check for such a key is via its value (value == RGFW_escape). That, however, ignores the user's keyboard layout, which could have the physical key mapped to something else.
I, for instance, have Caps Lock and Esc swapped, so my physical Esc key performs the usual function of a Caps Lock, while the physical Caps Lock key is typically handled as an Esc by most applications (with the exception of games). Each key still produces it's original KeyCode, but XKB returns the correct (swapped) KeySym for each one.
One solution to this would be to expose the "KeySym" (what the key represents in a given layout in a given context) alongside the "KeyCode" (what physical key it is) for each key press, independently of the text it may represent.
I will add that I did all my tests on version 1.7.0, so sorry if something is outdated.
Thanks for putting the issue up here. I will look into it as soon as I can.
Fixing this would probably require a change to the API. So the fix will probably be reserved for 1.8.5, considering 1.8.0 has been in a pre-release stage and will not receive any updates to the user level API.
I think it would also be nice if the symbol information was obtainable on-demand with a dedicated function, instead of having it precomputed inside of the event struct, since games often don't care about them and would rather not call the necessary Xlib functions (or equivalent in other systems)
yeah, I was thinking the same thing.
I'm working on this issue in a 1.8.5 branch on the development fork, which will be pulled into main when 1.8.0 releases.