diff options
author | Max Horn | 2004-12-30 14:11:00 +0000 |
---|---|---|
committer | Max Horn | 2004-12-30 14:11:00 +0000 |
commit | 246f14bb406e7408a62e98702bedb497634ae2f1 (patch) | |
tree | 3b9137d7e2390ec434ae5eae36f2cf6df244a6a2 /backends | |
parent | 9581bd5691183bc9aca1f59fc80e656f1ff82239 (diff) | |
download | scummvm-rg350-246f14bb406e7408a62e98702bedb497634ae2f1.tar.gz scummvm-rg350-246f14bb406e7408a62e98702bedb497634ae2f1.tar.bz2 scummvm-rg350-246f14bb406e7408a62e98702bedb497634ae2f1.zip |
set key modifiers for keyup events, too; use SDL_GetModState to determine mod flags, so that the modifier flags get set if e.g. the shift key is pressed alone
svn-id: r16381
Diffstat (limited to 'backends')
-rw-r--r-- | backends/sdl/events.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/backends/sdl/events.cpp b/backends/sdl/events.cpp index 6749da9adf..e5cdc89280 100644 --- a/backends/sdl/events.cpp +++ b/backends/sdl/events.cpp @@ -145,6 +145,25 @@ void OSystem_SDL::handleKbdMouse() { } } +static byte SDLModToOSystemKeyFlags(SDLMod mod) { + byte b = 0; +#ifdef LINUPY + // Yopy has no ALT key, steal the SHIFT key + // (which isn't used much anyway) + if (mod & KMOD_SHIFT) + b |= OSystem::KBD_ALT; +#else + if (mod & KMOD_SHIFT) + b |= OSystem::KBD_SHIFT; + if (mod & KMOD_ALT) + b |= OSystem::KBD_ALT; +#endif + if (mod & KMOD_CTRL) + b |= OSystem::KBD_CTRL; + + return b; +} + bool OSystem_SDL::pollEvent(Event &event) { SDL_Event ev; int axis; @@ -162,21 +181,7 @@ bool OSystem_SDL::pollEvent(Event &event) { while(SDL_PollEvent(&ev)) { switch(ev.type) { case SDL_KEYDOWN: -#ifdef LINUPY - // Yopy has no ALT key, steal the SHIFT key - // (which isn't used much anyway) - if (ev.key.keysym.mod & KMOD_SHIFT) - b |= KBD_ALT; - if (ev.key.keysym.mod & KMOD_CTRL) - b |= KBD_CTRL; -#else - if (ev.key.keysym.mod & KMOD_SHIFT) - b |= KBD_SHIFT; - if (ev.key.keysym.mod & KMOD_CTRL) - b |= KBD_CTRL; - if (ev.key.keysym.mod & KMOD_ALT) - b |= KBD_ALT; -#endif + b = SDLModToOSystemKeyFlags(SDL_GetModState()); event.kbd.flags = b; // Alt-Return and Alt-Enter toggle full screen mode @@ -418,6 +423,7 @@ bool OSystem_SDL::pollEvent(Event &event) { event.type = EVENT_KEYUP; event.kbd.keycode = ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); + event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());; /* switch(ev.key.keysym.sym) { |