aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/events.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/events.h b/common/events.h
index 484ccec5f0..4f060a6da7 100644
--- a/common/events.h
+++ b/common/events.h
@@ -159,6 +159,36 @@ public:
};
/**
+ * An artificial event source. This is class is used as an event source, which is
+ * made up by client specific events.
+ *
+ * Example usage cases for this are the Keymapper or the DefaultEventManager.
+ */
+class ArtificialEventSource : public EventSource {
+protected:
+ 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;
+ }
+ }
+
+ /**
+ * By default an artificial event source prevents its events
+ * from being mapped.
+ */
+ virtual bool allowMapping() const { return false; }
+};
+
+/**
* Object which catches and processes Events.
*
* An example for this is the Engine object, it is catching events and processing them.