aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/inputadapter.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/inputadapter.h')
-rw-r--r--plugin/inputadapter.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugin/inputadapter.h b/plugin/inputadapter.h
new file mode 100644
index 0000000..0613751
--- /dev/null
+++ b/plugin/inputadapter.h
@@ -0,0 +1,40 @@
+#ifndef INPUTADAPTER_H
+#define INPUTADAPTER_H
+
+#include <QObject>
+#include "inputtypes.h"
+
+class CursorNavigation;
+class QQuickWindow;
+class QKeyEvent;
+class QMouseEvent;
+class QWheelEvent;
+
+/* filter various input events and translate them for the cursor navigation.
+ * it is possible to interpret mouse events as joystick/swipe events
+ * Set instance of this class as an input filter to the window or component that
+ * is being tracked.
+ * Events are passed forward to the CursorNavigation class, which should accept
+ * the event or reject it. When rejected, event is passed on.
+ */
+
+class InputAdapter : public QObject
+{
+ Q_OBJECT
+public:
+ InputAdapter(QObject *target, CursorNavigation *cursorNavigation);
+
+protected:
+ bool eventFilter(QObject *object, QEvent *event) override;
+
+private:
+ bool handleKeyEvent(QKeyEvent *ev);
+ bool handleMouseEvent(QMouseEvent *ev);
+ bool handleWheelEvent(QWheelEvent *ev);
+
+ QObject *const m_target;
+ CursorNavigation *m_cursorNavigation;
+
+};
+
+#endif // INPUTADAPTER_H