[SDL] OS independent SDL_keysym.scancode
Sebastian Biallas
sb at biallas.net
Tue Aug 17 14:14:24 PDT 2004
Hi!
I have a question concerning SDL_KeyEvent. I thought this is a fairly
frequently asked question, but I found nothing about this problem in
documentation.
Let's suppose I want to program a game where the keys that are covered
with the '[' and ']' characters on an american keyboard should have a
certain meaning. Now, I can either interpret the scancode field of
SDL_keysym struct, but this would make my program platform dependent (I
would have to "#ifdef __WIN32__" etc.). Or I can use the sym field,
which provide platform independent keys, but this makes my program
dependent on the selected "locale" of the user, i.e. a german user would
have to press AltGr+'8' or AltGr+'9' for the '[' and ']' keys
respectively. Of course the later option is completely useless if the
AltGr key had also a certain meaning.
The situation gets even worse when I want to assign meta-keys or dead
keys (e.g. on my current keyboard layout the spacebar is a modifier
key). Here I can only fallback to the scancode solution.
It's not that the keyssyms are really bad, they are ok for text
input-lines etc, where the user expects his current locale, but useless
for "raw" keyboard accesses.
So, am I missing something, or am I really forced to use the platform
dependent solution for such things at the moment?
Sebastian
More information about the SDL
mailing list