From e7ade8ae05aff3669059e6003e046d1ef6e914a3 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 12:17:51 -0600 Subject: KEYMAPPER: EventMapper must now eat all events --- common/EventDispatcher.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'common/EventDispatcher.cpp') diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index 4e3f671cfd..55eea9c7b2 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -21,6 +21,7 @@ */ #include "common/events.h" +#include "common/textconsole.h" namespace Common { @@ -54,18 +55,20 @@ void EventDispatcher::dispatch() { // We only try to process the events via the setup event mapper, when // we have a setup mapper and when the event source allows mapping. if (_mapper && allowMapping) { - if (_mapper->notifyEvent(event)) { - // We allow the event mapper to create multiple events, when - // eating an event. - while (_mapper->pollEvent(event)) - dispatchEvent(event); - - // Try getting another event from the current EventSource. - continue; - } + bool mapped = _mapper->notifyEvent(event); + // EventMappers must map all events + if (!mapped) + error("Event [%u] was not mapped by the EventMapper!", event.type); + // We allow the event mapper to create multiple events, when + // eating an event. + while (_mapper->pollEvent(event)) + dispatchEvent(event); + + // Try getting another event from the current EventSource. + continue; + } else { + dispatchEvent(event); } - - dispatchEvent(event); } } } -- cgit v1.2.3 From c0b04fdcaa0d357a0565a16ea7be74994e55da07 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 15:18:38 -0600 Subject: KEYMAPPER: Having a mapper is no longer optional --- common/EventDispatcher.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common/EventDispatcher.cpp') diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index 55eea9c7b2..6f36ee5f0f 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -54,7 +54,8 @@ void EventDispatcher::dispatch() { while (i->source->pollEvent(event)) { // We only try to process the events via the setup event mapper, when // we have a setup mapper and when the event source allows mapping. - if (_mapper && allowMapping) { + assert(_mapper); + if (allowMapping) { bool mapped = _mapper->notifyEvent(event); // EventMappers must map all events if (!mapped) @@ -67,7 +68,7 @@ void EventDispatcher::dispatch() { // Try getting another event from the current EventSource. continue; } else { - dispatchEvent(event); + dispatchEvent(Event(event)); } } } -- cgit v1.2.3 From a0ba4eb569ae9ec0e05a7ba8532ab304e6852f84 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 17:08:58 -0600 Subject: KEYMAPPER: Rewrite the EventMapper API --- common/EventDispatcher.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'common/EventDispatcher.cpp') diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index 6f36ee5f0f..4c7286bbb5 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -21,7 +21,6 @@ */ #include "common/events.h" -#include "common/textconsole.h" namespace Common { @@ -49,26 +48,15 @@ void EventDispatcher::dispatch() { dispatchPoll(); for (List::iterator i = _sources.begin(); i != _sources.end(); ++i) { - const bool allowMapping = i->source->allowMapping(); - while (i->source->pollEvent(event)) { // We only try to process the events via the setup event mapper, when // we have a setup mapper and when the event source allows mapping. assert(_mapper); - if (allowMapping) { - bool mapped = _mapper->notifyEvent(event); - // EventMappers must map all events - if (!mapped) - error("Event [%u] was not mapped by the EventMapper!", event.type); - // We allow the event mapper to create multiple events, when - // eating an event. - while (_mapper->pollEvent(event)) - dispatchEvent(event); - - // Try getting another event from the current EventSource. - continue; - } else { - dispatchEvent(Event(event)); + List mappedEvents = _mapper->mapEvent(event, i->source); + + for (List::iterator j = mappedEvents.begin(); j != mappedEvents.end(); ++j) { + const Event mappedEvent = *j; + dispatchEvent(mappedEvent); } } } -- cgit v1.2.3 From c0a215282d12872cf32fb24f9067216c0f869b96 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 1 Mar 2012 06:29:44 -0600 Subject: KEYMAPPER: Add delays for *UP events coming from non-keys Delayed entries are in a queue where each entry stores how many milliseconds should pass based on the last entry. --- common/EventDispatcher.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common/EventDispatcher.cpp') diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index 4c7286bbb5..012a2dfce5 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -60,6 +60,12 @@ void EventDispatcher::dispatch() { } } } + + List delayedEvents = _mapper->getDelayedEvents(); + for (List::iterator k = delayedEvents.begin(); k != delayedEvents.end(); ++k) { + const Event delayedEvent = *k; + dispatchEvent(delayedEvent); + } } void EventDispatcher::registerMapper(EventMapper *mapper) { -- cgit v1.2.3