[SDL] sdl 1.2 - incorrect scancode reported on osx

Ryan C. Gordon icculus at icculus.org
Tue Jul 5 02:52:05 PDT 2011


> 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.




More information about the SDL mailing list