Keyboard azerty vs qwerty

Hi all,

Excuse my ignorance, but I’m compiling for first time my game under win32
platform and I have some troubles with keyboard handling event…

Let’s see this piece of code :

switch (event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym){ case SDLK_z: printf("z pressed !\n"); break; default: printf(" !(z pressed)"); break; }

Under GNU/Linux, with my azerty maped keyboard, it’s perfect… when I press
’z’ key, program prints ‘z pressed’…
But under win32, on the same machine (and azerty maped keyboard too !),
SDLK_z is generated when ‘w’ is pressed , like on a qwerty keyboard…

So, is there any reason for this happening, or am I just stupid :frowning: ?

Tia
CU–
Pascal “Toweld” Bourut
toweld at rocketmail.com
http://toweld.free.fr/towbowltactics/
Up The Irons !!!

Assuming you can type azerty normally in any win32 app, I think its windows just being stupid. Tho, specifcally, what windows are you running? 9x/me or nt4/w2k/xp?On 28-Nov-2001, Pascal Bourut wrote:

Hi all,

Excuse my ignorance, but I’m compiling for first time my game under win32
platform and I have some troubles with keyboard handling event…

Let’s see this piece of code :

switch (event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym){ case SDLK_z: printf("z pressed !\n"); break; default: printf(" !(z pressed)"); break; }

Under GNU/Linux, with my azerty maped keyboard, it’s perfect… when I press
’z’ key, program prints ‘z pressed’…
But under win32, on the same machine (and azerty maped keyboard too !),
SDLK_z is generated when ‘w’ is pressed , like on a qwerty keyboard…

So, is there any reason for this happening, or am I just stupid :frowning: ?

Tia
CU


Pascal “Toweld” Bourut
toweld at rocketmail.com
http://toweld.free.fr/towbowltactics/
Up The Irons !!!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Patrick “Diablo-D3” McFarland || unknown at panax.com

“Patrick McFarland” a ?crit dans le message news:
mailman.1006906747.13128.sdl at libsdl.org

Assuming you can type azerty normally in any win32 app, I think its
windows just being stupid.
Yes, for sure:-)

Tho, specifcally, what windows are you running? 9x/me or nt4/w2k/xp?
I’m running win98…

I dont think win98 correctly maps keyboards for some apps, even with the keyboard locale set rightOn 28-Nov-2001, Pascal Bourut wrote:

“Patrick McFarland” a ?crit dans le message news:
mailman.1006906747.13128.sdl at libsdl.org

Assuming you can type azerty normally in any win32 app, I think its
windows just being stupid.
Yes, for sure:-)

Tho, specifcally, what windows are you running? 9x/me or nt4/w2k/xp?
I’m running win98…


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Patrick “Diablo-D3” McFarland || unknown at panax.com

“Pascal Bourut” <pascal.bourut at wanadoo.fr> wrote:

But under win32, on the same machine (and azerty maped keyboard too !),
SDLK_z is generated when ‘w’ is pressed , like on a qwerty keyboard…

this is probably a bug in SDL. Any win32 programmers around to fix it?

oops, and I am just asking here about native keyboard layout… (but I still
don’t see my post)
Is that mean, that SDLKey fully support native keyboards under Linux?On Wed, Nov 28, 2001 at 12:46:59AM -0000, Pascal Bourut wrote:

Under GNU/Linux, with my azerty maped keyboard, it’s perfect… when I press
’z’ key, program prints ‘z pressed’…


I love the night So many shadows
Unholy light
Secrets of the heart Leave 'em in the dark "Lord of the Last Day"
Forever - Ronnie James Dio

“Pascal Bourut” <pascal.bourut at wanadoo.fr> wrote:

But under win32, on the same machine (and azerty maped keyboard too !),
SDLK_z is generated when ‘w’ is pressed , like on a qwerty keyboard…

this is probably a bug in SDL. Any win32 programmers around to fix it?

It’s not a bug in SDL. It’s what I’ve been saying for ages… that’s
what DirectX is returning as the key code. You can’t rely on the VK
keysyms reflecting the keyboard layout because they’re just great big
gamepad button identifiers. It’s only when they’re translated into
character codes that they start to have meaningful ascii values and
will match the actual keyboard layout.

Max hacked the MacOS code to do a partial keyboard translation on each
key so we know what it should be, but really MacOS has the same problem.
The only environment that maps the scancodes to virtual keys while
respecting the keyboard layout is X11. And, Mattias, you’re in cushy
land there… :slight_smile:

It’s a real problem, and I’m not sure how to solve it at this point.

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

Sam Lantinga wrote:

It’s not a bug in SDL. It’s what I’ve been saying for ages…

It’s a bug in SDL. It’s what I’ve been saying for ages… :slight_smile:

You can’t rely on the VK
keysyms reflecting the keyboard layout because they’re just great big
gamepad button identifiers. It’s only when they’re translated into
character codes that they start to have meaningful ascii values and
will match the actual keyboard layout.

this should work: (by “keysym” here I mean the actual key identified by
what’s printed on the keycaps)

if key is “special” (control, return, shift, keypad, etc):
There is a known mapping between VK and keysym — use it

otherwise,
if key generates an ascii/unicode character when pressed without modifiers:
Use that generated char code to map to the appropriate keysym

otherwise,
it’s probably a dead key (ToUnicodeEx() returns -1):
This is a bit tricky — ToUnicodeEx() mentions that it might return
a spacing version of the dead-key char anyway, so then we can use that.
Another solution would be to examine the key name string.

A similar approach might work on other platforms as well (it’s basically
what Max did for OS X)

Not only do people have quite different logical keyboard layouts, it’s
becoming increasingly more common with different physical layouts
(think all kinds of ergonomic keyboards, handhelds, etc)

It’s a real problem, and I’m not sure how to solve it at this point.

I’ve just received mail from one of other ARAnyM emulator
(http://aranym.atari.org) developer. We were speaking about this problem
too.

regards

STan

------------ Cut -----------

The only environment that maps the scancodes to virtual keys while
respecting the keyboard layout is X11.

Had you ever had a look to the microwindows project?

http://www.microwindows.org

They have a unified scancode engine and handoptimizes x86 asm graphics
primitve code. Maybe, you could look in there, or just use their basic
engine. They project is strickly in layers, so that you could just take
the basic part or so. It also needs to sit on top of frambuffer console,
SDL, X11… Maybe, you like to look into it.

------------ End -----------On Wed, 28 Nov 2001, Sam Lantinga wrote: