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