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 .
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
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:
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?
With Unicode enabled you simply get the pressed key in Unicode?
I meant ‘letter’ iso key
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:
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.
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
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
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.)