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 QINPUTDEVICE_H
5#define QINPUTDEVICE_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qobject.h>
9#include <QtGui/qscreen.h>
10
11QT_BEGIN_NAMESPACE
12
13class QDebug;
14class QInputDevicePrivate;
15
16class Q_GUI_EXPORT QInputDevice : public QObject
17{
18 Q_OBJECT
19 Q_DECLARE_PRIVATE(QInputDevice)
20 Q_PROPERTY(QString name READ name CONSTANT)
21 Q_PROPERTY(DeviceType type READ type CONSTANT)
22 Q_PROPERTY(Capabilities capabilities READ capabilities CONSTANT)
23 Q_PROPERTY(qint64 systemId READ systemId CONSTANT)
24 Q_PROPERTY(QString seatName READ seatName CONSTANT)
25 Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry
26 NOTIFY availableVirtualGeometryChanged)
27
28public:
29 enum class DeviceType {
30 Unknown = 0x0000,
31 Mouse = 0x0001,
32 TouchScreen = 0x0002,
33 TouchPad = 0x0004,
34 Puck = 0x0008,
35 Stylus = 0x0010,
36 Airbrush = 0x0020,
37 Keyboard = 0x1000,
38 AllDevices = 0x7FFFFFFF
39 };
40 Q_DECLARE_FLAGS(DeviceTypes, DeviceType)
41 Q_FLAG(DeviceTypes)
42
43 enum class Capability {
44 None = 0,
45 Position = 0x0001,
46 Area = 0x0002,
47 Pressure = 0x0004,
48 Velocity = 0x0008,
49 NormalizedPosition = 0x0020,
50 MouseEmulation = 0x0040,
51 PixelScroll = 0x0080,
52 Scroll = 0x0100,
53 Hover = 0x0200,
54 Rotation = 0x0400,
55 XTilt = 0x0800,
56 YTilt = 0x1000,
57 TangentialPressure = 0x2000,
58 ZPosition = 0x4000,
59 All = 0x7FFFFFFF
60 };
61 Q_DECLARE_FLAGS(Capabilities, Capability)
62 Q_FLAG(Capabilities)
63
64 QInputDevice(QObject *parent = nullptr);
65 ~QInputDevice();
66 QInputDevice(const QString &name, qint64 systemId, DeviceType type,
67 const QString &seatName = QString(), QObject *parent = nullptr);
68
69 QString name() const;
70 DeviceType type() const;
71 Capabilities capabilities() const;
72 bool hasCapability(Capability cap) const;
73 qint64 systemId() const;
74 QString seatName() const;
75 QRect availableVirtualGeometry() const;
76
77 static QStringList seatNames();
78 static QList<const QInputDevice *> devices();
79 static const QInputDevice *primaryKeyboard(const QString& seatName = QString());
80
81 bool operator==(const QInputDevice &other) const;
82
83Q_SIGNALS:
84 void availableVirtualGeometryChanged(QRect area);
85
86protected:
87 QInputDevice(QInputDevicePrivate &d, QObject *parent);
88
89 Q_DISABLE_COPY_MOVE(QInputDevice)
90};
91
92Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDevice::DeviceTypes)
93Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDevice::Capabilities)
94
95#ifndef QT_NO_DEBUG_STREAM
96Q_GUI_EXPORT QDebug operator<<(QDebug, const QInputDevice *);
97#endif
98
99QT_END_NAMESPACE
100
101#endif // QINPUTDEVICE_H
102

source code of qtbase/src/gui/kernel/qinputdevice.h