aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/events/default/default-events.cpp6
-rw-r--r--backends/platform/sdl/events.cpp51
-rw-r--r--backends/platform/sdl/sdl.cpp1
-rw-r--r--backends/platform/sdl/sdl.h3
-rw-r--r--common/keyboard.h29
-rw-r--r--engines/agi/agi.cpp2
-rw-r--r--engines/agi/preagi_troll.cpp2
-rw-r--r--engines/agos/event.cpp10
-rw-r--r--engines/cruise/cruise_main.cpp2
-rw-r--r--engines/draci/draci.cpp2
-rw-r--r--engines/gob/gob.cpp2
-rw-r--r--engines/gob/util.cpp2
-rw-r--r--engines/kyra/gui.cpp2
-rw-r--r--engines/kyra/kyra_v1.cpp8
-rw-r--r--engines/lure/fights.cpp2
-rw-r--r--engines/lure/game.cpp2
-rw-r--r--engines/m4/events.cpp2
-rw-r--r--engines/m4/mads_views.cpp2
-rw-r--r--engines/parallaction/input.cpp2
-rw-r--r--engines/queen/input.cpp6
-rw-r--r--engines/saga/input.cpp4
-rw-r--r--engines/saga/interface.cpp2
-rw-r--r--engines/sci/event.cpp43
-rw-r--r--engines/scumm/dialogs.cpp2
-rw-r--r--engines/scumm/input.cpp44
-rw-r--r--engines/sky/sky.cpp8
-rw-r--r--engines/sword2/sword2.cpp8
-rw-r--r--engines/teenagent/teenagent.cpp6
-rw-r--r--engines/tinsel/tinsel.cpp7
-rw-r--r--engines/touche/touche.cpp2
-rw-r--r--engines/tucker/tucker.cpp2
-rw-r--r--gui/ListWidget.cpp72
-rw-r--r--gui/PopUpWidget.cpp30
-rw-r--r--gui/console.cpp160
-rw-r--r--gui/console.h2
-rw-r--r--gui/editable.cpp79
-rw-r--r--gui/editable.h2
37 files changed, 404 insertions, 207 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;
diff --git a/common/keyboard.h b/common/keyboard.h
index cf595d4dd8..928b59d997 100644
--- a/common/keyboard.h
+++ b/common/keyboard.h
@@ -40,15 +40,15 @@ enum KeyCode {
KEYCODE_PAUSE = 19,
KEYCODE_ESCAPE = 27,
KEYCODE_SPACE = 32,
- KEYCODE_EXCLAIM = 33,
- KEYCODE_QUOTEDBL = 34,
- KEYCODE_HASH = 35,
- KEYCODE_DOLLAR = 36,
- KEYCODE_AMPERSAND = 38,
- KEYCODE_QUOTE = 39,
+ KEYCODE_EXCLAIM = 33, // !
+ KEYCODE_QUOTEDBL = 34, // "
+ KEYCODE_HASH = 35, // #
+ KEYCODE_DOLLAR = 36, // $
+ KEYCODE_AMPERSAND = 38, // &
+ KEYCODE_QUOTE = 39, // '
KEYCODE_LEFTPAREN = 40,
KEYCODE_RIGHTPAREN = 41,
- KEYCODE_ASTERISK = 42,
+ KEYCODE_ASTERISK = 42, // *
KEYCODE_PLUS = 43,
KEYCODE_COMMA = 44,
KEYCODE_MINUS = 45,
@@ -105,6 +105,7 @@ enum KeyCode {
KEYCODE_y = 121,
KEYCODE_z = 122,
KEYCODE_DELETE = 127,
+ KEYCODE_TILDE = 176, // ~
// Numeric keypad
KEYCODE_KP0 = 256,
@@ -215,7 +216,10 @@ enum {
enum {
KBD_CTRL = 1 << 0,
KBD_ALT = 1 << 1,
- KBD_SHIFT = 1 << 2
+ KBD_SHIFT = 1 << 2,
+ KBD_NUM = 1 << 3,
+ KBD_CAPS = 1 << 4,
+ KBD_SCRL = 1 << 5
};
/**
@@ -245,7 +249,7 @@ struct KeyState {
/**
* Status of the modifier keys. Bits are set in this for each
* pressed modifier
- * @see KBD_CTRL, KBD_ALT, KBD_SHIFT
+ * @see KBD_CTRL, KBD_ALT, KBD_SHIFT, KBD_NUM, KBD_CAPS, KBD_SCRL
*/
byte flags;
@@ -266,6 +270,13 @@ struct KeyState {
ascii = flags = 0;
}
+ /**
+ * Check for flags, ignoring the sticky flags (KBD_NUM, KBD_CAPS, KBD_SCRL)
+ */
+ bool hasFlags(byte f) {
+ return f == (flags & ~(KBD_NUM|KBD_CAPS|KBD_SCRL));
+ }
+
bool operator ==(const KeyState &x) const {
return keycode == x.keycode && ascii == x.ascii && flags == x.flags;
}
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index de2d9a8ab9..c66ccd4751 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -121,7 +121,7 @@ void AgiEngine::processEvents() {
_mouse.y = event.mouse.y;
break;
case Common::EVENT_KEYDOWN:
- if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == Common::KEYCODE_d) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) {
_console->attach();
break;
}
diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp
index 619c0c0cc6..96a3147e5a 100644
--- a/engines/agi/preagi_troll.cpp
+++ b/engines/agi/preagi_troll.cpp
@@ -104,7 +104,7 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
case Common::KEYCODE_KP_ENTER:
return true;
case Common::KEYCODE_s:
- if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (_soundOn) {
playTune(2, 1);
_soundOn = !_soundOn;
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index 360fa4bf8c..f22a2e69e9 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -459,8 +459,8 @@ void AGOSEngine::delay(uint amount) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9
- && (event.kbd.flags == Common::KBD_ALT ||
- event.kbd.flags == Common::KBD_CTRL)) {
+ && (event.kbd.hasFlags(Common::KBD_ALT) ||
+ event.kbd.hasFlags(Common::KBD_CTRL))) {
_saveLoadSlot = event.kbd.keycode - Common::KEYCODE_0;
// There is no save slot 0
@@ -469,13 +469,13 @@ void AGOSEngine::delay(uint amount) {
memset(_saveLoadName, 0, sizeof(_saveLoadName));
sprintf(_saveLoadName, "Quick %d", _saveLoadSlot);
- _saveLoadType = (event.kbd.flags == Common::KBD_ALT) ? 1 : 2;
+ _saveLoadType = (event.kbd.hasFlags(Common::KBD_ALT)) ? 1 : 2;
// We should only allow a load or save when it was possible in original
// This stops load/save during copy protection, conversations and cut scenes
if (!_mouseHideCount && !_showPreposition)
quickLoadOrSave();
- } else if (event.kbd.flags == Common::KBD_CTRL) {
+ } else if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (event.kbd.keycode == Common::KEYCODE_a) {
GUI::Dialog *_aboutDialog;
_aboutDialog = new GUI::AboutDialog();
@@ -492,7 +492,7 @@ void AGOSEngine::delay(uint amount) {
}
if (getGameType() == GType_PP) {
- if (event.kbd.flags == Common::KBD_SHIFT)
+ if (event.kbd.hasFlags(Common::KBD_SHIFT))
_variableArray[41] = 0;
else
_variableArray[41] = 1;
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index 92d484e241..14de916a84 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -1759,7 +1759,7 @@ bool manageEvents() {
break;
}
- if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (event.kbd.keycode == Common::KEYCODE_d) {
// Start the debugger
_vm->getDebugger()->attach();
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 31b2c28679..882b845f08 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -293,7 +293,7 @@ void DraciEngine::handleEvents() {
}
break;
case Common::KEYCODE_F5:
- if (event.kbd.flags == 0) {
+ if (event.kbd.hasFlags(0)) {
openMainMenuDialog();
}
break;
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index cf2f090351..e0d7a740eb 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -109,7 +109,7 @@ void PauseDialog::reflowLayout() {
void PauseDialog::handleKeyDown(Common::KeyState state) {
// Close on CTRL+p
- if ((state.flags == Common::KBD_CTRL) && (state.keycode == Common::KEYCODE_p))
+ if ((state.hasFlags(Common::KBD_CTRL)) && (state.keycode == Common::KEYCODE_p))
close();
}
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 2e15948080..26899232e2 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -114,7 +114,7 @@ void Util::processInput(bool scroll) {
_mouseButtons = (MouseButtons) (((uint32) _mouseButtons) & ~((uint32) kMouseButtonsRight));
break;
case Common::EVENT_KEYDOWN:
- if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (event.kbd.keycode == Common::KEYCODE_f)
_fastMode ^= 1;
else if (event.kbd.keycode == Common::KEYCODE_g)
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index d976c3463d..ac14a408a9 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -421,7 +421,7 @@ void GUI::checkTextfieldInput() {
while (_vm->_eventMan->pollEvent(event) && running) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.flags == Common::KBD_CTRL)
+ if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL))
_vm->quitGame();
else
_keyPressed = event.kbd;
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index eebb493e38..b9894af98f 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -262,10 +262,10 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag)
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode >= Common::KEYCODE_1 && event.kbd.keycode <= Common::KEYCODE_9 &&
- (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && mainLoop) {
+ (event.kbd.hasFlags(Common::KBD_CTRL) || event.kbd.hasFlags(Common::KBD_ALT)) && mainLoop) {
int saveLoadSlot = 9 - (event.kbd.keycode - Common::KEYCODE_0) + 990;
- if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (saveFileLoadable(saveLoadSlot))
loadGameStateCheck(saveLoadSlot);
_eventList.clear();
@@ -275,7 +275,7 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag)
sprintf(savegameName, "Quicksave %d", event.kbd.keycode - Common::KEYCODE_0);
saveGameState(saveLoadSlot, savegameName, 0);
}
- } else if (event.kbd.flags == Common::KBD_CTRL) {
+ } else if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (event.kbd.keycode == Common::KEYCODE_d) {
if (_debugger)
_debugger->attach();
@@ -385,7 +385,7 @@ void KyraEngine_v1::updateInput() {
event.kbd.keycode == Common::KEYCODE_UP || event.kbd.keycode == Common::KEYCODE_RIGHT ||
event.kbd.keycode == Common::KEYCODE_DOWN || event.kbd.keycode == Common::KEYCODE_LEFT)
_eventList.push_back(Event(event, true));
- else if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.flags == Common::KBD_CTRL)
+ else if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
else
_eventList.push_back(event);
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp
index 81dfac03c8..53539677c8 100644
--- a/engines/lure/fights.cpp
+++ b/engines/lure/fights.cpp
@@ -205,7 +205,7 @@ void FightsManager::checkEvents() {
return;
case Common::KEYCODE_d:
- if (events.event().kbd.flags == Common::KBD_CTRL) {
+ if (events.event().kbd.hasFlags(Common::KBD_CTRL)) {
// Activate the debugger
game.debugger().attach();
return;
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 36d423251b..49a100346e 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -195,7 +195,7 @@ void Game::execute() {
if (events.type() == Common::EVENT_KEYDOWN) {
uint16 roomNum = room.roomNumber();
- if ((events.event().kbd.flags == Common::KBD_CTRL) &&
+ if ((events.event().kbd.hasFlags(Common::KBD_CTRL)) &&
(events.event().kbd.keycode == Common::KEYCODE_d)) {
// Activate the debugger
_debugger->attach();
diff --git a/engines/m4/events.cpp b/engines/m4/events.cpp
index b0c5e8f85d..0acf0cd6e4 100644
--- a/engines/m4/events.cpp
+++ b/engines/m4/events.cpp
@@ -73,7 +73,7 @@ M4EventType Events::handleEvents() {
if ((_event.kbd.keycode == Common::KEYCODE_LCTRL) || (_event.kbd.keycode == Common::KEYCODE_RCTRL))
_ctrlFlag = true;
- else if (_event.kbd.flags == Common::KBD_CTRL) {
+ else if (_event.kbd.hasFlags(Common::KBD_CTRL)) {
if ((_event.kbd.keycode == Common::KEYCODE_d) && _ctrlFlag) {
_console->attach();
_console->onFrame();
diff --git a/engines/m4/mads_views.cpp b/engines/m4/mads_views.cpp
index d4d3bc53cb..c06a8de513 100644
--- a/engines/m4/mads_views.cpp
+++ b/engines/m4/mads_views.cpp
@@ -362,7 +362,7 @@ bool MadsInterfaceView::handleKeypress(int32 keycode) {
// Capitalise the letter if necessary
if (_cheatKeyCtr < CHEAT_SEQUENCE_MAX) {
- if ((flags == Common::KBD_CTRL) && (kc == CHEAT_SEQUENCE[_cheatKeyCtr])) {
+ if ((flags & Common::KBD_CTRL) && (kc == CHEAT_SEQUENCE[_cheatKeyCtr])) {
++_cheatKeyCtr;
if (_cheatKeyCtr == CHEAT_SEQUENCE_MAX)
Dialog::display(_vm, 22, cheatingEnabledDesc);
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index d1e2765539..42f60995ff 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -111,7 +111,7 @@ void Input::readInput() {
_hasKeyPressEvent = true;
_keyPressed = e.kbd;
- if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd')
+ if (e.kbd.hasFlags(Common::KBD_CTRL) && e.kbd.keycode == Common::KEYCODE_d)
_vm->_debugger->attach();
updateMousePos = false;
diff --git a/engines/queen/input.cpp b/engines/queen/input.cpp
index 84e21fbcaa..473253786c 100644
--- a/engines/queen/input.cpp
+++ b/engines/queen/input.cpp
@@ -100,10 +100,10 @@ void Input::delay(uint amount) {
_idleTime = 0;
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if (event.kbd.flags == Common::KBD_CTRL) {
- if (event.kbd.keycode == 'd') {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ if (event.kbd.keycode == Common::KEYCODE_d) {
_debugger = true;
- } else if (event.kbd.keycode == 'f') {
+ } else if (event.kbd.keycode == Common::KEYCODE_f) {
_fastMode = !_fastMode;
}
} else {
diff --git a/engines/saga/input.cpp b/engines/saga/input.cpp
index 7bce00686c..e3a3b49396 100644
--- a/engines/saga/input.cpp
+++ b/engines/saga/input.cpp
@@ -44,7 +44,7 @@ int SagaEngine::processInput() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (event.kbd.keycode == Common::KEYCODE_d)
_console->attach();
}
@@ -56,7 +56,7 @@ int SagaEngine::processInput() {
switch (event.kbd.keycode) {
case Common::KEYCODE_HASH:
case Common::KEYCODE_BACKQUOTE:
- case Common::KEYCODE_QUOTE: // tilde ("~")
+ case Common::KEYCODE_TILDE: // tilde ("~")
_console->attach();
break;
case Common::KEYCODE_r:
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp
index 42336912d5..eb132e3831 100644
--- a/engines/saga/interface.cpp
+++ b/engines/saga/interface.cpp
@@ -651,7 +651,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
return true;
}
}
- if (keystate.keycode == Common::KEYCODE_o && keystate.flags == Common::KBD_CTRL) { // ctrl-o
+ if (keystate.keycode == Common::KEYCODE_o && keystate.hasFlags(Common::KBD_CTRL)) { // ctrl-o
if (_saveReminderState > 0) {
setMode(kPanelOption);
return true;
diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp
index 4f6201824e..dfc9c3c4f1 100644
--- a/engines/sci/event.cpp
+++ b/engines/sci/event.cpp
@@ -120,50 +120,15 @@ sciEvent SciEvent::getFromScummVM() {
int modifiers = em->getModifierState();
// We add the modifier key status to buckybits
- // SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off
- //
- // FIXME: This code is semi-bogus. It only records the modifier key being *pressed*.
- // It does not track correctly whether capslock etc. is active. To do that, we
- // would have to record the fact that the modifier was pressed in global var,
- // and also watch for Common::EVENT_KEYUP events.
- // But this is still not quite good enough, because not all events might
- // pass through here (e.g. the GUI might be running with its own event loop).
- //
- // The best solution likely would be to add code to the EventManager class
- // for tracking which keys are pressed and which are not...
- if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {
- switch (ev.kbd.keycode) {
- case Common::KEYCODE_CAPSLOCK:
- if (ev.type == Common::EVENT_KEYDOWN) {
- _modifierStates |= SCI_KEYMOD_CAPSLOCK;
- } else {
- _modifierStates &= ~SCI_KEYMOD_CAPSLOCK;
- }
- break;
- case Common::KEYCODE_NUMLOCK:
- if (ev.type == Common::EVENT_KEYDOWN) {
- _modifierStates |= SCI_KEYMOD_NUMLOCK;
- } else {
- _modifierStates &= ~SCI_KEYMOD_NUMLOCK;
- }
- break;
- case Common::KEYCODE_SCROLLOCK:
- if (ev.type == Common::EVENT_KEYDOWN) {
- _modifierStates |= SCI_KEYMOD_SCRLOCK;
- } else {
- _modifierStates &= ~SCI_KEYMOD_SCRLOCK;
- }
- break;
- default:
- break;
- }
- }
//TODO: SCI_EVM_INSERT
input.modifiers =
((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) |
((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) |
((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0) |
+ ((ev.kbd.flags & Common::KBD_NUM) ? SCI_KEYMOD_NUMLOCK : 0) |
+ ((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) |
+ ((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) |
_modifierStates;
switch (ev.type) {
@@ -173,7 +138,7 @@ sciEvent SciEvent::getFromScummVM() {
input.character = ev.kbd.ascii;
// Debug console
- if (ev.kbd.flags == Common::KBD_CTRL && ev.kbd.keycode == Common::KEYCODE_d) {
+ if (ev.kbd.hasFlags(Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) {
// Open debug console
Console *con = g_sci->getSciDebugger();
con->attach();
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp
index 3c329915f6..dd4569ca76 100644
--- a/engines/scumm/dialogs.cpp
+++ b/engines/scumm/dialogs.cpp
@@ -725,7 +725,7 @@ void SubtitleSettingsDialog::handleTickle() {
}
void SubtitleSettingsDialog::handleKeyDown(Common::KeyState state) {
- if (state.keycode == 't' && state.flags == Common::KBD_CTRL) {
+ if (state.keycode == Common::KEYCODE_t && state.hasFlags(Common::KBD_CTRL)) {
cycleValue();
reflowLayout();
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 5e3f9fefeb..8a9570f534 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -110,26 +110,26 @@ void ScummEngine_v80he::parseEvent(Common::Event event) {
void ScummEngine::parseEvent(Common::Event event) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9' &&
- ((event.kbd.flags == Common::KBD_ALT && canSaveGameStateCurrently()) ||
- (event.kbd.flags == Common::KBD_CTRL && canLoadGameStateCurrently()))) {
- _saveLoadSlot = event.kbd.keycode - '0';
+ if (event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9 &&
+ ((event.kbd.hasFlags(Common::KBD_ALT) && canSaveGameStateCurrently()) ||
+ (event.kbd.hasFlags(Common::KBD_CTRL) && canLoadGameStateCurrently()))) {
+ _saveLoadSlot = event.kbd.keycode - Common::KEYCODE_0;
// don't overwrite autosave (slot 0)
if (_saveLoadSlot == 0)
_saveLoadSlot = 10;
sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot);
- _saveLoadFlag = (event.kbd.flags == Common::KBD_ALT) ? 1 : 2;
+ _saveLoadFlag = (event.kbd.hasFlags(Common::KBD_ALT)) ? 1 : 2;
_saveTemporaryState = false;
- } else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {
+ } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) {
_fastMode ^= 1;
- } else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'g') {
+ } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_g) {
_fastMode ^= 2;
- } else if ((event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'd') ||
- event.kbd.ascii == '~' || event.kbd.ascii == '#') {
+ } else if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d)
+ || event.kbd.ascii == '~' || event.kbd.ascii == '#') {
_debugger->attach();
- } else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 's') {
+ } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_s) {
_res->resourceStats();
} else {
// Normal key press, pass on to the game.
@@ -355,12 +355,12 @@ void ScummEngine::processInput() {
#ifdef ENABLE_SCUMM_7_8
void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) {
// F1 (the trigger for the original save/load dialog) is mapped to F5
- if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.flags == 0) {
+ if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.hasFlags(0)) {
lastKeyHit = Common::KeyState(Common::KEYCODE_F5, 319);
}
// Alt-F5 should bring up the original save/load dialog, so map it to F1.
- if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) {
+ if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(Common::KBD_ALT)) {
lastKeyHit = Common::KeyState(Common::KEYCODE_F1, 315);
}
@@ -383,7 +383,7 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) {
// version string is hard coded in the engine, hence we don't invoke
// versionDialog for it. Dig/FT version strings are partly hard coded, too.
if (_game.id != GID_CMI && 0 != VAR(VAR_VERSION_KEY) &&
- lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.flags == Common::KBD_CTRL) {
+ lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.hasFlags(Common::KBD_CTRL)) {
versionDialog();
} else if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) {
@@ -408,7 +408,7 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) {
#endif
void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) {
- if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit.flags == Common::KBD_CTRL) {
+ if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit.hasFlags(Common::KBD_CTRL)) {
SubtitleSettingsDialog dialog(this, _voiceMode);
_voiceMode = runDialog(dialog);
@@ -442,7 +442,7 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) {
ScummEngine::processKeyboard(lastKeyHit);
// On Alt-F5 prepare savegame for the original save/load dialog.
- if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) {
+ if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(Common::KBD_ALT)) {
prepareSavegame();
if (_game.id == GID_MANIAC && _game.version == 0) {
runScript(2, 0, 0, 0);
@@ -467,7 +467,7 @@ void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) {
ScummEngine::processKeyboard(lastKeyHit);
// On Alt-F5 prepare savegame for the original save/load dialog.
- if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) {
+ if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(Common::KBD_ALT)) {
prepareSavegame();
}
@@ -504,7 +504,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
if (_game.id == GID_CMI)
mainmenuKeyEnabled = true;
- if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0)) {
+ if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(0))) {
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0);
@@ -513,25 +513,25 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0);
- } else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0)) {
+ } else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.hasFlags(0))) {
confirmRestartDialog();
- } else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit.flags == 0)) {
+ } else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit.hasFlags(0))) {
pauseGame();
- } else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit.flags == 0)) {
+ } else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit.hasFlags(0))) {
_talkDelay = 0;
if (_sound->_sfxMode & 2)
stopTalk();
- } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.flags == 0)) {
+ } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.hasFlags(0))) {
abortCutscene();
// VAR_CUTSCENEEXIT_KEY doesn't exist in SCUMM0
if (VAR_CUTSCENEEXIT_KEY != 0xFF)
_mouseAndKeyboardStat = VAR(VAR_CUTSCENEEXIT_KEY);
} else if (snapScrollKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_r &&
- lastKeyHit.flags == Common::KBD_CTRL) {
+ lastKeyHit.hasFlags(Common::KBD_CTRL)) {
_snapScroll ^= 1;
if (_snapScroll) {
messageDialog("Snap scroll on");
diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp
index 7fd13661ad..c099dbc8b1 100644
--- a/engines/sky/sky.cpp
+++ b/engines/sky/sky.cpp
@@ -113,12 +113,12 @@ void SkyEngine::handleKey() {
_skySound->fnUnPauseFx();
_systemVars.paused = false;
_skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette));
- } else if (_keyPressed.flags == Common::KBD_CTRL) {
- if (_keyPressed.keycode == 'f')
+ } else if (_keyPressed.hasFlags(Common::KBD_CTRL)) {
+ if (_keyPressed.keycode == Common::KEYCODE_f)
_fastMode ^= 1;
- else if (_keyPressed.keycode == 'g')
+ else if (_keyPressed.keycode == Common::KEYCODE_g)
_fastMode ^= 2;
- else if (_keyPressed.keycode == 'd')
+ else if (_keyPressed.keycode == Common::KEYCODE_d)
_debugger->attach();
} else if (_keyPressed.keycode) {
switch (_keyPressed.keycode) {
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index cf9e67e178..822946f42d 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -491,9 +491,9 @@ Common::Error Sword2Engine::run() {
KeyboardEvent *ke = keyboardEvent();
if (ke) {
- if ((ke->kbd.flags == Common::KBD_CTRL && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') {
+ if ((ke->kbd.hasFlags(Common::KBD_CTRL) && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') {
_debugger->attach();
- } else if (ke->kbd.flags == 0 || ke->kbd.flags == Common::KBD_SHIFT) {
+ } else if (ke->kbd.hasFlags(0) || ke->kbd.hasFlags(Common::KBD_SHIFT)) {
switch (ke->kbd.keycode) {
case Common::KEYCODE_p:
if (_gamePaused)
@@ -654,8 +654,8 @@ void Sword2Engine::parseInputEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if (event.kbd.flags == Common::KBD_CTRL) {
- if (event.kbd.keycode == 'f') {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ if (event.kbd.keycode == Common::KEYCODE_f) {
if (_gameSpeed == 1)
_gameSpeed = 2;
else
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 42478cfa12..5e3d960a28 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -474,12 +474,12 @@ Common::Error TeenAgentEngine::run() {
//debug(0, "event");
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if ((event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'd') ||
+ if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) ||
event.kbd.ascii == '~' || event.kbd.ascii == '#') {
console->attach();
- } else if (event.kbd.flags == 0 && event.kbd.keycode == Common::KEYCODE_F5) {
+ } else if (event.kbd.hasFlags(0) && event.kbd.keycode == Common::KEYCODE_F5) {
openMainMenuDialog();
- } if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {
+ } if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) {
_mark_delay = _mark_delay == 80? 40: 80;
debug(0, "mark_delay = %u", _mark_delay);
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index ba667cf224..f3e52c929d 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -230,11 +230,11 @@ void KeyboardProcess(CORO_PARAM, const void *) {
continue;
case Common::KEYCODE_m:
// Debug facility - scene hopper
- if (TinselV2 && (evt.kbd.flags == Common::KBD_ALT))
+ if (TinselV2 && (evt.kbd.hasFlags(Common::KBD_ALT)))
ProcessKeyEvent(PLR_JUMP);
break;
case Common::KEYCODE_q:
- if ((evt.kbd.flags == Common::KBD_CTRL) || (evt.kbd.flags == Common::KBD_ALT))
+ if ((evt.kbd.hasFlags(Common::KBD_CTRL)) || (evt.kbd.hasFlags(Common::KBD_ALT)))
ProcessKeyEvent(PLR_QUIT);
continue;
case Common::KEYCODE_PAGEUP:
@@ -1201,7 +1201,8 @@ void TinselEngine::ProcessKeyEvent(const Common::Event &event) {
// Handle any special keys immediately
switch (event.kbd.keycode) {
case Common::KEYCODE_d:
- if ((event.kbd.flags == Common::KBD_CTRL) && (event.type == Common::EVENT_KEYDOWN)) {
+ // Checks for CTRL flag, ignoring all the sticky flags
+ if ((Common::KBD_CTRL == (event.kbd.flags & ~(Common::KBD_NUM|Common::KBD_CAPS|Common::KBD_SCRL))) && (event.type == Common::EVENT_KEYDOWN)) {
// Activate the debugger
assert(_console);
_console->attach();
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 25874f869e..3289afe00f 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -313,7 +313,7 @@ void ToucheEngine::processEvents(bool handleKeyEvents) {
} else if (event.kbd.keycode == Common::KEYCODE_F10) {
_fastWalkMode = false;
}
- if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (event.kbd.keycode == Common::KEYCODE_f) {
_fastMode = !_fastMode;
}
diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp
index 5cfa99def7..f704dcb195 100644
--- a/engines/tucker/tucker.cpp
+++ b/engines/tucker/tucker.cpp
@@ -607,7 +607,7 @@ void TuckerEngine::parseEvents() {
case Common::EVENT_KEYDOWN:
switch (ev.kbd.keycode) {
case Common::KEYCODE_f:
- if (ev.kbd.flags == Common::KBD_CTRL) {
+ if (ev.kbd.hasFlags(Common::KBD_CTRL)) {
_fastMode = !_fastMode;
}
break;
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index fb6d7de2c5..baaa29aecb 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -286,7 +286,7 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
bool dirty = false;
int oldSelectedItem = _selectedItem;
- if (!_editMode && isprint((unsigned char)state.ascii)) {
+ if (!_editMode && state.keycode <= Common::KEYCODE_z && isprint((unsigned char)state.ascii)) {
// Quick selection mode: Go to first list item starting with this key
// (or a substring accumulated from the last couple key presses).
// Only works in a useful fashion if the list entries are sorted.
@@ -339,8 +339,18 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
sendCommand(kListItemActivatedCmd, _selectedItem);
}
break;
- case Common::KEYCODE_BACKSPACE:
+
+ // Keypad & special keys
+ // - if num lock is set, we do not handle the keypress
+ // - if num lock is not set, we either fall down to the special key case
+ // or ignore the key press for 0, 4, 5 and 6
+
case Common::KEYCODE_KP_PERIOD:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
+ case Common::KEYCODE_BACKSPACE:
case Common::KEYCODE_DELETE:
if (_selectedItem >= 0) {
if (_editable) {
@@ -350,30 +360,68 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
}
}
break;
- case Common::KEYCODE_UP:
- if (_selectedItem > 0)
- _selectedItem--;
+
+ case Common::KEYCODE_KP1:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
+ case Common::KEYCODE_END:
+ _selectedItem = _list.size() - 1;
break;
+
+
+ case Common::KEYCODE_KP2:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
case Common::KEYCODE_DOWN:
if (_selectedItem < (int)_list.size() - 1)
_selectedItem++;
break;
- case Common::KEYCODE_PAGEUP:
- _selectedItem -= _entriesPerPage - 1;
- if (_selectedItem < 0)
- _selectedItem = 0;
- break;
+
+ case Common::KEYCODE_KP3:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
case Common::KEYCODE_PAGEDOWN:
_selectedItem += _entriesPerPage - 1;
if (_selectedItem >= (int)_list.size() )
_selectedItem = _list.size() - 1;
break;
+
+ case Common::KEYCODE_KP7:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
case Common::KEYCODE_HOME:
_selectedItem = 0;
break;
- case Common::KEYCODE_END:
- _selectedItem = _list.size() - 1;
+
+ case Common::KEYCODE_KP8:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
+ case Common::KEYCODE_UP:
+ if (_selectedItem > 0)
+ _selectedItem--;
break;
+
+ case Common::KEYCODE_KP9:
+ if (state.flags & Common::KBD_NUM) {
+ handled = false;
+ break;
+ }
+ case Common::KEYCODE_PAGEUP:
+ _selectedItem -= _entriesPerPage - 1;
+ if (_selectedItem < 0)
+ _selectedItem = 0;
+ break;
+
default:
handled = false;
}
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index 35cfaf6d4a..d0828a69f6 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -222,23 +222,45 @@ void PopUpDialog::handleKeyDown(Common::KeyState state) {
return;
switch (state.keycode) {
+
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
setResult(_selection);
close();
break;
- case Common::KEYCODE_UP:
- moveUp();
+
+ // Keypad & special keys
+ // - if num lock is set, we ignore the keypress
+ // - if num lock is not set, we fall down to the special key case
+
+ case Common::KEYCODE_KP1:
+ if (state.flags & Common::KBD_NUM)
+ break;
+ case Common::KEYCODE_END:
+ setSelection(_popUpBoss->_entries.size()-1);
break;
+
+ case Common::KEYCODE_KP2:
+ if (state.flags & Common::KBD_NUM)
+ break;
case Common::KEYCODE_DOWN:
moveDown();
break;
+
+ case Common::KEYCODE_KP7:
+ if (state.flags & Common::KBD_NUM)
+ break;
case Common::KEYCODE_HOME:
setSelection(0);
break;
- case Common::KEYCODE_END:
- setSelection(_popUpBoss->_entries.size()-1);
+
+ case Common::KEYCODE_KP8:
+ if (state.flags & Common::KBD_NUM)
+ break;
+ case Common::KEYCODE_UP:
+ moveUp();
break;
+
default:
break;
}
diff --git a/gui/console.cpp b/gui/console.cpp
index 1316b59241..37d3bd6aa5 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -302,9 +302,11 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
slideUpAndClose();
break;
}
+
case Common::KEYCODE_ESCAPE:
slideUpAndClose();
break;
+
case Common::KEYCODE_BACKSPACE:
if (_caretVisible)
drawCaret(true);
@@ -316,8 +318,8 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
scrollToCurrent();
drawLine(pos2line(_currentPos));
break;
- case Common::KEYCODE_TAB:
- {
+
+ case Common::KEYCODE_TAB: {
if (_completionCallbackProc) {
int len = _currentPos - _promptStartPos;
assert(len >= 0);
@@ -339,24 +341,64 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
delete[] str;
}
break;
- }
+ }
+
+ // Keypad & special keys
+ // - if num lock is set, we always go to the default case
+ // - if num lock is not set, we either fall down to the special key case
+ // or ignore the key press in case of 0 (INSERT) or 5
+
+ case Common::KEYCODE_KP0:
+ case Common::KEYCODE_KP5:
+ if (state.flags & Common::KBD_NUM)
+ defaultKeyDownHandler(state);
+ break;
+
+ case Common::KEYCODE_KP_PERIOD:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
case Common::KEYCODE_DELETE:
if (_currentPos < _promptEndPos) {
killChar();
drawLine(pos2line(_currentPos));
}
break;
- case Common::KEYCODE_PAGEUP:
- if (state.flags == Common::KBD_SHIFT) {
- _scrollLine -= _linesPerPage - 1;
- if (_scrollLine < _firstLineInBuffer + _linesPerPage - 1)
- _scrollLine = _firstLineInBuffer + _linesPerPage - 1;
+
+ case Common::KEYCODE_KP1:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
+ case Common::KEYCODE_END:
+ if (state.hasFlags(Common::KBD_SHIFT)) {
+ _scrollLine = _promptEndPos / kCharsPerLine;
+ if (_scrollLine < _linesPerPage - 1)
+ _scrollLine = _linesPerPage - 1;
updateScrollBuffer();
- draw();
+ } else {
+ _currentPos = _promptEndPos;
}
+ draw();
break;
+
+ case Common::KEYCODE_KP2:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
+ case Common::KEYCODE_DOWN:
+ historyScroll(-1);
+ break;
+
+ case Common::KEYCODE_KP3:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
case Common::KEYCODE_PAGEDOWN:
- if (state.flags == Common::KBD_SHIFT) {
+ if (state.hasFlags(Common::KBD_SHIFT)) {
_scrollLine += _linesPerPage - 1;
if (_scrollLine > _promptEndPos / kCharsPerLine) {
_scrollLine = _promptEndPos / kCharsPerLine;
@@ -367,8 +409,36 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
draw();
}
break;
+
+ case Common::KEYCODE_KP4:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
+ case Common::KEYCODE_LEFT:
+ if (_currentPos > _promptStartPos)
+ _currentPos--;
+ drawLine(pos2line(_currentPos));
+ break;
+
+ case Common::KEYCODE_KP6:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
+ case Common::KEYCODE_RIGHT:
+ if (_currentPos < _promptEndPos)
+ _currentPos++;
+ drawLine(pos2line(_currentPos));
+ break;
+
+ case Common::KEYCODE_KP7:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
case Common::KEYCODE_HOME:
- if (state.flags == Common::KBD_SHIFT) {
+ if (state.hasFlags(Common::KBD_SHIFT)) {
_scrollLine = _firstLineInBuffer + _linesPerPage - 1;
updateScrollBuffer();
} else {
@@ -376,45 +446,47 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
}
draw();
break;
- case Common::KEYCODE_END:
- if (state.flags == Common::KBD_SHIFT) {
- _scrollLine = _promptEndPos / kCharsPerLine;
- if (_scrollLine < _linesPerPage - 1)
- _scrollLine = _linesPerPage - 1;
- updateScrollBuffer();
- } else {
- _currentPos = _promptEndPos;
+
+ case Common::KEYCODE_KP8:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
}
- draw();
- break;
case Common::KEYCODE_UP:
historyScroll(+1);
break;
- case Common::KEYCODE_DOWN:
- historyScroll(-1);
- break;
- case Common::KEYCODE_RIGHT:
- if (_currentPos < _promptEndPos)
- _currentPos++;
- drawLine(pos2line(_currentPos));
- break;
- case Common::KEYCODE_LEFT:
- if (_currentPos > _promptStartPos)
- _currentPos--;
- drawLine(pos2line(_currentPos));
+
+ case Common::KEYCODE_KP9:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state);
+ break;
+ }
+ case Common::KEYCODE_PAGEUP:
+ if (state.hasFlags(Common::KBD_SHIFT)) {
+ _scrollLine -= _linesPerPage - 1;
+ if (_scrollLine < _firstLineInBuffer + _linesPerPage - 1)
+ _scrollLine = _firstLineInBuffer + _linesPerPage - 1;
+ updateScrollBuffer();
+ draw();
+ }
break;
+
default:
- if (state.ascii == '~' || state.ascii == '#') {
- slideUpAndClose();
- } else if (state.flags == Common::KBD_CTRL) {
- specialKeys(state.keycode);
- } else if ((state.ascii >= 32 && state.ascii <= 127) || (state.ascii >= 160 && state.ascii <= 255)) {
- for (i = _promptEndPos - 1; i >= _currentPos; i--)
- buffer(i + 1) = buffer(i);
- _promptEndPos++;
- putchar((byte)state.ascii);
- scrollToCurrent();
- }
+ defaultKeyDownHandler(state);
+ }
+}
+
+void ConsoleDialog::defaultKeyDownHandler(Common::KeyState &state) {
+ if (state.ascii == '~' || state.ascii == '#') {
+ slideUpAndClose();
+ } else if (state.hasFlags(Common::KBD_CTRL)) {
+ specialKeys(state.keycode);
+ } else if ((state.ascii >= 32 && state.ascii <= 127) || (state.ascii >= 160 && state.ascii <= 255)) {
+ for (int i = _promptEndPos - 1; i >= _currentPos; i--)
+ buffer(i + 1) = buffer(i);
+ _promptEndPos++;
+ putchar((byte)state.ascii);
+ scrollToCurrent();
}
}
diff --git a/gui/console.h b/gui/console.h
index 52c3394184..bf44bdbe17 100644
--- a/gui/console.h
+++ b/gui/console.h
@@ -178,6 +178,8 @@ protected:
void updateScrollBuffer();
void scrollToCurrent();
+ void defaultKeyDownHandler(Common::KeyState &state);
+
// Line editing
void specialKeys(int keycode);
void nextLine();
diff --git a/gui/editable.cpp b/gui/editable.cpp
index 232873ffe3..aa95588da9 100644
--- a/gui/editable.cpp
+++ b/gui/editable.cpp
@@ -100,10 +100,12 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
endEditMode();
dirty = true;
break;
+
case Common::KEYCODE_ESCAPE:
abortEditMode();
dirty = true;
break;
+
case Common::KEYCODE_BACKSPACE:
if (_caretPos > 0) {
_caretPos--;
@@ -114,6 +116,28 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
}
forcecaret = true;
break;
+
+ // Keypad & special keys
+ // - if num lock is set, we always go to the default case
+ // - if num lock is not set, we either fall down to the special key case
+ // or ignore the key press in case of 0 (INSERT), 2 (DOWN), 3 (PGDWN)
+ // 5, 8 (UP) and 9 (PGUP)
+
+ case Common::KEYCODE_KP0:
+ case Common::KEYCODE_KP2:
+ case Common::KEYCODE_KP3:
+ case Common::KEYCODE_KP5:
+ case Common::KEYCODE_KP8:
+ case Common::KEYCODE_KP9:
+ if (state.flags & Common::KBD_NUM)
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ break;
+
+ case Common::KEYCODE_KP_PERIOD:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ break;
+ }
case Common::KEYCODE_DELETE:
if (_caretPos < (int)_editString.size()) {
_editString.deleteChar(_caretPos);
@@ -123,6 +147,22 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
}
forcecaret = true;
break;
+
+ case Common::KEYCODE_KP1:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ break;
+ }
+ case Common::KEYCODE_END:
+ dirty = setCaretPos(_editString.size());
+ forcecaret = true;
+ break;
+
+ case Common::KEYCODE_KP4:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ break;
+ }
case Common::KEYCODE_LEFT:
if (_caretPos > 0) {
dirty = setCaretPos(_caretPos - 1);
@@ -130,6 +170,12 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
forcecaret = true;
dirty = true;
break;
+
+ case Common::KEYCODE_KP6:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ break;
+ }
case Common::KEYCODE_RIGHT:
if (_caretPos < (int)_editString.size()) {
dirty = setCaretPos(_caretPos + 1);
@@ -137,24 +183,19 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
forcecaret = true;
dirty = true;
break;
+
+ case Common::KEYCODE_KP7:
+ if (state.flags & Common::KBD_NUM) {
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ break;
+ }
case Common::KEYCODE_HOME:
dirty = setCaretPos(0);
forcecaret = true;
break;
- case Common::KEYCODE_END:
- dirty = setCaretPos(_editString.size());
- forcecaret = true;
- break;
- default:
- if (tryInsertChar((byte)state.ascii, _caretPos)) {
- _caretPos++;
- dirty = true;
- forcecaret = true;
- sendCommand(_cmd, 0);
- } else {
- handled = false;
- }
+ default:
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
}
if (dirty)
@@ -166,6 +207,18 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
return handled;
}
+void EditableWidget::defaultKeyDownHandler(Common::KeyState &state, bool &dirty, bool &forcecaret, bool &handled) {
+ if (tryInsertChar((byte)state.ascii, _caretPos)) {
+ _caretPos++;
+ dirty = true;
+ forcecaret = true;
+
+ sendCommand(_cmd, 0);
+ } else {
+ handled = false;
+ }
+}
+
int EditableWidget::getCaretOffset() const {
int caretpos = 0;
for (int i = 0; i < _caretPos; i++)
diff --git a/gui/editable.h b/gui/editable.h
index 363ba7b9f6..00cb3431a5 100644
--- a/gui/editable.h
+++ b/gui/editable.h
@@ -81,6 +81,8 @@ protected:
bool adjustOffset();
void makeCaretVisible();
+ void defaultKeyDownHandler(Common::KeyState &state, bool &dirty, bool &forcecaret, bool &handled);
+
void setFontStyle(ThemeEngine::FontStyle font) { _font = font; }
virtual bool tryInsertChar(byte c, int pos);