From cf145a275d1d5ecf9a51446ad1fbe4a929cda3cc Mon Sep 17 00:00:00 2001
From: Julien <littleboy@users.sourceforge.net>
Date: Wed, 17 Feb 2010 15:16:47 -0500
Subject: [PATCH] Add support for Scroll lock as a modifier key and remove hack in SCI event code
---
backends/platform/sdl/events.cpp | 12 ++++++++++++
backends/platform/sdl/sdl.cpp | 1 +
engines/sci/event.cpp | 25 +------------------------
3 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp
index 0c13d0f..2edea66 100644
a
|
b
|
bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
234 | 234 | |
235 | 235 | SDLModToOSystemKeyFlags(SDL_GetModState(), event); |
236 | 236 | |
| 237 | // Handle scroll lock as a key modifier |
| 238 | if (ev.key.keysym.sym == SDLK_SCROLLOCK) |
| 239 | _scrollLock = !_scrollLock; |
| 240 | |
| 241 | if (_scrollLock) |
| 242 | event.kbd.flags |= Common::KBD_SCRL; |
| 243 | |
237 | 244 | // Alt-Return and Alt-Enter toggle full screen mode |
238 | 245 | if (event.kbd.hasFlags(Common::KBD_ALT) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER)) { |
239 | 246 | beginGFXTransaction(); |
… |
… |
bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) {
|
326 | 333 | |
327 | 334 | // Ctrl-Alt-<key> will change the GFX mode |
328 | 335 | SDLModToOSystemKeyFlags(SDL_GetModState(), event); |
| 336 | |
| 337 | // Set the scroll lock sticky flag |
| 338 | if (_scrollLock) |
| 339 | event.kbd.flags |= Common::KBD_SCRL; |
| 340 | |
329 | 341 | if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { |
330 | 342 | // Swallow these key up events |
331 | 343 | return false; |
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 356f881..27ae43d 100644
a
|
b
|
OSystem_SDL::OSystem_SDL()
|
232 | 232 | _overlayscreen(0), _tmpscreen2(0), |
233 | 233 | _samplesPerSec(0), |
234 | 234 | _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), |
| 235 | _scrollLock(false), |
235 | 236 | _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), |
236 | 237 | _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), |
237 | 238 | _joystick(0), |
diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp
index 420411f..dfc9c3c 100644
a
|
b
|
sciEvent SciEvent::getFromScummVM() {
|
120 | 120 | int modifiers = em->getModifierState(); |
121 | 121 | |
122 | 122 | // We add the modifier key status to buckybits |
123 | | // SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off |
124 | | // |
125 | | // FIXME: This code is semi-bogus. It only records the modifier key being *pressed*. |
126 | | // It does not track correctly whether scrolllock. is active. To do that, we |
127 | | // would have to record the fact that the modifier was pressed in global var, |
128 | | // and also watch for Common::EVENT_KEYUP events. |
129 | | // But this is still not quite good enough, because not all events might |
130 | | // pass through here (e.g. the GUI might be running with its own event loop). |
131 | | // |
132 | | // The best solution likely would be to add code to the EventManager class |
133 | | // for tracking which keys are pressed and which are not... |
134 | | if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) { |
135 | | switch (ev.kbd.keycode) { |
136 | | case Common::KEYCODE_SCROLLOCK: |
137 | | if (ev.type == Common::EVENT_KEYDOWN) { |
138 | | _modifierStates |= SCI_KEYMOD_SCRLOCK; |
139 | | } else { |
140 | | _modifierStates &= ~SCI_KEYMOD_SCRLOCK; |
141 | | } |
142 | | break; |
143 | | default: |
144 | | break; |
145 | | } |
146 | | } |
147 | 123 | //TODO: SCI_EVM_INSERT |
148 | 124 | |
149 | 125 | input.modifiers = |
… |
… |
sciEvent SciEvent::getFromScummVM() {
|
152 | 128 | ((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0) | |
153 | 129 | ((ev.kbd.flags & Common::KBD_NUM) ? SCI_KEYMOD_NUMLOCK : 0) | |
154 | 130 | ((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) | |
| 131 | ((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) | |
155 | 132 | _modifierStates; |
156 | 133 | |
157 | 134 | switch (ev.type) { |