diff options
-rw-r--r-- | engines/kyra/gui.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/kyra.h | 3 | ||||
-rw-r--r-- | engines/sword2/controls.cpp | 12 | ||||
-rw-r--r-- | engines/sword2/screen.cpp | 2 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 10 | ||||
-rw-r--r-- | engines/sword2/sword2.h | 5 | ||||
-rw-r--r-- | engines/touche/ui.cpp | 2 |
7 files changed, 26 insertions, 26 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 18fdd4436d..8cafb54fb8 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -596,7 +596,7 @@ int KyraEngine::buttonMenuCallback(Button *caller) { calcCoords(_menu[i]); _menuRestoreScreen = true; - _keyPressed = 0; + _keyPressed.reset(); _mousePressFlag = false; _toplevelMenu = 0; @@ -826,7 +826,7 @@ void KyraEngine::gui_getInput() { _mouseWheel = 1; break; case Common::EVENT_KEYDOWN: - _keyPressed = event.kbd.ascii; + _keyPressed = event.kbd; break; default: break; @@ -1002,26 +1002,28 @@ void KyraEngine::gui_redrawTextfield() { void KyraEngine::gui_updateSavegameString() { int length; - if (_keyPressed) { + if (_keyPressed.keycode) { length = strlen(_savegameName); - if (_keyPressed > 31 && _keyPressed < 127) { + if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127) { if (length < 31) { - _savegameName[length] = _keyPressed; + _savegameName[length] = _keyPressed.ascii; _savegameName[length+1] = 0; gui_redrawTextfield(); } - } else if (_keyPressed == 8 ||_keyPressed == 127) { + } else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE || + _keyPressed.keycode == Common::KEYCODE_DELETE) { if (length > 0) { _savegameName[length-1] = 0; gui_redrawTextfield(); } - } else if (_keyPressed == 13) { + } else if (_keyPressed.keycode == Common::KEYCODE_RETURN || + _keyPressed.keycode == Common::KEYCODE_KP_ENTER) { _displaySubMenu = false; } } - _keyPressed = 0; + _keyPressed.reset(); } int KyraEngine::gui_saveGame(Button *button) { diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index 9d891ee511..bb41a68e6b 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -29,6 +29,7 @@ #include "engines/engine.h" #include "common/rect.h" #include "common/array.h" +#include "common/events.h" namespace Kyra { @@ -744,7 +745,7 @@ protected: int _gameToLoad; char _savegameName[31]; const char *_specialSavegameString; - uint8 _keyPressed; + Common::KeyState _keyPressed; struct KyragemState { uint16 nextOperation; diff --git a/engines/sword2/controls.cpp b/engines/sword2/controls.cpp index eeb2cda2d9..84580c7520 100644 --- a/engines/sword2/controls.cpp +++ b/engines/sword2/controls.cpp @@ -318,9 +318,9 @@ int Dialog::runModal() { KeyboardEvent *ke = _vm->keyboardEvent(); if (ke) { - if (ke->keycode == Common::KEYCODE_ESCAPE) + if (ke->kbd.keycode == Common::KEYCODE_ESCAPE) setResult(0); - else if (ke->keycode == Common::KEYCODE_RETURN || ke->keycode == Common::KEYCODE_KP_ENTER) + else if (ke->kbd.keycode == Common::KEYCODE_RETURN || ke->kbd.keycode == Common::KEYCODE_KP_ENTER) setResult(1); } @@ -1131,13 +1131,13 @@ public: virtual void onKey(KeyboardEvent *ke) { if (_editable) { - if (ke->keycode == Common::KEYCODE_BACKSPACE) + if (ke->kbd.keycode == Common::KEYCODE_BACKSPACE) _parent->onAction(this, Common::KEYCODE_BACKSPACE); - else if (ke->ascii >= ' ' && ke->ascii <= 255) { + else if (ke->kbd.ascii >= ' ' && ke->kbd.ascii <= 255) { // Accept the character if the font renderer // has what looks like a valid glyph for it. - if (_fr->getCharWidth(ke->ascii)) - _parent->onAction(this, ke->ascii); + if (_fr->getCharWidth(ke->kbd.ascii)) + _parent->onAction(this, ke->kbd.ascii); } } } diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp index 88850dd3b4..0a1b45d2de 100644 --- a/engines/sword2/screen.cpp +++ b/engines/sword2/screen.cpp @@ -1092,7 +1092,7 @@ void Screen::rollCredits() { KeyboardEvent *ke = _vm->keyboardEvent(); - if (ke && ke->keycode == Common::KEYCODE_ESCAPE) { + if (ke && ke->kbd.keycode == Common::KEYCODE_ESCAPE) { if (!abortCredits) { abortCredits = true; fadeDown(); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 22a2fcec45..8bf3467b86 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -381,10 +381,10 @@ int Sword2Engine::go() { KeyboardEvent *ke = keyboardEvent(); if (ke) { - if ((ke->modifiers == Common::KBD_CTRL && ke->keycode == Common::KEYCODE_d) || ke->ascii == '#' || ke->ascii == '~') { + if ((ke->kbd.flags == Common::KBD_CTRL && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') { _debugger->attach(); - } else if (ke->modifiers == 0 || ke->modifiers == Common::KBD_SHIFT) { - switch (ke->keycode) { + } else if (ke->kbd.flags == 0 || ke->kbd.flags == Common::KBD_SHIFT) { + switch (ke->kbd.keycode) { case Common::KEYCODE_p: if (_gamePaused) unpauseGame(); @@ -553,9 +553,7 @@ void Sword2Engine::parseInputEvents() { } if (!(_inputEventFilter & RD_KEYDOWN)) { _keyboardEvent.pending = true; - _keyboardEvent.ascii = event.kbd.ascii; - _keyboardEvent.keycode = event.kbd.keycode; - _keyboardEvent.modifiers = event.kbd.flags; + _keyboardEvent.kbd = event.kbd; } break; case Common::EVENT_LBUTTONDOWN: diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index b6d6c331f9..a9a1e21875 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -39,6 +39,7 @@ #include "engines/engine.h" +#include "common/events.h" #include "common/util.h" #define MAX_starts 100 @@ -79,9 +80,7 @@ struct MouseEvent { struct KeyboardEvent { bool pending; - uint16 ascii; - int keycode; - int modifiers; + Common::KeyState kbd; }; struct StartUp { diff --git a/engines/touche/ui.cpp b/engines/touche/ui.cpp index bf2fb747ab..ef8f5a0d7d 100644 --- a/engines/touche/ui.cpp +++ b/engines/touche/ui.cpp @@ -399,7 +399,7 @@ void ToucheEngine::handleOptions(int forceDisplay) { break; case Common::EVENT_KEYDOWN: if (menuData.mode == kMenuSaveStateMode) { - if (event.kbd.keycode == 8) { + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { menuData.removeLastCharFromDescription(_saveLoadCurrentSlot); } else { menuData.addCharToDescription(_saveLoadCurrentSlot, (char)event.kbd.ascii); |