diff options
author | Stephen Kennedy | 2008-07-23 08:45:12 +0000 |
---|---|---|
committer | Stephen Kennedy | 2008-07-23 08:45:12 +0000 |
commit | 2f064da1021344f28c9106285475c72930638390 (patch) | |
tree | d636949ffff9972e30511446d79ff3a8d4369b81 /backends/events/default | |
parent | 0861fa4c00f0ecb82f3607127c8278d55f95376c (diff) | |
download | scummvm-rg350-2f064da1021344f28c9106285475c72930638390.tar.gz scummvm-rg350-2f064da1021344f28c9106285475c72930638390.tar.bz2 scummvm-rg350-2f064da1021344f28c9106285475c72930638390.zip |
Most of Keymapper class complete
DefaultEventManager now initialises Keymapper and passes key press events to it
svn-id: r33227
Diffstat (limited to 'backends/events/default')
-rw-r--r-- | backends/events/default/default-events.cpp | 25 | ||||
-rw-r--r-- | backends/events/default/default-events.h | 4 |
2 files changed, 23 insertions, 6 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 3a77b0114c..685f2bac89 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -107,6 +107,7 @@ DefaultEventManager::DefaultEventManager(OSystem *boss) : _eventCount = 0; _lastEventCount = 0; _lastMillis = 0; + _artificialEventCounter = 0; Common::String recordModeString = ConfMan.get("record_mode"); if (recordModeString.compareToIgnoreCase("record") == 0) { @@ -193,7 +194,7 @@ DefaultEventManager::DefaultEventManager(OSystem *boss) : } _vk = new Common::VirtualKeyboard(); - _artificialEventCounter = 0; + _keyMapper = new Common::Keymapper(this); } DefaultEventManager::~DefaultEventManager() { @@ -351,18 +352,32 @@ void DefaultEventManager::processMillis(uint32 &millis) { bool DefaultEventManager::pollEvent(Common::Event &event) { uint32 time = _boss->getMillis(); - bool result; + bool result = false; + // poll for pushed events if (!_artificialEventQueue.empty()) { // delay the feeding of artificial events if (++_artificialEventCounter % kArtificialEventDelay == 0) { event = _artificialEventQueue.pop(); result = true; _artificialEventCounter = 0; - } else - result = _boss->pollEvent(event); - } else + } + } + + // poll for event from backend + if (!result) { 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) { diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index 891ee3e744..e018657977 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -29,6 +29,7 @@ #include "common/events.h" #include "common/queue.h" #include "common/savefile.h" +#include "backends/common/keymapper.h" #include "backends/common/virtual-keyboard.h" /* @@ -47,11 +48,12 @@ class DefaultEventManager : public Common::EventManager { OSystem *_boss; Common::VirtualKeyboard *_vk; + Common::Keymapper *_keyMapper; Common::Queue<Common::Event> _artificialEventQueue; int _artificialEventCounter; enum { - kArtificialEventDelay = 10 + kArtificialEventDelay = 5 }; Common::Point _mousePos; |