[SDL] SDL 1.3 keyboard input on X11

Bob Pendleton bob at pendleton.com
Tue Dec 18 10:18:26 PST 2007

I have a little time right now and I'm trying to get X keyboard input
working on SDL 1.3. But, I am having a bit of a problem. The new SDL 1.3
way of doing keyboard input is to always pass an SDLK_* that represents
a real, physical, key on the keyboard. Personally I like that a lot
because it lets be be sure that if I get the SDLK_W key it is the same
physical key no matter what language is on the key caps. 

The trouble is that X11 keyboard input is designed to hide the physical
keycodes. Oh, it gives them to you, but they are not documented, they
can be different on every implementation of X11 and even different for
different kinds of keyboards attached to the same implementation. The
idea is that an application running on X can be running on any kind of a
device and you shouldn't have to worry about the kind of keyboard you
are using. X11 hides all that and just gives the application a "virtual"
keyboard that uses standard "keysyms".

This was a great idea back in the early 1980s when everyone was building
their own unique keyboards. Now days, it kind of sucks.... Not to
mention that it makes translating from X11 keycodes to SDLK_* a very
dicey proposition.

Now that I have explained the problem I am going to ask for some help. I
have been digging around in the xfree86 and X.org source code and it
looks like they both use the same keycodes on all versions of Linux, and
maybe on all versions of the server. I do not know for sure if this is
true. If it is, then we can handle a large number of systems very

So, if you know more than I do about what these servers are doing, then
please let me know and tell me where to look in the source and docs.

OTOH, if you are using X11 with a non US-English keyboard, please run
xmodmap -pk and send the out to me at bob at pendleton.com

	Thank You,

		Bob Pendleton

+ Bob Pendleton: writer and programmer +
+ email: Bob at Pendleton.com             +
+ web: www.GameProgrammer.com          +
+ www.Wise2Food.com                    +
+ nutrient info on 7,000+ common foods +

More information about the SDL mailing list