diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 13677a6d90a..8f8b2bdd29f 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -190,7 +190,7 @@ MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) { bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) { #ifdef ENABLE_KEYMAPPER - if (event.type != Common::EVENT_CUSTOM_BACKEND_ACTION) + if (event.type != Common::EVENT_CUSTOM_BACKEND_ACTION_START) return false; if (event.customType == kEventClickMode) { assert(_eventSource); diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 7de4b1bfb18..d7c086940f8 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -183,20 +183,20 @@ List Keymapper::mapEvent(const Event &ev) { Keymapper::IncomingEventType Keymapper::convertToIncomingEventType(const Event &ev) const { if (ev.type == EVENT_CUSTOM_BACKEND_HARDWARE) { - return kIncomingNonKey; + return kIncomingEventInstant; } else if (ev.type == EVENT_KEYDOWN) { - return kIncomingKeyDown; + return kIncomingEventStart; } else { - return kIncomingKeyUp; + return kIncomingEventEnd; } } Event Keymapper::executeAction(const Action *action, IncomingEventType incomingType) { Event evt = Event(action->event); - EventType convertedType = convertDownToUp(evt.type); + EventType convertedType = convertStartToEnd(evt.type); // hardware keys need to send up instead when they are up - if (incomingType == kIncomingKeyUp) { + if (incomingType == kIncomingEventEnd) { evt.type = convertedType; } @@ -204,7 +204,7 @@ Event Keymapper::executeAction(const Action *action, IncomingEventType incomingT // Check if the event is coming from a non-key hardware event // that is mapped to a key event - if (incomingType == kIncomingNonKey && convertedType != EVENT_INVALID) { + if (incomingType == kIncomingEventInstant && convertedType != EVENT_INVALID) { // WORKAROUND: Delay the down events coming from non-key hardware events // with a zero delay. This is to prevent DOWN1 DOWN2 UP1 UP2. addDelayedEvent(0, evt); @@ -220,7 +220,7 @@ Event Keymapper::executeAction(const Action *action, IncomingEventType incomingT return evt; } -EventType Keymapper::convertDownToUp(EventType type) { +EventType Keymapper::convertStartToEnd(EventType type) { EventType result = EVENT_INVALID; switch (type) { case EVENT_KEYDOWN: @@ -235,6 +235,9 @@ EventType Keymapper::convertDownToUp(EventType type) { case EVENT_MBUTTONDOWN: result = EVENT_MBUTTONUP; break; + case EVENT_CUSTOM_BACKEND_ACTION_START: + result = EVENT_CUSTOM_BACKEND_ACTION_END; + break; default: break; } diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 920de701b88..3c89ce7d5b0 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -129,16 +129,16 @@ public: private: enum IncomingEventType { - kIncomingKeyDown, - kIncomingKeyUp, - kIncomingNonKey + kIncomingEventStart, + kIncomingEventEnd, + kIncomingEventInstant }; HardwareInputSet *_hardwareInputs; const KeymapperDefaultBindings *_backendDefaultBindings; Event executeAction(const Action *act, IncomingEventType incomingType); - EventType convertDownToUp(EventType eventType); + EventType convertStartToEnd(EventType eventType); IncomingEventType convertToIncomingEventType(const Event &ev) const; EventManager *_eventMan; diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index e0cf0e6029d..60a940c71df 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -204,7 +204,7 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { act = new Action("CLKM", _("Click Mode")); Event evt = Event(); - evt.type = EVENT_CUSTOM_BACKEND_ACTION; + evt.type = EVENT_CUSTOM_BACKEND_ACTION_START; evt.customType = Maemo::kEventClickMode; act->setEvent(evt); globalMap->addAction(act); diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index c8d8a459aeb..f3801464f49 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -56,6 +56,11 @@ void EventDispatcher::dispatch() { if (i->source->allowMapping()) { assert(_mapper); + // Backends may not produce directly action event types, those are meant + // to be the output of the event mapper. + assert(event.type != EVENT_CUSTOM_BACKEND_ACTION_START); + assert(event.type != EVENT_CUSTOM_BACKEND_ACTION_END); + List mappedEvents = _mapper->mapEvent(event); for (List::iterator j = mappedEvents.begin(); j != mappedEvents.end(); ++j) { diff --git a/common/events.h b/common/events.h index c36c571c537..b392b6e2fc7 100644 --- a/common/events.h +++ b/common/events.h @@ -77,7 +77,8 @@ enum EventType { #ifdef ENABLE_KEYMAPPER // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use // this, please talk to tsoliman and/or LordHoto. - EVENT_CUSTOM_BACKEND_ACTION = 18, + EVENT_CUSTOM_BACKEND_ACTION_START = 18, + EVENT_CUSTOM_BACKEND_ACTION_END = 19, EVENT_CUSTOM_BACKEND_HARDWARE = 21, #endif #ifdef ENABLE_VKEYBD