summaryrefslogtreecommitdiffstats
path: root/plugin/inputadapter.h
diff options
context:
space:
mode:
authorAntti Hölttä <AHoelttae@luxoft.com>2018-07-23 14:53:11 +0200
committerAntti Hölttä <AHoelttae@luxoft.com>2019-03-18 16:29:30 +0100
commitffd151ecf3971fd8601d8b1d4e2f04fb5793e364 (patch)
treecd3b947f04781d59bc61306dd34ef15f8c3a24fd /plugin/inputadapter.h
Initial commit, demoable poc
Sort of working with 4 dir navigation, check demoapp
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