[SDL] Problems with keymapping on AZERTY keyboards on Mac OS X

Gerry JJ trick at icculus.org
Thu Jul 5 08:30:39 PDT 2007


Den Wed, 27 Jun 2007 16:15:42 -0700
skrev Sam Lantinga <slouken at devolution.com>:
> SDL 1.3 formalizes the meaning of the keysyms:  SDL_blah is the key
> with the text "blah" printed on it based on the current keyboard
> layout. Pressing that key may or may not give you a text input event
> with "blah", depending on modifiers, composition state, etc.

Is there any way to get positional key information in SDL 1.3?  This is
something I've been missing in SDL 1.2.  Positional input can be a
nightmare without this, with either having to ship a gazillion
keymaps and having the user select one, or making people define
their own keymaps.  (While the ability to redefine input in a game is
a good thing, making its use required is not so good, specially if
there's many keys).

> This allows you to say "Press the blah key to fire" and it's actually
> the blah key, not where the blah key would be on a US QWERTY
> keyboard. :)

Perhaps I'm misunderstanding here, but I think this is false (or, at
least, not always true). Take the SDL_EQUALS keysym, for example.  On an
US qwerty keyboard, '=' is available with one single keypress, but on eg
mine, I have to press shift+0 to get it.  If a game tells me to press
'=' to fire, what should I do?  Press shift+0, or just 0?  SDLK_0 is a
different keysym?

I think a better way to do this kind of thing would be to get the label
of a key through some function:

	printf("Press the %s key to fire", SDL_GetKeyLabel(SDL_blah));

I can see arguments for both positional and labeled keysyms.  In an
RPG, having the 'I' key bring up the inventory makes sense (at least
in english), but in an FPS, the labels of the qwerty WASD keys doesn't
really matter, it's the (relative) position of the keys that's
important. Ideally there should be a way to do both of these.

> Most games do provide localized keyboard layout, or alternate layout
> schemes to account for some uncommon layouts.

This is difficult when you have to redefine most of the keyboard, eg to
get original native layout in an emulator, or in a game that uses
most of the keyboard (like most flight simulators seems to do).

- Gerry


More information about the SDL mailing list