Debian Codegraph @

src/systeminfo/qinputinfo.h

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 Canonical, Ltd. and/or its subsidiary(-ies).
4 ** Copyright (C) 2018 The Qt Company Ltd and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/legal
6 **
7 ** This file is part of the QtSystems module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 #ifndef QINPUTINFO_H
42 #define QINPUTINFO_H
43
44 #include "qsysteminfoglobal.h"
45 #include <QObject>
46 #include <QVector>
47 #include <QMap>
48 #include <QSocketNotifier>
49 #include <QDebug>
50 #include <QtCore/qglobal.h>
51
52 QT_BEGIN_NAMESPACE
53
54 class QInputInfoManagerPrivate;
55 class QInputDevicePrivate;
56 class QInputDevice;
57
58 class QInputInfoManager;
59
60 #ifndef QT_NO_MIR
61 class QInputInfoManagerMir;
62 #endif
63 #ifndef QT_NO_UDEV
64 class QInputInfoManagerUdev;
65 #endif
66
67 class Q_SYSTEMINFO_EXPORT QInputDevice : public QObject
68 {
69 Q_OBJECT
70
71 Q_PROPERTY(QVariantMap properties READ properties CONSTANT)
72 Q_PROPERTY(QInputDevice::InputTypeFlags types READ types CONSTANT)
73
74 public:
75
76 enum InputType {
77 UnknownType = 0,
78 Button = 1,
79 Mouse = 2,
80 TouchPad = 4,
81 TouchScreen = 8,
82 Keyboard = 16,
83 Switch = 32
84 };
85 Q_ENUMS(InputType)
86
87 Q_DECLARE_FLAGS(InputTypeFlags, InputType)
88 Q_FLAGS(InputTypeFlags)
89
90 explicit QInputDevice(QObject *parent = Q_NULLPTR);
91 QString name() const;
92 QString identifier() const;
93 QList <int> buttons() const; //keys event code
94 QList <int> switches() const;
95 QList <int> relativeAxes() const;
96 QList <int> absoluteAxes() const;
97 QInputDevice::InputTypeFlags types() const;
98 /*
99 * name
100 * identifier
101 * buttons
102 * switches
103 * rAxes
104 * xAxes
105 * types
106 * */
107 QVariantMap properties();
108
109 private:
110
111 QInputDevicePrivate *d_ptr;
112
113 friend class QInputDeviceManagerPrivate;
114 #ifndef QT_NO_MIR
115 friend class QInputInfoManagerMir;
116 #endif
117 #ifndef QT_NO_UDEV
118 friend class QInputInfoManagerUdev;
119 #endif
120 void setName(const QString &);
121 void setIdentifier(const QString &);
122 void addButton(int);
123 void addSwitch(int);
124 void addRelativeAxis(int);
125 void addAbsoluteAxis(int);
126 void setTypes(QInputDevice::InputTypeFlags flags);
127 QVariantMap deviceProperties;
128
129 };
130
131 class Q_SYSTEMINFO_EXPORT QInputInfoManager : public QObject
132 {
133 Q_OBJECT
134
135 Q_PROPERTY(int count READ count NOTIFY countChanged)
136 Q_PROPERTY(QInputDevice::InputTypeFlags filter READ filter WRITE setFilter NOTIFY filterChanged)
137 Q_PROPERTY(QInputDevice * lastAdded READ lastAdded NOTIFY deviceAdded)
138
139 public:
140
141 explicit QInputInfoManager(QObject *parent = Q_NULLPTR);
142 ~QInputInfoManager();
143
144 int count() const;
145 int count(const QInputDevice::InputType filter) const;
146
147 void setFilter(QInputDevice::InputTypeFlags filterFlags);
148 QInputDevice::InputTypeFlags filter();
149
150 QMap <QString, QInputDevice *> deviceMap();
151 QInputDevice *lastAdded();
152
153 Q_SIGNALS:
154
155 void ready();
156 void deviceAdded(QInputDevice *inputDevice);
157 void deviceRemoved(const QString &deviceId);
158
159 void countChanged(int count);
160 void filterChanged(QInputDevice::InputTypeFlags filterFlags);
161
162 private Q_SLOTS:
163 void addedDevice(QInputDevice *devicePath);
164 void removedDevice(const QString &deviceId);
165
166 private:
167
168 Q_DISABLE_COPY(QInputInfoManager)
169 QInputInfoManagerPrivate *const d_ptr;
170 Q_DECLARE_PRIVATE(QInputInfoManager)
171 QInputDevice::InputTypeFlags currentFilter;
172 QMap <QString, QInputDevice *> currentFilteredMap;
173 int filteredCount;
174
175 private Q_SLOTS:
176 void privateReady();
177 };
178
179
180 QT_END_NAMESPACE
181
182 Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QInputDevice::InputType))
183 Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QInputDevice::InputTypeFlags))
184 Q_DECLARE_OPERATORS_FOR_FLAGS(QT_PREPEND_NAMESPACE(QInputDevice::InputTypeFlags))
185
186 #endif // QINPUTINFO_H