diff options
author | Max Horn | 2007-06-22 22:18:56 +0000 |
---|---|---|
committer | Max Horn | 2007-06-22 22:18:56 +0000 |
commit | 05ca0d86ba28ffa724b30c309943fa02eda124b9 (patch) | |
tree | bef22eced95c0a70a403e113007bc1d2a1b6e0e8 /engines | |
parent | c690cad67f91fea90be949e29b2d218952c79859 (diff) | |
download | scummvm-rg350-05ca0d86ba28ffa724b30c309943fa02eda124b9.tar.gz scummvm-rg350-05ca0d86ba28ffa724b30c309943fa02eda124b9.tar.bz2 scummvm-rg350-05ca0d86ba28ffa724b30c309943fa02eda124b9.zip |
Converted BASS to use Common::KeyState
svn-id: r27635
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sky/control.cpp | 32 | ||||
-rw-r--r-- | engines/sky/control.h | 5 | ||||
-rw-r--r-- | engines/sky/intro.cpp | 2 | ||||
-rw-r--r-- | engines/sky/mouse.cpp | 2 | ||||
-rw-r--r-- | engines/sky/sky.cpp | 32 | ||||
-rw-r--r-- | engines/sky/sky.h | 3 |
6 files changed, 33 insertions, 43 deletions
diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp index 04f6800aab..c03cf9688b 100644 --- a/engines/sky/control.cpp +++ b/engines/sky/control.cpp @@ -497,7 +497,7 @@ void Control::doControlPanel(void) { _system->updateScreen(); _mouseClicked = false; delay(50); - if (_keyPressed == 27) { // escape pressed + if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) { // escape pressed _mouseClicked = false; quitPanel = true; } @@ -841,7 +841,7 @@ bool Control::autoSaveExists(void) { uint16 Control::saveRestorePanel(bool allowSave) { - _keyPressed = 0; + _keyPressed.reset(); _mouseWheel = 0; buttonControl(NULL); _text->drawToScreen(WITH_MASK); // flush text restore buffer @@ -898,21 +898,21 @@ uint16 Control::saveRestorePanel(bool allowSave) { _system->updateScreen(); _mouseClicked = false; delay(50); - if (_keyPressed == 27) { // escape pressed + if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) { // escape pressed _mouseClicked = false; clickRes = CANCEL_PRESSED; quitPanel = true; - } else if ((_keyPressed == 13) || (_keyPressed == 15)) { + } else if ((_keyPressed.keycode == Common::KEYCODE_RETURN) || (_keyPressed.keycode == Common::KEYCODE_KP_ENTER)) { clickRes = handleClick(lookList[0]); if (clickRes == GAME_SAVED) saveDescriptions(saveGameTexts); quitPanel = true; _mouseClicked = false; - _keyPressed = 0; - } if (allowSave && _keyPressed) { + _keyPressed.reset(); + } if (allowSave && _keyPressed.keycode) { handleKeyPress(_keyPressed, _selectedGame * MAX_TEXT_LEN + saveGameTexts); refreshNames = true; - _keyPressed = 0; + _keyPressed.reset(); } if (_mouseWheel) { @@ -991,9 +991,9 @@ bool Control::checkKeyList(uint8 key) { return false; } -void Control::handleKeyPress(uint8 key, uint8 *textBuf) { +void Control::handleKeyPress(Common::KeyState kbd, uint8 *textBuf) { - if (key == 8) { // backspace + if (kbd.keycode == Common::KEYCODE_BACKSPACE) { // backspace for (uint8 cnt = 0; cnt < 6; cnt++) if (!textBuf[cnt]) return; @@ -1004,15 +1004,15 @@ void Control::handleKeyPress(uint8 key, uint8 *textBuf) { } else { if (_enteredTextWidth >= PAN_LINE_WIDTH - 10) return; - if (((key >= 'A') && (key <= 'Z')) || ((key >= 'a') && (key <= 'z')) || - ((key >= '0') && (key <= '9')) || checkKeyList(key)) { + if (((kbd.ascii >= 'A') && (kbd.ascii <= 'Z')) || ((kbd.ascii >= 'a') && (kbd.ascii <= 'z')) || + ((kbd.ascii >= '0') && (kbd.ascii <= '9')) || checkKeyList(kbd.ascii)) { uint8 strLen = 0; while (textBuf[0]) { textBuf++; strLen++; } if (strLen < MAX_TEXT_LEN) { - textBuf[0] = key; + textBuf[0] = kbd.ascii; textBuf[1] = 0; } } @@ -1556,18 +1556,14 @@ void Control::delay(unsigned int amount) { uint32 start = _system->getMillis(); uint32 cur = start; - _keyPressed = 0; //reset + _keyPressed.reset(); do { Common::EventManager *eventMan = _system->getEventManager(); while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: - // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == 8) - _keyPressed = 8; - else - _keyPressed = (byte)event.kbd.ascii; + _keyPressed = event.kbd; break; case Common::EVENT_MOUSEMOVE: if (!(SkyEngine::_systemVars.systemFlags & SF_MOUSE_LOCKED)) diff --git a/engines/sky/control.h b/engines/sky/control.h index ebf66a9e16..217ab5714a 100644 --- a/engines/sky/control.h +++ b/engines/sky/control.h @@ -27,6 +27,7 @@ #define SKY_CONTROL_H #include "common/stdafx.h" +#include "common/events.h" #include "common/scummsys.h" class OSystem; @@ -220,7 +221,7 @@ private: void setUpGameSprites(uint8 *nameBuf, dataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame); void showSprites(dataFileHeader **nameSprites, bool allowSave); bool checkKeyList(uint8 key); - void handleKeyPress(uint8 key, uint8 *textBuf); + void handleKeyPress(Common::KeyState kbd, uint8 *textBuf); uint16 _selectedGame; uint16 saveGameToFile(void); @@ -243,7 +244,7 @@ private: Sound *_skySound; OSystem *_system; bool _mouseClicked; - byte _keyPressed; + Common::KeyState _keyPressed; int _mouseWheel; struct { diff --git a/engines/sky/intro.cpp b/engines/sky/intro.cpp index 482dc623cc..6d841495af 100644 --- a/engines/sky/intro.cpp +++ b/engines/sky/intro.cpp @@ -917,7 +917,7 @@ bool Intro::escDelay(uint32 msecs) { do { while (eventMan->pollEvent(event)) { if (event.type == Common::EVENT_KEYDOWN) { - if (event.kbd.keycode == 27) + if (event.kbd.keycode == Common::KEYCODE_ESCAPE) return false; } else if (event.type == Common::EVENT_QUIT) { _quitProg = true; diff --git a/engines/sky/mouse.cpp b/engines/sky/mouse.cpp index c18eb6d901..524005b7e3 100644 --- a/engines/sky/mouse.cpp +++ b/engines/sky/mouse.cpp @@ -191,7 +191,7 @@ void Mouse::waitMouseNotPressed(int minDelay) { while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: - if (event.kbd.ascii == 27) { + if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { minDelay = 0; mousePressed = false; } diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp index 84038990aa..181d67cbf4 100644 --- a/engines/sky/sky.cpp +++ b/engines/sky/sky.cpp @@ -217,33 +217,29 @@ void SkyEngine::initVirgin() { void SkyEngine::handleKey(void) { - if (_keyPressed && _systemVars.paused) { + if (_keyPressed.keycode && _systemVars.paused) { _skySound->fnUnPauseFx(); _systemVars.paused = false; _skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette)); - _keyFlags = _keyPressed = 0; - return; - } - - if (_keyFlags == Common::KBD_CTRL) { - if (_keyPressed == 'f') + } else if (_keyPressed.flags == Common::KBD_CTRL) { + if (_keyPressed.keycode == 'f') _fastMode ^= 1; - else if (_keyPressed == 'g') + else if (_keyPressed.keycode == 'g') _fastMode ^= 2; - else if (_keyPressed == 'd') + else if (_keyPressed.keycode == 'd') _debugger->attach(); } else { - switch (_keyPressed) { + switch (_keyPressed.ascii) { case '`': case '~': case '#': _debugger->attach(); break; - case 63: + case Common::ASCII_F5: _skyControl->doControlPanel(); break; - case 27: + case Common::ASCII_ESCAPE: if (!_systemVars.pastIntro) _skyControl->restartGame(); break; @@ -260,14 +256,14 @@ void SkyEngine::handleKey(void) { } } - _keyFlags = _keyPressed = 0; + _keyPressed.reset(); } int SkyEngine::go() { _systemVars.quitGame = false; - _keyFlags = _keyPressed = 0; + _keyPressed.reset(); uint16 result = 0; if (ConfMan.hasKey("save_slot") && ConfMan.getInt("save_slot") >= 0) @@ -517,7 +513,7 @@ void SkyEngine::delay(int32 amount) { Common::Event event; uint32 start = _system->getMillis(); - _keyFlags = _keyPressed = 0; //reset + _keyPressed.reset(); if (amount < 0) amount = 0; @@ -526,11 +522,7 @@ void SkyEngine::delay(int32 amount) { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: - _keyFlags = event.kbd.flags; - if (_keyFlags == Common::KBD_CTRL) - _keyPressed = event.kbd.keycode; - else - _keyPressed = (byte)event.kbd.ascii; + _keyPressed = event.kbd; break; case Common::EVENT_MOUSEMOVE: if (!(_systemVars.systemFlags & SF_MOUSE_LOCKED)) diff --git a/engines/sky/sky.h b/engines/sky/sky.h index bc76e37eef..002964d6bb 100644 --- a/engines/sky/sky.h +++ b/engines/sky/sky.h @@ -27,6 +27,7 @@ #define SKY_H #include "common/stdafx.h" +#include "common/events.h" #include "engines/engine.h" namespace Sky { @@ -60,7 +61,7 @@ class SkyCompact; class SkyEngine : public Engine { GUI::Debugger *getDebugger(); protected: - byte _keyPressed, _keyFlags; + Common::KeyState _keyPressed; bool _floppyIntro; Sound *_skySound; |