diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/events/default/default-events.cpp | 6 | ||||
-rw-r--r-- | backends/platform/sdl/events.cpp | 51 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 1 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.h | 3 |
4 files changed, 41 insertions, 20 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 8b3fe5cdc4..212cb130c1 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -103,7 +103,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _keyRepeatTime = time + kKeyRepeatInitialDelay; #endif // Global Main Menu - if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == Common::KEYCODE_F5) { + if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) { if (g_engine && !g_engine->isPaused()) { Common::Event menuEvent; menuEvent.type = Common::EVENT_MAINMENU; @@ -135,7 +135,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { } } #ifdef ENABLE_VKEYBD - else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.flags == 0) { + else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) { if (_vk->isDisplaying()) { _vk->close(true); } else { @@ -149,7 +149,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { } #endif #ifdef ENABLE_KEYMAPPER - else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.flags == 0) { + else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.hasFlags(0)) { if (!_remap) { _remap = true; Common::RemapDialog _remapDialog; diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index d7f6468b24..fe7fd7e5f9 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -152,23 +152,29 @@ void OSystem_SDL::handleKbdMouse() { } } -static byte SDLModToOSystemKeyFlags(SDLMod mod) { - byte b = 0; +static void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { + + event.kbd.flags = 0; + #ifdef LINUPY // Yopy has no ALT key, steal the SHIFT key // (which isn't used much anyway) if (mod & KMOD_SHIFT) - b |= Common::KBD_ALT; + event.kbd.flags |= Common::KBD_ALT; #else if (mod & KMOD_SHIFT) - b |= Common::KBD_SHIFT; + event.kbd.flags |= Common::KBD_SHIFT; if (mod & KMOD_ALT) - b |= Common::KBD_ALT; + event.kbd.flags |= Common::KBD_ALT; #endif if (mod & KMOD_CTRL) - b |= Common::KBD_CTRL; + event.kbd.flags |= Common::KBD_CTRL; - return b; + // Sticky flags + if (mod & KMOD_NUM) + event.kbd.flags |= Common::KBD_NUM; + if (mod & KMOD_CAPS) + event.kbd.flags |= Common::KBD_CAPS; } bool OSystem_SDL::pollEvent(Common::Event &event) { @@ -225,12 +231,18 @@ bool OSystem_SDL::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) { - byte b = 0; - b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState()); + + SDLModToOSystemKeyFlags(SDL_GetModState(), event); + + // Handle scroll lock as a key modifier + if (ev.key.keysym.sym == SDLK_SCROLLOCK) + _scrollLock = !_scrollLock; + + if (_scrollLock) + event.kbd.flags |= Common::KBD_SCRL; // Alt-Return and Alt-Enter toggle full screen mode - if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN - || ev.key.keysym.sym == SDLK_KP_ENTER)) { + if (event.kbd.hasFlags(Common::KBD_ALT) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER)) { beginGFXTransaction(); setFullscreenMode(!_videoMode.fullscreen); endGFXTransaction(); @@ -245,7 +257,7 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) { } // Alt-S: Create a screenshot - if (b == Common::KBD_ALT && ev.key.keysym.sym == 's') { + if (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 's') { char filename[20]; for (int n = 0;; n++) { @@ -265,7 +277,7 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) { } // Ctrl-m toggles mouse capture - if (b == Common::KBD_CTRL && ev.key.keysym.sym == 'm') { + if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') { toggleMouseGrab(); return false; } @@ -284,7 +296,7 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) { } #else // Ctrl-z and Alt-X quit - if ((b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT && ev.key.keysym.sym == 'x')) { + if ((event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'z') || (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 'x')) { event.type = Common::EVENT_QUIT; return true; } @@ -296,7 +308,7 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) { } // Ctrl-Alt-<key> will change the GFX mode - if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { + if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { if (handleScalerHotkeys(ev.key)) return false; } @@ -320,8 +332,13 @@ bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) { event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); // Ctrl-Alt-<key> will change the GFX mode - byte b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState()); - if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { + SDLModToOSystemKeyFlags(SDL_GetModState(), event); + + // Set the scroll lock sticky flag + if (_scrollLock) + event.kbd.flags |= Common::KBD_SCRL; + + if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { // Swallow these key up events return false; } diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 356f881830..27ae43d4b8 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -232,6 +232,7 @@ OSystem_SDL::OSystem_SDL() _overlayscreen(0), _tmpscreen2(0), _samplesPerSec(0), _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), + _scrollLock(false), _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), _joystick(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 0b862abd63..78793d4aad 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -412,6 +412,9 @@ protected: kMouseColorKey = 1 }; + // Scroll lock state - since SDL doesn't track it + bool _scrollLock; + // joystick SDL_Joystick *_joystick; |