[SDL] My thoughts on keyboard input in SDL 1.3
Bob Pendleton
bob at pendleton.com
Tue Jan 22 10:54:05 PST 2008
On Sun, 2008-01-20 at 11:03 -0800, Sam Lantinga wrote:
> > > The current API has a function that seems to solve the problem of key
> > > transposition on European keyboards but that does not address the
> > > problem of using a Greek or Chinese keyboard.
>
> > Can you elaborate on this? As far as I can tell, it handles Greek just fine
>
> Yes, the idea is just mapping the position dependent key into the layout
> defined key, using Unicode where possible. e.g. mapping from the q positional
> key to 'a' on french keyboards. This works just fine with greek keyboards,
> since it would map to the appropriate unicode codepoint. Symbols which don't
> have a unicode equivalent, like keypad enter and so forth, would have an SDL
> defined symbol that is outside the current Unicode space.
>
> Most of the asian keyboards have the standard US layout printed on the keys
> and enter a special input mode for entering asian characters. In this case
> the positional key codes would be the USB defined set, the layout codes would
> be the US keyboard codes, and asian characters would arrive as text input
> events via the IME.
Ok, I have been through the code and the documentation and what you
describe appears to be what is implemented. But, until I reread your
last paragraph above for the third or fourth time I did not "get" (and I
may still not get) what you just said. I still do not see how to get the
Greek or Farsi key symbol from a key code?
How does this work for the Chinese programmer? If he wants to do WASD
input he uses SDLK_W and so on. Now, he wants to use a specific Chinese
keycap symbol in his code for the equivalent of 'Z' for zoom. He can
either use the US keyboard names, or he can force his users to go
through the IME to enter the Chinese character.
Is that a correct interpretation of what SDL_GetLayoutkey and
SDL_Getkeyname are supposed to do?
-----------------------------------------------------
What follows is what I thought it was supposed to do:
-----------------------------------------------------
The key press/release event returns a positional SDLK_*
The text input events returns the composed character(s) from IMEs and
from normal shift keys and so on.
I thought SDL_GetLayoutkey() just handled key position swaps, that is it
handled cases where z and y and a and q were swapped around on European
keyboards. That was wrong.
I thought SDL_Getkeyname() was supposed to return the actual Unicode for
the locale dependent key cap on the key. This also was wrong. As I
understand it SDL_Getkeyname() never returns the actual key symbol for
languages like Chinese, Greek, and Farsi. Is that correct?
As I currently understand it, and I do not claim that I do, there is no
way to get the actual symbol on the key board on a key press by key
press basis. Is that correct?
----------------------------
It seems to me that what we have here is a case where my preconceived
ideas are so different from y'alls that we are not communicating much at
all. I'm trying to work that out.
----------------------------
I am quite happy with the current plans for key press events and for
text input events. They let me get text in a reasonable way and they let
me get positional key codes which is something I really like. I like
adding bits to identify different keys types.
I would like to have a function called something like SDL_GetKeysymbol()
that takes the SDLK_* from a key event and returns either the Unicode
code point for the Key Symbol on the key or the SDLK_* for the key. If
the key does *not* have a Unicode code point then it returns the SDLK_*
otherwise it returns the Unicode code point. On a Greek keyboard it
would return a Greek Unicode code point, on a Farsi keyboard it would
return the Farsi Unicode codepoint. The SDLK_* would have a high order
bit set to distinguish them from the Unicode code points. The existing
SDL_PHYSICAL_KEY does that just fine.
Bob Pendleton
>
> > > There is also a function
> > > to get the key cap, but the current implementation and the architecture
> > > (in my possibly very wrong opinion) assume that code will be added to
> > > SDL to address each different type of keyboard.
>
> > I'm not sure what you're talking about here.
>
> Me neither, can you elaborate?
>
> See ya!
> -Sam Lantinga, Lead Software Engineer, Blizzard Entertainment
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
--
+--------------------------------------+
+ 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