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 <private/qglobal_p.h>
23
24#include <memory>
25
26QT_BEGIN_NAMESPACE
27
28class QSocketNotifier;
29
30class QEvdevMouseHandler : public QObject
31{
32 Q_OBJECT
33public:
34 static std::unique_ptr<QEvdevMouseHandler> create(const QString &device, const QString &specification);
35 ~QEvdevMouseHandler();
36
37 void readMouseData();
38
39signals:
40 void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons,
41 Qt::MouseButton button, QEvent::Type type);
42 void handleWheelEvent(QPoint delta);
43
44private:
45 QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit);
46
47 void sendMouseEvent();
48 bool getHardwareMaximum();
49 void detectHiResWheelSupport();
50
51 QString m_device;
52 int m_fd;
53 QSocketNotifier *m_notify = nullptr;
54 int m_x = 0, m_y = 0;
55 int m_prevx = 0, m_prevy = 0;
56 bool m_abs;
57 bool m_compression;
58 bool m_hiResWheel = false;
59 bool m_hiResHWheel = false;
60 Qt::MouseButtons m_buttons;
61 Qt::MouseButton m_button;
62 QEvent::Type m_eventType;
63 int m_jitterLimitSquared;
64 bool m_prevInvalid = true;
65 int m_hardwareWidth;
66 int m_hardwareHeight;
67 qreal m_hardwareScalerY;
68 qreal m_hardwareScalerX;
69};
70
71QT_END_NAMESPACE
72
73#endif // QEVDEVMOUSEHANDLER_P_H
74

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