Sdl 1.2 - incorrect scancode reported on osx

Hello all, i’ve run into a tiny problem wtih SDL1.2 on osx.
Every time i press the W key on the keyboard i get an event reporting
SDLK_z scancode; the opposite happens when i press Z (and get a W key
event).
This happens with the italian keyboard, while the code works well with
the english layout: is this a known problem? is there a way to fix it?

Thanks,
Vittorio

This happens with the italian keyboard, while the code works well with
the english layout: is this a known problem? is there a way to fix it?

It looks like the Mac 1.2 code decides the keysym from the scancode, and
tries to let the OS override this:

http://hg.libsdl.org/SDL/file/80ae1ac3bdc9/src/video/quartz/SDL_QuartzEvents.m#l215

If that piece of code is completely failing for some reason, you’d get
the behaviour you’re experiencing, as scancodes map to physical keys (so
whatever letter happens to be written on a specific key, you’ll get the
same value in any country).

I’ve never heard a complaint about this happening before, but that
doesn’t mean anything.

If you care that the key is SDLK_w, that’ll be a problem, but if you
wanted to know if the user typed a “w” while entering text, call
SDL_EnableUNICODE(1) near the start of your program and use
event.key.keysym.unicode in the SDL_KEYDOWN event…on the Mac, this
gets the “w” character from Cocoa directly, and should still work correctly.

–ryan.

Follow up from July 5th…

This happens with the italian keyboard, while the code works well with
the english layout: is this a known problem? is there a way to fix it?

It looks like the Mac 1.2 code decides the keysym from the scancode, and
tries to let the OS override this:

http://hg.libsdl.org/SDL/file/80ae1ac3bdc9/src/video/quartz/SDL_QuartzEvents.m#l215

If that piece of code is completely failing for some reason, you’d get
the behaviour you’re experiencing, as scancodes map to physical keys (so
whatever letter happens to be written on a specific key, you’ll get the
same value in any country).

I think this was fixed in my sandbox, btw, by moving off a deprecated API.

–ryan.