1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QEVDEVMOUSEHANDLER_P_H
5#define QEVDEVMOUSEHANDLER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QObject>
19#include <QString>
20#include <QPoint>
21#include <QEvent>
22#include <QLoggingCategory>
23
24#include <private/qglobal_p.h>
25
26#include <memory>
27
28QT_BEGIN_NAMESPACE
29
30Q_DECLARE_LOGGING_CATEGORY(qLcEvdevMouse)
31
32class QSocketNotifier;
33
34class QEvdevMouseHandler : public QObject
35{
36 Q_OBJECT
37public:
38 static std::unique_ptr<QEvdevMouseHandler> create(const QString &device, const QString &specification);
39 ~QEvdevMouseHandler();
40
41 void readMouseData();
42
43signals:
44 void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons,
45 Qt::MouseButton button, QEvent::Type type);
46 void handleWheelEvent(QPoint delta);
47
48private:
49 QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit);
50
51 void sendMouseEvent();
52#ifndef Q_OS_VXWORKS
53 bool getHardwareMaximum();
54#endif
55 void detectHiResWheelSupport();
56
57 QString m_device;
58 int m_fd;
59 QSocketNotifier *m_notify = nullptr;
60 int m_x = 0, m_y = 0;
61 int m_prevx = 0, m_prevy = 0;
62 bool m_abs;
63 bool m_compression;
64 bool m_hiResWheel = false;
65 bool m_hiResHWheel = false;
66 Qt::MouseButtons m_buttons;
67 Qt::MouseButton m_button;
68 QEvent::Type m_eventType;
69 int m_jitterLimitSquared;
70 bool m_prevInvalid = true;
71 int m_hardwareWidth;
72 int m_hardwareHeight;
73 qreal m_hardwareScalerY;
74 qreal m_hardwareScalerX;
75};
76
77QT_END_NAMESPACE
78
79#endif // QEVDEVMOUSEHANDLER_P_H
80

source code of qtbase/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h