[SDL] My thoughts on keyboard input in SDL 1.3

Rainer Deyke rainerd at eldwood.com
Fri Jan 25 22:40:36 PST 2008


Bob Pendleton wrote:
> Please do. I would love to see a function that takes an SDLK_* and a
> locale name as arguments and returns the correct name for each key. I
> would love to be able to write SDL_GetI18nKeyName(SDKK_ENTER, "zh"); and
> get back the utf8 for the Chinese character(s) for "enter". But, I don't
> personally want to try to track that all down. If you do, please do and
> submit the function for inclusion in SDL 1.3.

Actually, I'm pretty sure it is not possible in the general case to 
obtain the printed symbol on a key from just a key code and a locale 
name.  For example:

   - Some US keyboards have an 'enter' key, while on other US keyboards 
the same key is labeled 'return'.
   - The meta key on my keyboard is usually called the Windows key, and 
contains a symbol that is (presumably) not a valid unicode character. 
When I use my Mac Mini, the same key suddenly functions as the command 
key, even though it is in the same locale.  It still has the Windows 
icon printed on it though.
   - In general, the logical keyboard layout, the physical keyboard 
layout, and the active locale can be quite different.  I run Windows 
with the location set to US but the language for non-Unicode programs 
(which is often interpreted as the locale) set to Japanese.  I switch 
between US keyboard layouts (English and International) and Japanese IME 
as needed.  My physical keyboard is a US keyboard.

That said, the easiest way to implement SDL_GetI18nKeyName would 
probably to start out with a dummy function that only handles the US 
locale and request translations from the community.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the SDL mailing list