diff options
Diffstat (limited to 'backends/events/default/default-events.cpp')
-rw-r--r-- | backends/events/default/default-events.cpp | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index c503e6a536..a2616bc58a 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -28,6 +28,9 @@ #include "common/system.h" #include "common/config-manager.h" #include "backends/events/default/default-events.h" +#include "backends/keymapper/keymapper.h" +#include "backends/keymapper/remap-dialog.h" +#include "backends/vkeybd/virtual-keyboard.h" #include "engines/engine.h" #include "gui/message.h" @@ -192,9 +195,17 @@ DefaultEventManager::DefaultEventManager(OSystem *boss) : _hasPlaybackEvent = false; } + + _vk = new Common::VirtualKeyboard(); + _keymapper = new Common::Keymapper(this); + _remap = false; + + //init(); } DefaultEventManager::~DefaultEventManager() { + delete _keymapper; + delete _vk; _boss->lockMutex(_timeMutex); _boss->lockMutex(_recorderMutex); _recordMode = kPassthrough; @@ -253,6 +264,14 @@ DefaultEventManager::~DefaultEventManager() { _boss->deleteMutex(_recorderMutex); } +void DefaultEventManager::init() { + if (ConfMan.hasKey("vkeybd_pack_name")) { + _vk->loadKeyboardPack(ConfMan.get("vkeybd_pack_name")); + } else { + _vk->loadKeyboardPack("vkeybd"); + } +} + bool DefaultEventManager::playback(Common::Event &event) { if (!_hasPlaybackEvent) { @@ -351,13 +370,28 @@ void DefaultEventManager::processMillis(uint32 &millis) { bool DefaultEventManager::pollEvent(Common::Event &event) { uint32 time = _boss->getMillis(); - bool result; - - if (!artificialEventQueue.empty()) { - event = artificialEventQueue.pop(); + bool result = false; + + // poll for pushed events + if (!_artificialEventQueue.empty()) { + event = _artificialEventQueue.pop(); result = true; - } else + } else { + // poll for event from backend result = _boss->pollEvent(event); + if (result) { + // send key press events to keymapper + if (event.type == Common::EVENT_KEYDOWN) { + if (_keymapper->mapKeyDown(event.kbd)) { + result = false; + } + } else if (event.type == Common::EVENT_KEYUP) { + if (_keymapper->mapKeyUp(event.kbd)) { + result = false; + } + } + } + } if (_recordMode != kPassthrough) { @@ -423,6 +457,26 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { else if (_shouldRTL) event.type = Common::EVENT_RTL; } + } else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.flags == 0) { + if (_vk->isDisplaying()) { + _vk->close(true); + } else { + bool isPaused = (g_engine) ? g_engine->isPaused() : true; + if (!isPaused) g_engine->pauseEngine(true); + _vk->show(); + if (!isPaused) g_engine->pauseEngine(false); + result = false; + } + } else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.flags == 0) { + if (!_remap) { + _remap = true; + Common::RemapDialog _remapDialog; + bool isPaused = (g_engine) ? g_engine->isPaused() : true; + if (!isPaused) g_engine->pauseEngine(true); + _remapDialog.runModal(); + if (!isPaused) g_engine->pauseEngine(false); + _remap = false; + } } break; @@ -505,7 +559,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { return result; } -void DefaultEventManager::pushEvent(Common::Event event) { +void DefaultEventManager::pushEvent(const Common::Event &event) { // If already received an EVENT_QUIT, don't add another one if (event.type == Common::EVENT_QUIT) { |