diff options
-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; |