Having a concept of a key position is actually more relevant in a game than
key label. If I want to use the number bar, I don’t care if the 3 key is
labeled 3 or ", what I’m interested in is the physical position of the key
as that position is meaningful in terms of gameplay. Same goes for WASD.
Having to remap the keys, usually right after the introduction cinematic,
make the game look unprofessional, and it breaks the player’s immersion at
the very beginning of the game.
If you see it that way, scancodes may be broken on some platforms, but most
gameplays are broken on non US keyboards when using keycodes.
There are some solutions to avoid that. The first is to have SDL give us a
portable way to query the keyboard layout. Then we would adapt the default
configuration to that.
Another would be to ask the user either when downloading the game or when
the game starts for the first time. But I believe it’s wrong to rely on the
user.
As for weird keyboards, not much we can do about that, we game developers
have to manually plan for each of those we wish to support manually anyways.
The best solution in my mind would be to remap the weird platforms to a
standard set of scancodes (solaris/sparc, and more). That way the behaviour
described by patrick would be an SDL bug. That way have some overhead
though. But even if it’s not fully portable, please keep the scancodes. My
target platforms are Windows/Linux/Mac, so if it works for those, I’ll take
it !
2011/3/11 Patrick Baggett <baggett.patrick at gmail.com>> I’ve found scancodes to be a terrible idea. I had code that worked on Win32
system, reasonably worked on Linux/x86 systems, and went to hell when I ran
it on Solaris/SPARC. Turns out just translating the windowing system
messages into a platform independent message was the best way. While it is
unfortunate that WASD doesn’t always translate depending on keymap, a real
game would allow the user to remap the controls anyways and this would be
done once and problem solved.
Patrick
On Fri, Mar 11, 2011 at 1:26 PM, Sam Lantinga wrote:
In SDL 1.3 I introduced the concept of a scancode, which is keyboard
mapping independent.
e.g. WASD with scancodes will always be in an inverted T, while it might
be remapped to different positions using keycodes on a French keyboard or
Dvorak layout.
Unfortunately as you might imagine the scancodes are hardware dependent
and so things are broken on unusual keyboards.
Is anybody using this distinction between scancodes and keycodes in SDL
1.3? Or is it preferrable to go back to just using keycodes the way SDL 1.2
works?
See ya!
-Sam Lantinga, Founder and CEO, Galaxy Gameworks
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org