aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
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) {