diff options
author | Johannes Schickel | 2009-07-25 00:59:53 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-07-25 00:59:53 +0000 |
commit | 60e7faf9b6026d73ffb0709dfab44f734fdba332 (patch) | |
tree | e244af82ac882fd75920025743ea8837da4fa58c /backends/events/default | |
parent | f03753672665aea4015646045bbe255de7f55021 (diff) | |
download | scummvm-rg350-60e7faf9b6026d73ffb0709dfab44f734fdba332.tar.gz scummvm-rg350-60e7faf9b6026d73ffb0709dfab44f734fdba332.tar.bz2 scummvm-rg350-60e7faf9b6026d73ffb0709dfab44f734fdba332.zip |
Replaced "_artificialEventQueue" by an EventSource.
svn-id: r42722
Diffstat (limited to 'backends/events/default')
-rw-r--r-- | backends/events/default/default-events.cpp | 7 | ||||
-rw-r--r-- | backends/events/default/default-events.h | 21 |
2 files changed, 23 insertions, 5 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 7e9d8db66e..799ac6ec14 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -380,8 +380,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { uint32 time = g_system->getMillis(); bool result; - if (!_artificialEventQueue.empty()) { - event = _artificialEventQueue.pop(); + if (_artificialEventSource.pollEvent(event)) { result = true; } else { result = _boss->pollEvent(event); @@ -599,9 +598,9 @@ void DefaultEventManager::pushEvent(const 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); + _artificialEventSource.addEvent(event); } else - _artificialEventQueue.push(event); + _artificialEventSource.addEvent(event); } #endif // !defined(DISABLE_DEFAULT_EVENTMANAGER) diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index 9be90f4ad8..4124dd956b 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -53,7 +53,26 @@ class DefaultEventManager : public Common::EventManager { bool _remap; #endif - Common::Queue<Common::Event> _artificialEventQueue; + // TODO: Maybe move this to common/events.h, when other code uses something similar + class ArtificialEventSource : public Common::EventSource { + private: + Common::Queue<Common::Event> _artificialEventQueue; + public: + void addEvent(const Common::Event &ev) { + _artificialEventQueue.push(ev); + } + + bool pollEvent(Common::Event &ev) { + if (!_artificialEventQueue.empty()) { + ev = _artificialEventQueue.pop(); + return true; + } else { + return false; + } + } + + bool allowMapping() const { return false; } + } _artificialEventSource; Common::Point _mousePos; int _buttonState; |