aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
authorJohannes Schickel2009-07-25 01:01:05 +0000
committerJohannes Schickel2009-07-25 01:01:05 +0000
commitef7166740369bab9111289122aac3ef07c48c0bb (patch)
tree49c7385e3e9703b0831ea77980437aa254ffbe61 /backends/events
parenteeaafdf4ee012df99b5f4d0ea5b394ad81e1e23c (diff)
downloadscummvm-rg350-ef7166740369bab9111289122aac3ef07c48c0bb.tar.gz
scummvm-rg350-ef7166740369bab9111289122aac3ef07c48c0bb.tar.bz2
scummvm-rg350-ef7166740369bab9111289122aac3ef07c48c0bb.zip
- Adapt DefaultEventManager to use Common::ArtificialEventSource
- Adapt Keymapper to implement EventMapper interface svn-id: r42727
Diffstat (limited to 'backends/events')
-rw-r--r--backends/events/default/default-events.cpp20
-rw-r--r--backends/events/default/default-events.h21
2 files changed, 3 insertions, 38 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp
index cffc210aaf..8cbc44d052 100644
--- a/backends/events/default/default-events.cpp
+++ b/backends/events/default/default-events.cpp
@@ -206,14 +206,13 @@ DefaultEventManager::DefaultEventManager(Common::EventSource *boss) :
#endif
#ifdef ENABLE_KEYMAPPER
_keymapper = new Common::Keymapper(this);
+ // EventDispatcher will automatically free the keymapper
+ g_eventDispatcher.registerMapper(_keymapper);
_remap = false;
#endif
}
DefaultEventManager::~DefaultEventManager() {
-#ifdef ENABLE_KEYMAPPER
- delete _keymapper;
-#endif
#ifdef ENABLE_VKEYBD
delete _vk;
#endif
@@ -388,21 +387,6 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {
if (!_eventQueue.empty()) {
event = _eventQueue.pop();
result = true;
-
-#ifdef ENABLE_KEYMAPPER
- 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;
- }
- }
- }
-#endif
}
if (_recordMode != kPassthrough) {
diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h
index b8f47385a8..2f4f347e34 100644
--- a/backends/events/default/default-events.h
+++ b/backends/events/default/default-events.h
@@ -51,26 +51,7 @@ class DefaultEventManager : public Common::EventManager, Common::EventObserver {
bool _remap;
#endif
- // 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::ArtificialEventSource _artificialEventSource;
Common::Queue<Common::Event> _eventQueue;
bool notifyEvent(const Common::Event &ev) {