From f97cbb8294eb35fbd3af38fbe37ac35a82c64121 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 00:05:32 +0000 Subject: Update GUI::Key constructs svn-id: r27643 --- backends/platform/sdl/events.cpp | 2 +- backends/platform/symbian/src/SymbianActions.cpp | 36 +++++++++++------------- backends/platform/wince/CEActionsPocket.cpp | 30 ++++++++++---------- backends/platform/wince/CEActionsSmartphone.cpp | 28 +++++++++--------- backends/platform/wince/CEgui/PanelKeyboard.cpp | 15 ++++------ backends/platform/wince/CEkeys/EventsBuffer.cpp | 7 ++--- backends/platform/wince/wince-sdl.cpp | 2 +- 7 files changed, 56 insertions(+), 64 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index 56636dfaa9..2b3c2c18fe 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -59,7 +59,7 @@ static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) return key; } else if (unicode) { return unicode; - } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) { + } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) { return key & ~0x20; } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { return 0; diff --git a/backends/platform/symbian/src/SymbianActions.cpp b/backends/platform/symbian/src/SymbianActions.cpp index 2c13a407ed..3809253032 100644 --- a/backends/platform/symbian/src/SymbianActions.cpp +++ b/backends/platform/symbian/src/SymbianActions.cpp @@ -122,7 +122,7 @@ void SymbianActions::initInstanceMain(OSystem *mainSystem) { // Skip _action_enabled[ACTION_SKIP] = true; - _key_action[ACTION_SKIP].setAscii(SDLK_ESCAPE); + _key_action[ACTION_SKIP].setKey(SDLK_ESCAPE); } void SymbianActions::initInstanceGame() { @@ -150,28 +150,27 @@ void SymbianActions::initInstanceGame() { _action_enabled[ACTION_SAVE] = true; if (is_queen) { - _key_action[ACTION_SAVE].setAscii(SDLK_F1); // F1 key for FOTAQ + _key_action[ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); // F1 key for FOTAQ } else if (is_sky) { - _key_action[ACTION_SAVE].setAscii(63); + _key_action[ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); } else if (is_cine) { - _key_action[ACTION_SAVE].setAscii(SDLK_F10); // F10 + _key_action[ACTION_SAVE].setKey(Common::ASCII_F10, SDLK_F10); // F10 } else if (is_agi) { - _key_action[ACTION_SAVE].setAscii(SDLK_ESCAPE); + _key_action[ACTION_SAVE].setKey(Common::ASCII_ESCAPE, SDLK_ESCAPE); } else if (is_parallaction) { - _key_action[ACTION_SAVE].setAscii(SDLK_s); + _key_action[ACTION_SAVE].setKey('s', SDLK_s); } else { - _key_action[ACTION_SAVE].setAscii(SDLK_F5); // F5 key + _key_action[ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); // F5 key } } // Enable fast mode _action_enabled[ACTION_FASTMODE] = true; - _key_action[ACTION_FASTMODE].setAscii('f'); - _key_action[ACTION_FASTMODE].setFlags(KMOD_CTRL); + _key_action[ACTION_FASTMODE].setKey('f', SDLK_f, KMOD_CTRL); // Swap character _action_enabled[ACTION_SWAPCHAR] = true; - _key_action[ACTION_SWAPCHAR].setAscii('b'); // b + _key_action[ACTION_SWAPCHAR].setKey('b'); // b // Zone _action_enabled[ACTION_ZONE] = true; @@ -179,31 +178,30 @@ void SymbianActions::initInstanceGame() { // Multi function key _action_enabled[ACTION_MULTI] = true; if (is_agi) - _key_action[ACTION_MULTI].setAscii(SDLK_PAUSE); // agi: show predictive dialog + _key_action[ACTION_MULTI].setKey(SDLK_PAUSE); // agi: show predictive dialog else if (is_gob) - _key_action[ACTION_MULTI].setAscii(315); // bargon : F1 to start + _key_action[ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1); // bargon : F1 to start else if (gameid == "atlantis") - _key_action[ACTION_MULTI].setAscii(SDLK_KP0); // fate of atlantis : Ins to sucker-punch + _key_action[ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch else - _key_action[ACTION_MULTI].setAscii(86); // FT cheat : shift-V + _key_action[ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V // Enable debugger _action_enabled[ACTION_DEBUGGER] = true; - _key_action[ACTION_DEBUGGER].setAscii('d'); - _key_action[ACTION_DEBUGGER].setFlags(KMOD_CTRL); + _key_action[ACTION_DEBUGGER].setKey('d', SDLK_d, KMOD_CTRL); // Skip text if (!is_cine) _action_enabled[ACTION_SKIP_TEXT] = true; if (is_queen) { - _key_action[ACTION_SKIP_TEXT].setAscii(SDLK_SPACE); + _key_action[ACTION_SKIP_TEXT].setKey(SDLK_SPACE); } else { - _key_action[ACTION_SKIP_TEXT].setAscii(SDLK_PERIOD); + _key_action[ACTION_SKIP_TEXT].setKey(SDLK_PERIOD); } // Pause - _key_action[ACTION_PAUSE].setAscii(' '); + _key_action[ACTION_PAUSE].setKey(' '); _action_enabled[ACTION_PAUSE] = true; // Quit diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp index 81de8e779c..efada68ad9 100644 --- a/backends/platform/wince/CEActionsPocket.cpp +++ b/backends/platform/wince/CEActionsPocket.cpp @@ -141,29 +141,29 @@ void CEActionsPocket::initInstanceGame() { // Initialize keys for different actions // Pause - _key_action[POCKET_ACTION_PAUSE].setAscii(VK_SPACE); + _key_action[POCKET_ACTION_PAUSE].setKey(VK_SPACE); _action_enabled[POCKET_ACTION_PAUSE] = true; // Save if (is_simon || is_sword2 || is_gob || is_kyra || is_touche) _action_enabled[POCKET_ACTION_SAVE] = false; else if (is_queen) { _action_enabled[POCKET_ACTION_SAVE] = true; - _key_action[POCKET_ACTION_SAVE].setAscii(286); // F1 key for FOTAQ + _key_action[POCKET_ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); // F1 key for FOTAQ } else if (is_sky) { _action_enabled[POCKET_ACTION_SAVE] = true; - _key_action[POCKET_ACTION_SAVE].setAscii(63); + _key_action[POCKET_ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); } else if (is_cine) { _action_enabled[POCKET_ACTION_SAVE] = true; - _key_action[POCKET_ACTION_SAVE].setAscii(291); // F10 + _key_action[POCKET_ACTION_SAVE].setKey(Common::ASCII_F10, SDLK_F10); // F10 } else if (is_agi) { _action_enabled[POCKET_ACTION_SAVE] = true; - _key_action[POCKET_ACTION_SAVE].setAscii(SDLK_ESCAPE); + _key_action[POCKET_ACTION_SAVE].setKey(Common::ASCII_ESCAPE, SDLK_ESCAPE); } else if (is_parallaction) { _action_enabled[POCKET_ACTION_SAVE] = true; - _key_action[POCKET_ACTION_SAVE].setAscii(SDLK_s); + _key_action[POCKET_ACTION_SAVE].setKey('s', SDLK_s); } else { _action_enabled[POCKET_ACTION_SAVE] = true; - _key_action[POCKET_ACTION_SAVE].setAscii(319); // F5 key + _key_action[POCKET_ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); // F5 key } // Quit _action_enabled[POCKET_ACTION_QUIT] = true; @@ -171,9 +171,9 @@ void CEActionsPocket::initInstanceGame() { if (!is_cine && !is_parallaction) _action_enabled[POCKET_ACTION_SKIP] = true; if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_saga || is_kyra || is_touche) - _key_action[POCKET_ACTION_SKIP].setAscii(VK_ESCAPE); + _key_action[POCKET_ACTION_SKIP].setKey(VK_ESCAPE); else - _key_action[POCKET_ACTION_SKIP].setAscii(KEY_ALL_SKIP); + _key_action[POCKET_ACTION_SKIP].setKey(KEY_ALL_SKIP); // Hide _action_enabled[POCKET_ACTION_HIDE] = true; // Keyboard @@ -195,13 +195,13 @@ void CEActionsPocket::initInstanceGame() { // Multi function key _action_enabled[POCKET_ACTION_MULTI] = true; if (is_agi) - _key_action[POCKET_ACTION_MULTI].setAscii(SDLK_PAUSE); // agi: show predictive dialog + _key_action[POCKET_ACTION_MULTI].setKey(SDLK_PAUSE); // agi: show predictive dialog else if (is_gob) - _key_action[POCKET_ACTION_MULTI].setAscii(315); // bargon : F1 to start + _key_action[POCKET_ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1); // bargon : F1 to start else if (gameid == "atlantis") - _key_action[POCKET_ACTION_MULTI].setAscii(SDLK_KP0); // fate of atlantis : Ins to sucker-punch + _key_action[POCKET_ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch else - _key_action[POCKET_ACTION_MULTI].setAscii(86); // FT cheat : shift-V + _key_action[POCKET_ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V // Key bind method _action_enabled[POCKET_ACTION_BINDKEYS] = true; } @@ -242,9 +242,9 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { // Note that the user can accomplish this via the virtual keyboard as well, this is just for convenience GUI::MessageDialog alert("Do you want to load or save the game?", "Load", "Save"); if (alert.runModal() == GUI::kMessageOK) - _key_action[action].setAscii(SDLK_l); + _key_action[action].setKey(SDLK_l); else - _key_action[action].setAscii(SDLK_s); + _key_action[action].setKey(SDLK_s); } EventsBuffer::simulateKey(&_key_action[action], true); return true; diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp index 55af5085a2..c92217b1b9 100644 --- a/backends/platform/wince/CEActionsSmartphone.cpp +++ b/backends/platform/wince/CEActionsSmartphone.cpp @@ -131,41 +131,41 @@ void CEActionsSmartphone::initInstanceGame() { _action_enabled[SMARTPHONE_ACTION_SAVE] = false; else if (is_queen) { _action_enabled[SMARTPHONE_ACTION_SAVE] = true; - _key_action[SMARTPHONE_ACTION_SAVE].setAscii(SDLK_F5); // F1 key for FOTAQ + _key_action[SMARTPHONE_ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); // F1 key for FOTAQ } else if (is_sky) { _action_enabled[SMARTPHONE_ACTION_SAVE] = true; - _key_action[SMARTPHONE_ACTION_SAVE].setAscii(SDLK_QUESTION); + _key_action[SMARTPHONE_ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); } else if (is_cine) { _action_enabled[SMARTPHONE_ACTION_SAVE] = true; - _key_action[SMARTPHONE_ACTION_SAVE].setAscii(SDLK_F10); //F10 + _key_action[SMARTPHONE_ACTION_SAVE].setKey(Common::ASCII_F10, SDLK_F10); //F10 } else if (is_agi) { _action_enabled[SMARTPHONE_ACTION_SAVE] = true; - _key_action[SMARTPHONE_ACTION_SAVE].setAscii(SDLK_ESCAPE); + _key_action[SMARTPHONE_ACTION_SAVE].setKey(Common::ASCII_ESCAPE, SDLK_ESCAPE); } else if (is_parallaction) { _action_enabled[SMARTPHONE_ACTION_SAVE] = true; - _key_action[SMARTPHONE_ACTION_SAVE].setAscii(SDLK_s); + _key_action[SMARTPHONE_ACTION_SAVE].setKey('s', SDLK_s); } else { _action_enabled[SMARTPHONE_ACTION_SAVE] = true; - _key_action[SMARTPHONE_ACTION_SAVE].setAscii(Common::ASCII_F5); // F5 key + _key_action[SMARTPHONE_ACTION_SAVE].setKey(Common::ASCII_F5, SDLK_F5); // F5 key } // Skip _action_enabled[SMARTPHONE_ACTION_SKIP] = true; if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_saga || is_kyra || is_touche) - _key_action[SMARTPHONE_ACTION_SKIP].setAscii(VK_ESCAPE); + _key_action[SMARTPHONE_ACTION_SKIP].setKey(VK_ESCAPE); else - _key_action[SMARTPHONE_ACTION_SKIP].setAscii(KEY_ALL_SKIP); + _key_action[SMARTPHONE_ACTION_SKIP].setKey(KEY_ALL_SKIP); // Zone _action_enabled[SMARTPHONE_ACTION_ZONE] = true; // Multi function key _action_enabled[SMARTPHONE_ACTION_MULTI] = true; if (is_agi) - _key_action[SMARTPHONE_ACTION_MULTI].setAscii(SDLK_PAUSE); // agi: show predictive dialog + _key_action[SMARTPHONE_ACTION_MULTI].setKey(SDLK_PAUSE); // agi: show predictive dialog else if (is_gob) - _key_action[SMARTPHONE_ACTION_MULTI].setAscii(Common::ASCII_F1); // bargon : F1 to start + _key_action[SMARTPHONE_ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1) // bargon : F1 to start else if (gameid == "atlantis") - _key_action[SMARTPHONE_ACTION_MULTI].setAscii(SDLK_KP0); // fate of atlantis : Ins to sucker-punch + _key_action[SMARTPHONE_ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch else - _key_action[SMARTPHONE_ACTION_MULTI].setAscii(86); // FT cheat : shift-V + _key_action[SMARTPHONE_ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V // Bind keys _action_enabled[SMARTPHONE_ACTION_BINDKEYS] = true; } @@ -203,9 +203,9 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) { // Note that the user can accomplish this via the virtual keyboard as well, this is just for convenience GUI::MessageDialog alert("Do you want to load or save the game?", "Load", "Save"); if (alert.runModal() == GUI::kMessageOK) - _key_action[action].setAscii(SDLK_l); + _key_action[action].setKey(SDLK_l); else - _key_action[action].setAscii(SDLK_s); + _key_action[action].setKey(SDLK_s); } EventsBuffer::simulateKey(&_key_action[action], true); return true; diff --git a/backends/platform/wince/CEgui/PanelKeyboard.cpp b/backends/platform/wince/CEgui/PanelKeyboard.cpp index fdbb3b4e32..79b833f84b 100644 --- a/backends/platform/wince/CEgui/PanelKeyboard.cpp +++ b/backends/platform/wince/CEgui/PanelKeyboard.cpp @@ -36,8 +36,7 @@ namespace CEGUI { PanelKeyboard::PanelKeyboard(WORD reference) : Toolbar() { setBackground(reference); _state = false; - _lastKey.setAscii(0); - _lastKey.setKeycode(0); + _lastKey.setKey(0); } @@ -78,25 +77,21 @@ namespace CEGUI { keyCode = _lastKey.keycode(); } _state = pushed; - _lastKey.setAscii(keyAscii); - _lastKey.setKeycode(tolower(keyCode)); + _lastKey.setKey(keyAscii, tolower(keyCode)); - key.setAscii(keyAscii); - key.setKeycode(tolower(keyCode)); + key.setKey(keyAscii, tolower(keyCode)); return EventsBuffer::simulateKey(&key, pushed); } else if (_state && !pushed) { // cursor is in some forbidden region and is up _state = false; - key.setAscii(_lastKey.ascii()); - key.setKeycode(_lastKey.keycode()); + key = _lastKey; return EventsBuffer::simulateKey(&key, false); } else return false; } else if (_state && !pushed) { // cursor left the keyboard area and is up _state = false; - key.setAscii(_lastKey.ascii()); - key.setKeycode(_lastKey.keycode()); + key = _lastKey; return EventsBuffer::simulateKey(&key, false); } else return false; diff --git a/backends/platform/wince/CEkeys/EventsBuffer.cpp b/backends/platform/wince/CEkeys/EventsBuffer.cpp index c8b09f611a..19978c23dc 100644 --- a/backends/platform/wince/CEkeys/EventsBuffer.cpp +++ b/backends/platform/wince/CEkeys/EventsBuffer.cpp @@ -32,10 +32,9 @@ namespace CEKEYS { SDL_Event ev = {0}; if (!key->keycode()) - key->setKeycode(key->ascii()); - - if (!key->ascii()) - key->setAscii(key->keycode()); + key->setKey(key->ascii(), key->ascii()); + else if (!key->ascii()) + key->setKey(key->keycode()); ev.type = (pushed ? SDL_KEYDOWN : SDL_KEYUP); ev.key.keysym.mod = (SDLMod)key->flags(); diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 92012c7159..c8aa6de838 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -2105,7 +2105,7 @@ static int mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode, bool unfilter) return key; } else if (unicode) { return unicode; - } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) { + } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) { return key & ~0x20; } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { return 0; -- cgit v1.2.3