[SDL] Re: AltGr and other things

Christophe Cavalaria chris.cavalaria at free.fr
Fri Sep 30 16:48:03 PDT 2005


Ingo Schmidt wrote:

> Hi!
> 
> First of all:
> I am new to the list. Hi to everyone :-)
> 
> Now my questions:
> 
> I have this code in a program:
> 
>         SDL_Event event;
>         int eventmask = SDL_EVENTMASK(SDL_KEYDOWN)
>                                         | SDL_EVENTMASK(SDL_KEYUP)
>                                         |
SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)
>                                         | SDL_EVENTMASK(SDL_MOUSEBUTTONUP)
>                                         | SDL_EVENTMASK(SDL_MOUSEMOTION)
>                                         | SDL_EVENTMASK(SDL_JOYAXISMOTION)
>                                         | SDL_EVENTMASK(SDL_JOYHATMOTION)
>                                         | SDL_EVENTMASK(SDL_JOYBUTTONDOWN)
>                                         | SDL_EVENTMASK(SDL_JOYBUTTONUP)
>                                         | SDL_EVENTMASK(SDL_ACTIVEEVENT)
> #ifdef SDL_GUI
>                                         | SDL_EVENTMASK(GUI_RETURN_INFO)
> #endif
>                                         | SDL_EVENTMASK(SDL_QUIT);
> 
>         SDL_PumpEvents();
>         while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, eventmask)) {
>                 int type = event.type;
> 
>                 if (type == SDL_KEYDOWN || type == SDL_KEYUP) {
>                         process_keyboard_event(event);
>                 }
>                 else if (type == SDL_MOUSEBUTTONDOWN || type ==
>                 SDL_MOUSEBUTTONUP ...
>                 ...
>                 
>         
> static void process_keyboard_event(SDL_Event &event)
> {
>         SDL_keysym keysym = event.key.keysym;
>         SDLKey sym = keysym.sym;
>         int state = SDL_GetModState(); // keysym.mod does not deliver
>         single mod key presses for some reason ...
>         ...
> 
> 
> 
> If I press AltGr now, I get FOUR events:
> 
> left ctrl down
> right alt down
> left ctrl up
> right alt up
> 
> WHY? Why dont I get an event that would indicate, that AltGr was
> pressed? In the variable "state" I ask the current ModState. Why am I
> doing it with this function? Because keysym.mod != SDL_GetModState();
> 
> Again: Why?
> 
> And yet another question:
> On my German keyboard I have a key with <,> and | on it. If I press
> this key, then keysym.sym == 0!
> 
> And yet another: Why? ;-)
> 
> All this under Windows XP pro, SP 2.
> 
> What am I doing wrong? How can I change the behaviour? I am using
> version 1.2.9
> 
> 
> Cheers, Ingo =;->

I guess it's due to the way Windows handles the AltGr key :
http://blogs.msdn.com/oldnewthing/archive/2004/03/29/101121.aspx

Too bad they have that broken way to do that.





More information about the SDL mailing list