summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/InputEventPayload.cpp36
-rw-r--r--Swiften/Elements/InputEventPayload.h62
2 files changed, 98 insertions, 0 deletions
diff --git a/Swiften/Elements/InputEventPayload.cpp b/Swiften/Elements/InputEventPayload.cpp
new file mode 100644
index 0000000..411d2cd
--- /dev/null
+++ b/Swiften/Elements/InputEventPayload.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/Elements/InputEventPayload.h>
+
+namespace Swift {
+
+InputEventPayload::InputEventPayload()
+ : action_(InputEventPayload::Notify)
+{
+}
+
+void InputEventPayload::addEvent(const InputEventPayload::Event& event)
+{
+ events_.push_back(event);
+}
+
+const std::vector<InputEventPayload::Event>& InputEventPayload::getEvents() const
+{
+ return events_;
+}
+
+void InputEventPayload::setAction(InputEventPayload::Action action)
+{
+ action_ = action;
+}
+
+InputEventPayload::Action InputEventPayload::getAction() const
+{
+ return action_;
+}
+
+}
diff --git a/Swiften/Elements/InputEventPayload.h b/Swiften/Elements/InputEventPayload.h
new file mode 100644
index 0000000..1ccdec8
--- /dev/null
+++ b/Swiften/Elements/InputEventPayload.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Elements/Payload.h>
+
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+namespace Swift {
+ class InputEventPayload : public Payload {
+ public:
+ typedef boost::shared_ptr<InputEventPayload> ref;
+
+ enum Action {
+ Notify,
+ Unknown,
+ };
+
+ struct Event {
+ enum EventType {
+ MouseMove,
+ MouseWheel,
+ MousePress,
+ MouseRelease,
+ KeyType,
+ KeyPress,
+ KeyRelease,
+ Unknown,
+ };
+
+ Event(EventType eventType = Unknown)
+ : type(eventType), integerArg(0), realArg1(0), realArg2(0) {}
+ Event(EventType eventType, int integerArg)
+ : type(eventType), integerArg(integerArg), realArg1(0), realArg2(0) {}
+ Event(EventType eventType, float realArg1, float realArg2)
+ : type(eventType), integerArg(0), realArg1(realArg1), realArg2(realArg2) {}
+
+ EventType type;
+ int integerArg;
+ float realArg1;
+ float realArg2;
+ };
+
+ public:
+ InputEventPayload();
+
+ void addEvent(const Event& event);
+ const std::vector<Event>& getEvents() const;
+
+ void setAction(Action action);
+ Action getAction() const;
+
+ private:
+ Action action_;
+ std::vector<Event> events_;
+ };
+}