[SDL] AltGr and other things

Sami Näätänen sn.ml at bayminer.com
Thu Sep 29 10:25:59 PDT 2005


On Thursday 29 September 2005 01:58, 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_MOUSEBUTT
>                                         |ONDOWN)
>                                         | SDL_EVENTMASK(SDL_MOUSEBUTT
>                                         |ONUP)
>                                         | SDL_EVENTMASK(SDL_MOUSEMOTI
>                                         |ON)
>                                         | SDL_EVENTMASK(SDL_JOYAXISMO
>                                         |TION)
>                                         | SDL_EVENTMASK(SDL_JOYHATMOT
>                                         |ION)
>                                         | SDL_EVENTMASK(SDL_JOYBUTTON
>                                         |DOWN)
>                                         | SDL_EVENTMASK(SDL_JOYBUTTON
>                                         |UP)
>                                         | SDL_EVENTMASK(SDL_ACTIVEEVE
>                                         |NT)
>
> #ifdef SDL_GUI
>
>                                         | SDL_EVENTMASK(GUI_RETURN_IN
>                                         |FO)
>
> #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 ...
>         ...

How do you combine this information?
If you only press say right alt it should give you keysym of SDLK_RALT
It will not give you keysym.mod if you do not press any other key.

Could you send the combination code, because that is most likely doing 
something wrong.

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




More information about the SDL mailing list