| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 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; |
| 94 |
QList <int> switches() const; |
| 95 |
QList <int> relativeAxes() const; |
| 96 |
QList <int> absoluteAxes() const; |
| 97 |
QInputDevice::InputTypeFlags types() const; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 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 |