1/****************************************************************************
3** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
6** This file is part of the QtSystems module of the Qt Toolkit.
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 Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
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 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
40****************************************************************************/
42#include "qinputinfo.h"
44#if defined(UNITY_MOCKS)
45#include "qinputdeviceinfo_mock_p.h"
46#elif defined(Q_OS_LINUX)
47#include "linux/qinputdeviceinfo_linux_p.h"
50Q_GLOBAL_STATIC(QInputDeviceManagerPrivate, inputDeviceManagerPrivate)
54QInputDeviceManagerPrivate * QInputDeviceManagerPrivate::instance()
56 QInputDeviceManagerPrivate *priv = inputDeviceManagerPrivate();
60QInputDevicePrivate::QInputDevicePrivate(QObject *parent) :
62 type(QInputDevice::Unknown)
66QInputDevice::QInputDevice(QObject *parent) :
68 d_ptr(new QInputDevicePrivate(this))
73 * Returns the name of this input device.
75QString QInputDevice::name() const
81 * Sets the name of this input device to \b name.
83void QInputDevice::setName(const QString &name)
89 * Returns the device path of this device.
91QString QInputDevice::devicePath() const
93 return d_ptr->devicePath;
97 * Sets the device ppath of this device to /b path.
99void QInputDevice::setDevicePath(const QString &path)
101 d_ptr->devicePath = path;
105 * Returns the number of buttons this device has.
107QList <int> QInputDevice::buttons() const
109 return d_ptr->buttons;
115void QInputDevice::addButton(int buttonCode)
117 d_ptr->buttons.append(buttonCode);
121 * Returns the number of switch of this device.
123QList <int> QInputDevice::switches() const
125 return d_ptr->switches;
131void QInputDevice::addSwitch(int switchCode)
133 d_ptr->switches.append(switchCode);
137 * Returns a list of the relative axis of this device
139QList <int> QInputDevice::relativeAxis() const
141 return d_ptr->relativeAxis;
146void QInputDevice::addRelativeAxis(int axisCode)
148 d_ptr->relativeAxis.append(axisCode);
152 * Returns a list of the absolute axis of this device
154QList <int> QInputDevice::absoluteAxis() const
156 return d_ptr->absoluteAxis;
161void QInputDevice::addAbsoluteAxis(int axisCode)
163 d_ptr->absoluteAxis.append(axisCode);
167 * Returns a QInputDevice::InputTypeFlags of all the types of types.
169QInputDevice::InputTypeFlags QInputDevice::type() const
176void QInputDevice::setType(QInputDevice::InputTypeFlags type) //? setTypes?
181QInputDeviceManager::QInputDeviceManager(QObject *parent) :
183 d_ptr(inputDeviceManagerPrivate)
185 connect(d_ptr, &QInputDeviceManagerPrivate::deviceAdded,this,&QInputDeviceManager::addedDevice);
186 connect(d_ptr, &QInputDeviceManagerPrivate::deviceRemoved,this,&QInputDeviceManager::deviceRemoved);
188 connect(d_ptr,SIGNAL(ready()),this,SIGNAL(ready()));
192 * Returns a QMap of known input devices.
194QMap <QString, QInputDevice *> QInputDeviceManager::deviceMap()
196 return d_ptr->deviceMap;
201void QInputDeviceManager::addedDevice(const QString & devicePath)
203 Q_EMIT deviceAdded(devicePath);
207 * Returns a QVector of InputDevices of type filter
209QVector <QInputDevice *> QInputDeviceManager::deviceListOfType(QInputDevice::InputType filter)
211 QVector <QInputDevice *> dList;
212 QMapIterator<QString, QInputDevice *> i(d_ptr->deviceMap);
213 while (i.hasNext()) {
215 if (i.value()->type().testFlag(filter) || filter == QInputDevice::Unknown) {
216 dList.append(i.value());
223 * Returns the number of input devices with the currently set QInputDevice::InputType filter.
224 * If no device filter has been set, returns number of all available input devices.
225 * If filter has not been set, returns all available input devices
227int QInputDeviceManager::deviceCount() const
229 return deviceCount(static_cast< QInputDevice::InputType >(d_ptr->currentFilter));
233 * Returns the number of input devices of the type filter.
235int QInputDeviceManager::deviceCount(const QInputDevice::InputType filter) const
238 QMapIterator<QString, QInputDevice *> i(d_ptr->deviceMap);
239 while (i.hasNext()) {
241// qDebug() << i.value()->name() << i.value()->devicePath();
242// qDebug() << i.value()->type() << i.value()->type().testFlag(filter);
244 if (i.value()->type().testFlag(filter)) {
252 * Returns the currently set device filter.
254QInputDevice::InputType QInputDeviceManager::deviceFilter()
256 return d_ptr->currentFilter;
260 * Sets the current input device filter to filter.
262void QInputDeviceManager::setDeviceFilter(QInputDevice::InputType filter)
264 if (filter != d_ptr->currentFilter) {
265 d_ptr->currentFilter = filter;
266 Q_EMIT deviceFilterChanged(filter);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list