aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorEugene Sandulenko2012-03-17 03:46:46 -0700
committerEugene Sandulenko2012-03-17 03:46:46 -0700
commit56252909f5bebfa9cfd43cf092effb0111fdabef (patch)
treeefcf99fefc8b019cd07c119a9e15ccf3be06a2fe /common
parent5ae2543795433513e68339b16e0783d4b3295204 (diff)
parentc0a215282d12872cf32fb24f9067216c0f869b96 (diff)
downloadscummvm-rg350-56252909f5bebfa9cfd43cf092effb0111fdabef.tar.gz
scummvm-rg350-56252909f5bebfa9cfd43cf092effb0111fdabef.tar.bz2
scummvm-rg350-56252909f5bebfa9cfd43cf092effb0111fdabef.zip
Merge pull request #202 from tsoliman/keymapper-nonkey-inputs
KEYMAPPER: Add Gesture Support
Diffstat (limited to 'common')
-rw-r--r--common/EventDispatcher.cpp6
-rw-r--r--common/EventMapper.cpp38
-rw-r--r--common/events.h17
3 files changed, 61 insertions, 0 deletions
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<Event> delayedEvents = _mapper->getDelayedEvents();
+ for (List<Event>::iterator k = delayedEvents.begin(); k != delayedEvents.end(); ++k) {
+ const Event delayedEvent = *k;
+ dispatchEvent(delayedEvent);
+ }
}
void EventDispatcher::registerMapper(EventMapper *mapper) {
diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp
index 2808a7b5fd..47db61e472 100644
--- a/common/EventMapper.cpp
+++ b/common/EventMapper.cpp
@@ -22,6 +22,9 @@
#include "common/events.h"
+#include "common/system.h"
+#include "common/textconsole.h"
+
namespace Common {
List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
@@ -46,9 +49,44 @@ List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
// if it didn't get mapped, just pass it through
if (mappedEvent.type == EVENT_INVALID)
mappedEvent = ev;
+
+#ifdef ENABLE_VKEYBD
+ // TODO: this check is not needed post-split
+ if (mappedEvent.type == EVENT_CUSTOM_BACKEND_HARDWARE) {
+ warning("EVENT_CUSTOM_BACKEND_HARDWARE was not mapped");
+ return List<Event>();
+ }
+#endif
+
events.push_back(mappedEvent);
return events;
}
+void DefaultEventMapper::addDelayedEvent(uint32 millis, Event ev) {
+ if (_delayedEvents.empty()) {
+ _delayedEffectiveTime = g_system->getMillis() + millis;
+ millis = 0;
+ }
+ DelayedEventsEntry entry = DelayedEventsEntry(millis, ev);
+ _delayedEvents.push(entry);
+}
+
+List<Event> DefaultEventMapper::getDelayedEvents() {
+ List<Event> events;
+
+ if (_delayedEvents.empty())
+ return events;
+
+ uint32 now = g_system->getMillis();
+
+ while (!_delayedEvents.empty() && now >= _delayedEffectiveTime) {
+ DelayedEventsEntry entry = _delayedEvents.pop();
+ if (!_delayedEvents.empty())
+ _delayedEffectiveTime += _delayedEvents.front().timerOffset;
+ events.push_back(entry.event);
+ }
+ return events;
+}
+
} // namespace Common
diff --git a/common/events.h b/common/events.h
index 4efdd67b91..7366c51d36 100644
--- a/common/events.h
+++ b/common/events.h
@@ -79,6 +79,8 @@ enum EventType {
// 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_HARDWARE = 21,
+ EVENT_GUI_REMAP_COMPLETE_ACTION = 22,
EVENT_KEYMAPPER_REMAP = 19
#endif
#ifdef ENABLE_VKEYBD
@@ -230,12 +232,27 @@ public:
* Map an incoming event to one or more action events
*/
virtual List<Event> mapEvent(const Event &ev, EventSource *source) = 0;
+
+ virtual List<Event> getDelayedEvents() = 0;
};
class DefaultEventMapper : public EventMapper {
public:
+ DefaultEventMapper() : _delayedEvents(), _delayedEffectiveTime(0) {}
// EventMapper interface
virtual List<Event> mapEvent(const Event &ev, EventSource *source);
+ virtual List<Event> getDelayedEvents();
+protected:
+ virtual void addDelayedEvent(uint32 millis, Event ev);
+
+ struct DelayedEventsEntry {
+ const uint32 timerOffset;
+ const Event event;
+ DelayedEventsEntry(const uint32 offset, const Event ev) : timerOffset(offset), event(ev) { }
+ };
+
+ Queue<DelayedEventsEntry> _delayedEvents;
+ uint32 _delayedEffectiveTime;
};
/**