Displaying keys pushed on european keyboards?

The “Change Keys” dialog in my game displays the keys a user chooses for walking and jumping. However, on international keyboards, if they push keys like ? and ?, it will display the U.S. keyboard symbols for that key instead of the european one. I’m wondering how to detect, under SDL, that a European keyboard was used, and determine which symbol (using my own pre-rendered bitmap font) to display for it?

The “Change Keys” dialog in my game displays the keys a user chooses for
walking and jumping. However, on international keyboards, if they push keys
like ? and ?, it will display the U.S. keyboard symbols for that key
instead of the european one. I’m wondering how to detect, under SDL, that a
European keyboard was used, and determine which symbol (using my own
pre-rendered bitmap font) to display for it?

Use SDL_keysym.unicode to get the proper value.
There is a bit more involved if you want to properly handle keys such as
control, alt, or space. Here is the functions we use for handling keyboard :

http://code.google.com/p/grafx2/source/browse/trunk/src/keyboard.c

And some documentation :
http://code.google.com/p/grafx2/source/browse/trunk/src/keyboard.hOn 2011-07-20 at 19:43:14 [+0200], VernJensen wrote:


Adrien.

Thanks!

UPDATE

So I wrote code to use the unicode value of the structure, and it turns out it’s always 0.

The SDL 1.3 code marks for this field in the headers (SDL_Keyboard.h):

/**< \deprecated use SDL_TextInputEvent instead */

However, SDL_TextInputEvent uses a char * for the input string, which would not be unicode either.

So I’m guessing there is no way to do this in SDL 1.3?

Unless it is UTF-8 encoded. What is being pointed to by it?On Thu, Jul 21, 2011 at 6:56 PM, VernJensen wrote:

**
UPDATE

So I wrote code to use the unicode value of the structure, and it turns out
it’s always 0.

The SDL 1.3 code marks for this field in the headers (SDL_Keyboard.h):

/**< \deprecated use SDL_TextInputEvent instead */

However, SDL_TextInputEvent uses a char * for the input string, which would
not be unicode either.

So I’m guessing there is no way to do this in SDL 1.3?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_TextInputEvent provides a UTF-8 sequence of text that was typed by the user, which as I understand it may consist of multiple characters (and multiple bytes per character), including accent
characters that modify the previous character.

This is sometimes called MultiByte text, each character may consist of 1-5 bytes of data, see the wikipedia page for an explanation:

When someone speaks of Unicode they are often referring to UTF-16, where each character may consist of 1 or 2 unsigned shorts (wchar_t):

The more or less canonical version of the Unicode system (where anything is a single unsigned int) is:

It is important to remember that text rendering can be rather ambiguous even in UTF-32 because of accent modifier sequences on a previous character.

I don’t know a lot about the details of Unicode text rendering, so I’m not much help beyond this basic information, my personal preference when programming is to use UTF-8, chiefly because it is
compatible with regular asprintf and friends (in the sense that high characters will pass through “safely”, one still must be careful with lengths).On 07/21/2011 06:33 PM, Patrick Baggett wrote:

Unless it is UTF-8 encoded. What is being pointed to by it?

On Thu, Jul 21, 2011 at 6:56 PM, VernJensen <vern at actionsoft.com <mailto:vern at actionsoft.com>> wrote:

__
**UPDATE**

So I wrote code to use the unicode value of the structure, and it turns out it's always 0.

The SDL 1.3 code marks for this field in the headers (SDL_Keyboard.h):

/**< \deprecated use SDL_TextInputEvent instead */

However, SDL_TextInputEvent uses a char * for the input string, which would *not* be unicode either.

So I'm guessing there is no way to do this in SDL 1.3?

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto: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


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier

char* can still hold unicode characters, since it is just a pointer to
8 byte chunks. UTF-8 characters could be held in 1 char each,
meanwhile UTF-16 in 2 chars each, etc.On Thu, Jul 21, 2011 at 10:09 PM, Forest Hale wrote:

SDL_TextInputEvent provides a UTF-8 sequence of text that was typed by the
user, which as I understand it may consist of multiple characters (and
multiple bytes per character), including accent characters that modify the
previous character.

This is sometimes called MultiByte text, each character may consist of 1-5
bytes of data, see the wikipedia page for an explanation:
http://en.wikipedia.org/wiki/UTF-8

When someone speaks of Unicode they are often referring to UTF-16, where
each character may consist of 1 or 2 unsigned shorts (wchar_t):
http://en.wikipedia.org/wiki/UTF-16

The more or less canonical version of the Unicode system (where anything is
a single unsigned int) is:
http://en.wikipedia.org/wiki/UTF-32

It is important to remember that text rendering can be rather ambiguous even
in UTF-32 because of accent modifier sequences on a previous character.

I don’t know a lot about the details of Unicode text rendering, so I’m not
much help beyond this basic information, my personal preference when
programming is to use UTF-8, chiefly because it is compatible with regular
asprintf and friends (in the sense that high characters will pass through
"safely", one still must be careful with lengths).

On 07/21/2011 06:33 PM, Patrick Baggett wrote:

Unless it is UTF-8 encoded. What is being pointed to by it?

On Thu, Jul 21, 2011 at 6:56 PM, VernJensen <vern at actionsoft.com <mailto:vern at actionsoft.com>> wrote:

? ?__
? ?UPDATE

? ?So I wrote code to use the unicode value of the structure, and it turns
out it’s always 0.

? ?The SDL 1.3 code marks for this field in the headers (SDL_Keyboard.h):

? ?/**< \deprecated use SDL_TextInputEvent instead */

? ?However, SDL_TextInputEvent uses a char * for the input string, which
would not be unicode either.

? ?So I’m guessing there is no way to do this in SDL 1.3?

? ?_______________________________________________
? ?SDL mailing list
? ?SDL at lists.libsdl.org <mailto: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


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged
demo." - James Klass
"A game is a series of interesting choices." - Sid Meier


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

While technically possible, such a use of char * would be in very poor taste, especially considering endianness concerns :slight_smile:

If it were a void * that would make some sense.

In any case the event generates UTF-8 text from my experience.On 07/21/2011 09:08 PM, Alex Barry wrote:

char* can still hold unicode characters, since it is just a pointer to
8 byte chunks. UTF-8 characters could be held in 1 char each,
meanwhile UTF-16 in 2 chars each, etc.

On Thu, Jul 21, 2011 at 10:09 PM, Forest Hale<@Forest_Hale> wrote:

SDL_TextInputEvent provides a UTF-8 sequence of text that was typed by the
user, which as I understand it may consist of multiple characters (and
multiple bytes per character), including accent characters that modify the
previous character.

This is sometimes called MultiByte text, each character may consist of 1-5
bytes of data, see the wikipedia page for an explanation:
http://en.wikipedia.org/wiki/UTF-8

When someone speaks of Unicode they are often referring to UTF-16, where
each character may consist of 1 or 2 unsigned shorts (wchar_t):
http://en.wikipedia.org/wiki/UTF-16

The more or less canonical version of the Unicode system (where anything is
a single unsigned int) is:
http://en.wikipedia.org/wiki/UTF-32

It is important to remember that text rendering can be rather ambiguous even
in UTF-32 because of accent modifier sequences on a previous character.

I don’t know a lot about the details of Unicode text rendering, so I’m not
much help beyond this basic information, my personal preference when
programming is to use UTF-8, chiefly because it is compatible with regular
asprintf and friends (in the sense that high characters will pass through
"safely", one still must be careful with lengths).

On 07/21/2011 06:33 PM, Patrick Baggett wrote:

Unless it is UTF-8 encoded. What is being pointed to by it?

On Thu, Jul 21, 2011 at 6:56 PM, VernJensen<vern at actionsoft.com <mailto:vern at actionsoft.com>> wrote:

__
**UPDATE**

So I wrote code to use the unicode value of the structure, and it turns

out it’s always 0.

The SDL 1.3 code marks for this field in the headers (SDL_Keyboard.h):

/**<  \deprecated use SDL_TextInputEvent instead */

However, SDL_TextInputEvent uses a char * for the input string, which

would not be unicode either.

So I'm guessing there is no way to do this in SDL 1.3?

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org<mailto: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


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged
demo." - James Klass
"A game is a series of interesting choices." - Sid Meier


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


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier