1/****************************************************************************
2**
3** Copyright (C) 2020 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QINPUTDEVICE_H
41#define QINPUTDEVICE_H
42
43#include <QtGui/qtguiglobal.h>
44#include <QtCore/qobject.h>
45#include <QtGui/qscreen.h>
46
47QT_BEGIN_NAMESPACE
48
49class QDebug;
50class QInputDevicePrivate;
51
52class Q_GUI_EXPORT QInputDevice : public QObject
53{
54 Q_OBJECT
55 Q_DECLARE_PRIVATE(QInputDevice)
56 Q_PROPERTY(QString name READ name CONSTANT)
57 Q_PROPERTY(DeviceType type READ type CONSTANT)
58 Q_PROPERTY(Capabilities capabilities READ capabilities CONSTANT)
59 Q_PROPERTY(qint64 systemId READ systemId CONSTANT)
60 Q_PROPERTY(QString seatName READ seatName CONSTANT)
61 Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry NOTIFY availableVirtualGeometryChanged)
62
63public:
64 enum class DeviceType : qint16 {
65 Unknown = 0x0000,
66 Mouse = 0x0001,
67 TouchScreen = 0x0002,
68 TouchPad = 0x0004,
69 Puck = 0x0008,
70 Stylus = 0x0010,
71 Airbrush = 0x0020,
72 Keyboard = 0x1000,
73 AllDevices = 0x7FFF
74 };
75 Q_DECLARE_FLAGS(DeviceTypes, DeviceType)
76 Q_FLAG(DeviceTypes)
77
78 enum class Capability : qint32 {
79 None = 0,
80 Position = 0x0001,
81 Area = 0x0002,
82 Pressure = 0x0004,
83 Velocity = 0x0008,
84 NormalizedPosition = 0x0020,
85 MouseEmulation = 0x0040,
86 Scroll = 0x0100,
87 Hover = 0x0200,
88 Rotation = 0x0400,
89 XTilt = 0x0800,
90 YTilt = 0x1000,
91 TangentialPressure = 0x2000,
92 ZPosition = 0x4000,
93 All = 0x7FFFFFFF
94 };
95 Q_DECLARE_FLAGS(Capabilities, Capability)
96 Q_FLAG(Capabilities)
97
98 QInputDevice();
99 ~QInputDevice();
100 QInputDevice(const QString &name, qint64 systemId, DeviceType type,
101 const QString &seatName = QString(), QObject *parent = nullptr);
102
103 QString name() const;
104 DeviceType type() const;
105 Capabilities capabilities() const;
106 bool hasCapability(Capability cap) const;
107 qint64 systemId() const;
108 QString seatName() const;
109 QRect availableVirtualGeometry() const;
110
111 static QList<const QInputDevice *> devices();
112 static const QInputDevice *primaryKeyboard(const QString& seatName = QString());
113
114 bool operator==(const QInputDevice &other) const;
115
116Q_SIGNALS:
117 void availableVirtualGeometryChanged(QRect area);
118
119protected:
120 QInputDevice(QInputDevicePrivate &d, QObject *parent = nullptr);
121
122 Q_DISABLE_COPY_MOVE(QInputDevice)
123};
124
125Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDevice::DeviceTypes)
126Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDevice::Capabilities)
127
128#ifndef QT_NO_DEBUG_STREAM
129Q_GUI_EXPORT QDebug operator<<(QDebug, const QInputDevice *);
130#endif
131
132QT_END_NAMESPACE
133
134#endif // QINPUTDEVICE_H
135