[SDL] AltGr and other things

Elden Armbrust earmbrust at xero-soft.com
Wed Sep 28 17:42:13 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
>        ...
>        ...
>
>
>
>  
>
Is this on a press AND release that you get the following four events?

>If I press AltGr now, I get FOUR events:
>
>left ctrl down
>right alt down
>left ctrl up
>right alt up
>
>  
>
If it is a press and release of those keys, then that is how it should 
respond, given the code:

if (type == SDL_KEYDOWN || type == SDL_KEYUP) {

>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? ;-)
>
>  
>
I'm sorry, I don't know much about foreign keyboards and the way SDL 
handles their keysyms, maybe someone else would know more about this 
problem than I do.

>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 =;->
>
>
>_______________________________________________
>SDL mailing list
>SDL at libsdl.org
>http://www.libsdl.org/mailman/listinfo/sdl
>
>
>
>  
>
-Elden





More information about the SDL mailing list