diff options
author | Max Horn | 2008-09-01 17:30:03 +0000 |
---|---|---|
committer | Max Horn | 2008-09-01 17:30:03 +0000 |
commit | 027ae0a6f6bd7e7dfbfe6f7df0824596894f51ae (patch) | |
tree | 205993ffb25dcb2311e62b1871431eb6cf62185e /backends/events | |
parent | 2db5747642446bad3e1824afd0358f51c1965c20 (diff) | |
parent | 852bc9dbb750b9995d31e70f4158c97d3758c46f (diff) | |
download | scummvm-rg350-027ae0a6f6bd7e7dfbfe6f7df0824596894f51ae.tar.gz scummvm-rg350-027ae0a6f6bd7e7dfbfe6f7df0824596894f51ae.tar.bz2 scummvm-rg350-027ae0a6f6bd7e7dfbfe6f7df0824596894f51ae.zip |
First part of GSoC2008 RTL branch merge
svn-id: r34241
Diffstat (limited to 'backends/events')
-rw-r--r-- | backends/events/default/default-events.cpp | 60 | ||||
-rw-r--r-- | backends/events/default/default-events.h | 4 |
2 files changed, 61 insertions, 3 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 0caba25792..65b375605b 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -93,7 +93,8 @@ DefaultEventManager::DefaultEventManager(OSystem *boss) : _boss(boss), _buttonState(0), _modifierState(0), - _shouldQuit(false) { + _shouldQuit(false), + _shouldRTL(false) { assert(_boss); @@ -200,6 +201,9 @@ DefaultEventManager::~DefaultEventManager() { _boss->unlockMutex(_timeMutex); _boss->unlockMutex(_recorderMutex); + if (!artificialEventQueue.empty()) + artificialEventQueue.clear(); + if (_playbackFile != NULL) { delete _playbackFile; } @@ -349,7 +353,11 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { uint32 time = _boss->getMillis(); bool result; - result = _boss->pollEvent(event); + if (!artificialEventQueue.empty()) { + event = artificialEventQueue.pop(); + result = true; + } else + result = _boss->pollEvent(event); if (_recordMode != kPassthrough) { @@ -375,7 +383,6 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { switch (event.type) { case Common::EVENT_KEYDOWN: _modifierState = event.kbd.flags; - // init continuous event stream // not done on PalmOS because keyboard is emulated and keyup is not generated #if !defined(PALMOS_MODE) @@ -384,7 +391,27 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _currentKeyDown.flags = event.kbd.flags; _keyRepeatTime = time + kKeyRepeatInitialDelay; #endif + // Global Main Menu + // FIXME: F6 is not the best trigger, it conflicts with some games!!! + if (event.kbd.keycode == Common::KEYCODE_F6) + if (g_engine && !g_engine->isPaused()) { + Common::Event menuEvent; + menuEvent.type = Common::EVENT_MAINMENU; + + // FIXME: GSoC RTL branch passes the F6 key event to the + // engine, and also enqueues a EVENT_MAINMENU. For now, + // we just drop the key event and return an EVENT_MAINMENU + // instead. This way, we don't have to add special cases + // to engines (like it was the case for LURE in the RTL branch). + // + // However, this has other consequences, possibly negative ones. + // Like, what happens with key repeat for the trigger key? + + //pushEvent(menuEvent); + event = menuEvent; + } break; + case Common::EVENT_KEYUP: _modifierState = event.kbd.flags; if (event.kbd.keycode == _currentKeyDown.keycode) { @@ -401,6 +428,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _mousePos = event.mouse; _buttonState |= LBUTTON; break; + case Common::EVENT_LBUTTONUP: _mousePos = event.mouse; _buttonState &= ~LBUTTON; @@ -410,11 +438,26 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _mousePos = event.mouse; _buttonState |= RBUTTON; break; + case Common::EVENT_RBUTTONUP: _mousePos = event.mouse; _buttonState &= ~RBUTTON; break; + case Common::EVENT_MAINMENU: + if (g_engine && !g_engine->isPaused()) + g_engine->mainMenuDialog(); + + if (_shouldQuit) + event.type = Common::EVENT_QUIT; + else if (_shouldRTL) + event.type = Common::EVENT_RTL; + break; + + case Common::EVENT_RTL: + _shouldRTL = true; + break; + case Common::EVENT_QUIT: if (ConfMan.getBool("confirm_exit")) { if (g_engine) @@ -425,6 +468,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { g_engine->pauseEngine(false); } else _shouldQuit = true; + break; default: @@ -447,4 +491,14 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { return result; } +void DefaultEventManager::pushEvent(Common::Event event) { + + // If already received an EVENT_QUIT, don't add another one + if (event.type == Common::EVENT_QUIT) { + if (!_shouldQuit) + artificialEventQueue.push(event); + } else + artificialEventQueue.push(event); +} + #endif // !defined(DISABLE_DEFAULT_EVENTMANAGER) diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index 98dcd4b3de..b2cd1354cc 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -48,6 +48,7 @@ class DefaultEventManager : public Common::EventManager { int _buttonState; int _modifierState; bool _shouldQuit; + bool _shouldRTL; class RandomSourceRecord { public: @@ -107,6 +108,7 @@ public: ~DefaultEventManager(); virtual bool pollEvent(Common::Event &event); + virtual void pushEvent(Common::Event event); virtual void registerRandomSource(Common::RandomSource &rnd, const char *name); virtual void processMillis(uint32 &millis); @@ -114,6 +116,8 @@ public: virtual int getButtonState() const { return _buttonState; } virtual int getModifierState() const { return _modifierState; } virtual int shouldQuit() const { return _shouldQuit; } + virtual int shouldRTL() const { return _shouldRTL; } + virtual void resetRTL() { _shouldRTL = false; } }; #endif |