diff options
author | Stephen Kennedy | 2008-07-09 13:33:36 +0000 |
---|---|---|
committer | Stephen Kennedy | 2008-07-09 13:33:36 +0000 |
commit | 1f0b3ceb3633c75cd40f1eaacddeb73b5b8ec555 (patch) | |
tree | fdf661d07db016bf181a4c4b9ef65011842349f9 /backends/events/default | |
parent | b035101732407ae7595d80162346f995242654f2 (diff) | |
download | scummvm-rg350-1f0b3ceb3633c75cd40f1eaacddeb73b5b8ec555.tar.gz scummvm-rg350-1f0b3ceb3633c75cd40f1eaacddeb73b5b8ec555.tar.bz2 scummvm-rg350-1f0b3ceb3633c75cd40f1eaacddeb73b5b8ec555.zip |
Added pushEvent to EventManager (from cpage88's branch) and changed VirtualKeyboard so that it uses this method to feed key presses its resulting key press events.
svn-id: r32977
Diffstat (limited to 'backends/events/default')
-rw-r--r-- | backends/events/default/default-events.cpp | 20 | ||||
-rw-r--r-- | backends/events/default/default-events.h | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index edb8f662e8..d06edaec1b 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -31,6 +31,7 @@ #include "engines/engine.h" #include "gui/message.h" +#include "gui/newgui.h" #define RECORD_SIGNATURE 0x54455354 #define RECORD_VERSION 1 @@ -196,6 +197,7 @@ DefaultEventManager::DefaultEventManager(OSystem *boss) : } DefaultEventManager::~DefaultEventManager() { + delete _vk; _boss->lockMutex(_timeMutex); _boss->lockMutex(_recorderMutex); _recordMode = kPassthrough; @@ -351,10 +353,11 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { uint32 time = _boss->getMillis(); bool result; - // poll virtual keyboard - result = _vk->pollEvent(event); - // if no vk event, then poll backend - if (!result) result = _boss->pollEvent(event); + if (!_artificialEventQueue.empty()) { + event = _artificialEventQueue.pop(); + result = true; + } else + result = _boss->pollEvent(event); if (_recordMode != kPassthrough) { @@ -390,16 +393,17 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _keyRepeatTime = time + kKeyRepeatInitialDelay; #endif - // quick hack to show/hide keyboard + // HACK to show/hide keyboard (keyboard is not shown if gui is active) if (event.kbd.keycode == Common::KEYCODE_F6 && event.kbd.flags == 0) { if (_vk->isDisplaying()) { _vk->hide(); - } else { + } else if (!g_gui.isActive()) { if (!_vk->isLoaded()) _vk->loadKeyboardPack("test"); bool isPaused = (g_engine) ? g_engine->isPaused() : true; if (!isPaused) g_engine->pauseEngine(true); _vk->show(); if (!isPaused) g_engine->pauseEngine(false); + result = false; } } @@ -466,4 +470,8 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { return result; } +void DefaultEventManager::pushEvent(Common::Event event) { + _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 4472b1115f..e836160188 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -27,6 +27,7 @@ #define BACKEND_EVENTS_DEFAULT_H #include "common/events.h" +#include "common/queue.h" #include "common/savefile.h" #include "backends/common/virtual-keyboard.h" @@ -47,6 +48,8 @@ class DefaultEventManager : public Common::EventManager { Common::VirtualKeyboard *_vk; + Common::Queue<Common::Event> _artificialEventQueue; + Common::Point _mousePos; int _buttonState; int _modifierState; @@ -110,6 +113,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); |