blob: 061375119e95fd9a7f6ad6d40eb39e682eab00b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
|