SDLKey wiki question

I read the following in the wiki:
For example, the SDLK_1 keysym can’t be accessed on a French keyboard.

How then do I check whether the ‘1’ is pressed with SDL?

I’m trying to make an in-game(game keeps running) commandline which should
only accept the ASCII keys,
but after reading the wiki I’m kind of discouraged .

Thanks, Lucas

Please tell me if this is not the appropriate place to ask these kind of
questions.

I must have read it wrong, but as I read it its impossible to check whether
the ‘1’ is pressed on a french keyboard.

(SDL 1.2)

I must have read it wrong, but as I read it its impossible to check whether
the ‘1’ is pressed on a french keyboard.

That’s correct with SDL 1.2, since technically there is no “1” key.

However, with SDL 1.3 we’re introduced the concept of scancodes which
represent layout independent key representation. You can check out a
sneak preview here:
http://www.libsdl.org/tmp/SDL-1.2.zip

You can build the checkkeys test program and try it ouf, if you like.

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

Thanks for your reply.

I’m trying to understand this, so please bear with me.

Howcome every programming language has a keyboard input function (like
scanf) but sdl can’t input keys ‘correctly’?
This is why I think I still don’t get it, sorry.

I don’t need to know which key is pressed, only what letter is pressed.

(I will suggest using 1.3 )>

I must have read it wrong, but as I read it its impossible to check
whether
the ‘1’ is pressed on a french keyboard.

That’s correct with SDL 1.2, since technically there is no “1” key.

However, with SDL 1.3 we’re introduced the concept of scancodes which
represent layout independent key representation. You can check out a
sneak preview here:
http://www.libsdl.org/tmp/SDL-1.2.zip

You can build the checkkeys test program and try it ouf, if you like.

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

Please tell me if this is not the appropriate place to ask these kind of
questions.

I must have read it wrong, but as I read it its impossible to check whether
the ‘1’ is pressed on a french keyboard.

(SDL 1.2)

Just catch the SDL_KEYUP (perhaps also SDL_KEYDOWN) events and read
event->key.keysym.unicode (or I think it’s event->key.keysym.char if you
have not enabled unicode).Am Donnerstag, den 14.02.2008, 11:23 +0100 schrieb Lucas:

I must have read it wrong, but as I read it its impossible to check
whether
the ‘1’ is pressed on a french keyboard.

That’s correct with SDL 1.2, since technically there is no “1” key.

Can’t he enable unicode and check the unicode-data?Am Donnerstag, den 14.02.2008, 03:31 -0800 schrieb Sam Lantinga:

Can’t he enable unicode and check the unicode-data?

With Unicode enabled you simply get the pressed key in Unicode?
Making it layout independent and easy to strip it to ASCII?
Are there any examples around?

Sorry for all the questions.

With Unicode enabled you simply get the pressed key in Unicode?
I meant ‘letter’ iso key :slight_smile:

Making it layout independent and easy to strip it to ASCII?
Unicode to ASCII should be easy.

Are there any examples around?
Using unicode.

Can’t he enable unicode and check the unicode-data?

He can, but on the French keyboard you have to press shift-& to get “1” :slight_smile:
http://www.forlang.wsu.edu/help/kfrench.gif

See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

So, it’s not just my custom “Swedish Dvorak Programmer” layout that
uses shift for numbers. :smiley:

(And yes, I have the same problems with applications that look for
SDLK_1, SDLK_2 etc.)

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Thursday 14 February 2008, Sam Lantinga wrote:

Can’t he enable unicode and check the unicode-data?

He can, but on the French keyboard you have to press shift-& to
get “1” :slight_smile:
http://www.forlang.wsu.edu/help/kfrench.gif

With Unicode enabled you simply get the pressed key in Unicode?
I meant ‘letter’ iso key :slight_smile:

Look at the manpage to SDL_keysym. This structure has a field unicode
where the letter is saved if you have activated Unicode-support.

You can activate it like this:
SDL_EnableUNICODE(1);

Now, if you press Shift+&, you get a keydown-event with
event->key.keysym.unicode == ‘1’.

Making it layout independent and easy to strip it to ASCII?
Unicode to ASCII should be easy.

Are there any examples around?
Using unicode.

What do you mean? This is probably not SDL related. In this unicode
field, there will be always the unicode number of the key. All special
keys will have a value >=128. It’s an Uint16.Am Donnerstag, den 14.02.2008, 15:12 +0100 schrieb Lucas:

Can’t he enable unicode and check the unicode-data?

He can, but on the French keyboard you have to press shift-& to get “1” :slight_smile:
http://www.forlang.wsu.edu/help/kfrench.gif

See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

And using a French keyboard and not enabling Unicode will not yield SDLK_1
when pressing shift-&?
Because if it would yield to SDLK_1 then I don’t need to enable Unicode as
its only natural to use the
keys like that for a French person for a console app.

And using a French keyboard and not enabling Unicode will not yield SDLK_1
when pressing shift-&?

I’m not sure, I don’t have a French keyboard to test with.

Have you tried with the checkkeys test program in SDL 1.3 PRERELEASE?
http://www.libsdl.org/tmp/SDL-1.3.zip

See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

And using a French keyboard and not enabling Unicode will not yield SDLK_1
when pressing shift-&?

This will trigger SDLK_LSHIFT, then SDLK_AMPERSAND.

I’m not sure, I don’t have a French keyboard to test with.

$ setxkbmap fr
:)–
Sylvain

Yeah, that should work, unless these keyboards actually send different
scan codes.

(The only keyboards I know of that do that are some special “no
configuration” Dvorak keyboards that do this to work around the fact
that some systems don’t have Dvorak keymaps.)

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Friday 15 February 2008, Sylvain Beucler wrote:

And using a French keyboard and not enabling Unicode will not
yield SDLK_1
when pressing shift-&?

This will trigger SDLK_LSHIFT, then SDLK_AMPERSAND.

I’m not sure, I don’t have a French keyboard to test with.

$ setxkbmap fr
:slight_smile:

Yes, I could precise that it works for US<->FR mapping, and for this
particular case (top 1-0 digits and letters). The behavior of weird
keys such as the ‘</>’ french key is a different story ;)On Sat, Feb 16, 2008 at 04:25:12AM +0100, David Olofson wrote:

On Friday 15 February 2008, Sylvain Beucler wrote:

And using a French keyboard and not enabling Unicode will not
yield SDLK_1
when pressing shift-&?

This will trigger SDLK_LSHIFT, then SDLK_AMPERSAND.

I’m not sure, I don’t have a French keyboard to test with.

$ setxkbmap fr
:slight_smile:

Yeah, that should work, unless these keyboards actually send different
scan codes.

(The only keyboards I know of that do that are some special “no
configuration” Dvorak keyboards that do this to work around the fact
that some systems don’t have Dvorak keymaps.)


Sylvain