But for this emulator I need to transform all (O.K. the most) keys to the
keys of the emulatetd system. This is also necessary for the german umlauts or
special french keys…
That is a problem. Unfortunately the keys that don’t have explicit SDLK_
constants have no fixed value (they may vary between drivers).
When I understand right there are undocumented definitions for speciel keys
in SDL_keysym.h. I will later have a look on this. Maybe it works with this,
but are this undocumented definitions supported in future sdl versions too?
What undocumented definitions are you talking about?
But isn’t there a way to do this host to emulator keybinding over the
unicode field in the SDL_keysym structure? I think all keys (characters) of the
european languages must be defined there (In the lowest 256 Byte?).
Please distinguish keys from characters. Unicode, ASCII and ISO-8859-n
are character encodings, but they are not very useful for encoding keys.
Maybe I use hardware dependent scancode in the SDL_keysym structure. Are
this hardware dependent scancodes for all Linux drivers (X, framebuffer, …)
the same? Are this scancodes the X scancodes?
No, they are not (necessarily) the same. For instance, the X11 driver uses
X keycodes for “scancode”, and these depend on keyboard hardware and X server.
One solution for this mess would be to give each possible key a different
keysym number (like X11 keysyms), with a different SDLK_ define for each.
Then we add API functions to map between scancodes and keysyms, and use
scancodes in SDL keyboard events. This gives us a compact and nice
set of scancodes for internal use, and a wide range of keysyms.
So, instead of writing
if(event->keysym == SDLK_aleph) infinite_lives_cheat();
you would do
SDL_keycode kc_aleph = SDL_KeysymToKeycode(SDLK_aleph);
...
if(event->keycode == kc_aleph) infinite_lives_cheat();
This way, you can in your emulator find the presence of each key when
you start, like this:
SDL_keycode key = SDL_KeysymToKeycode(SDLK_OE_ligature);
if(!key)
error("You heartless machine, you won't be able to type coeur!\n");
else
my_keycodes[OE_LIGATURE] = key;
etc. I think this is what we will have to do in SDL 1.3.