diff options
Diffstat (limited to 'src/platformsupport/devicediscovery')
7 files changed, 86 insertions, 104 deletions
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp index 44c5f845dc..bbd97091f6 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h index 93a676858d..e88c3d4160 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_p.h index f3b0d19a7c..637a74cb1f 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -74,7 +74,8 @@ public: Device_DRM = 0x10, Device_DRM_PrimaryGPU = 0x20, Device_Tablet = 0x40, - Device_InputMask = Device_Mouse | Device_Touchpad | Device_Touchscreen | Device_Keyboard | Device_Tablet, + Device_Joystick = 0x80, + Device_InputMask = Device_Mouse | Device_Touchpad | Device_Touchscreen | Device_Keyboard | Device_Tablet | Device_Joystick, Device_VideoMask = Device_DRM }; Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType) diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp index 660d3760fb..1bc834b5ef 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -38,6 +38,7 @@ #include <QObject> #include <QHash> #include <QDir> +#include <QLoggingCategory> #include <QtCore/private/qcore_unix_p.h> #include <linux/input.h> @@ -56,13 +57,6 @@ #define ABS_CNT (ABS_MAX+1) #endif - -//#define QT_QPA_DEVICE_DISCOVERY_DEBUG - -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG -#include <QtDebug> -#endif - #define LONG_BITS (sizeof(long) * 8 ) #define LONG_FIELD_SIZE(bits) ((bits / LONG_BITS) + 1) @@ -73,6 +67,8 @@ static bool testBit(long bit, const long *field) QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcDD, "qt.qpa.input") + QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) { return new QDeviceDiscoveryStatic(types, parent); @@ -81,9 +77,7 @@ QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) QDeviceDiscoveryStatic::QDeviceDiscoveryStatic(QDeviceTypes types, QObject *parent) : QDeviceDiscovery(types, parent) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "New DeviceDiscovery created for type" << types; -#endif + qCDebug(lcDD) << "static device discovery for type" << types; } QStringList QDeviceDiscoveryStatic::scanConnectedDevices() @@ -112,9 +106,7 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices() } } -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery found matching devices" << devices; -#endif + qCDebug(lcDD) << "Found matching devices" << devices; return devices; } @@ -124,9 +116,7 @@ bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) bool ret = false; int fd = QT_OPEN(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); if (!fd) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery cannot open device" << device; -#endif + qWarning() << "Device discovery cannot open device" << device; return false; } @@ -134,9 +124,7 @@ bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(bitsKey)), bitsKey) >= 0 ) { if (!ret && (m_types & Device_Keyboard)) { if (testBit(KEY_Q, bitsKey)) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery found keyboard at" << device; -#endif + qCDebug(lcDD) << "Found keyboard at" << device; ret = true; } } @@ -145,9 +133,7 @@ bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) long bitsRel[LONG_FIELD_SIZE(REL_CNT)]; if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(bitsRel)), bitsRel) >= 0 ) { if (testBit(REL_X, bitsRel) && testBit(REL_Y, bitsRel) && testBit(BTN_MOUSE, bitsKey)) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery found mouse at" << device; -#endif + qCDebug(lcDD) << "Found mouse at" << device; ret = true; } } @@ -158,24 +144,29 @@ bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(bitsAbs)), bitsAbs) >= 0 ) { if (testBit(ABS_X, bitsAbs) && testBit(ABS_Y, bitsAbs)) { if ((m_types & Device_Touchpad) && testBit(BTN_TOOL_FINGER, bitsKey)) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery found touchpad at" << device; -#endif + qCDebug(lcDD) << "Found touchpad at" << device; ret = true; } else if ((m_types & Device_Touchscreen) && testBit(BTN_TOUCH, bitsKey)) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery found touchscreen at" << device; -#endif + qCDebug(lcDD) << "Found touchscreen at" << device; ret = true; } else if ((m_types & Device_Tablet) && (testBit(BTN_STYLUS, bitsKey) || testBit(BTN_TOOL_PEN, bitsKey))) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "DeviceDiscovery found tablet at" << device; -#endif + qCDebug(lcDD) << "Found tablet at" << device; ret = true; } } } } + + if (!ret && (m_types & Device_Joystick)) { + long bitsAbs[LONG_FIELD_SIZE(ABS_CNT)]; + if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(bitsAbs)), bitsAbs) >= 0 ) { + if ((m_types & Device_Joystick) + && (testBit(BTN_A, bitsKey) || testBit(BTN_TRIGGER, bitsKey) || testBit(ABS_RX, bitsAbs))) { + qCDebug(lcDD) << "Found joystick/gamepad at" << device; + ret = true; + } + } + } } if (!ret && (m_types & Device_DRM) && device.contains(QString::fromLatin1(QT_DRM_DEVICE_PREFIX))) diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h index 6629a9a26c..16ded3fca3 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp index 7645dc4544..8fa82e2ad7 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -38,22 +38,17 @@ #include <QObject> #include <QHash> #include <QSocketNotifier> +#include <QLoggingCategory> #include <linux/input.h> -//#define QT_QPA_DEVICE_DISCOVERY_DEBUG - -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG -#include <QtDebug> -#endif - QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcDD, "qt.qpa.input") + QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "Try to create new UDeviceHelper"; -#endif + qCDebug(lcDD) << "udev device discovery for type" << types; QDeviceDiscovery *helper = 0; struct udev *udev; @@ -62,7 +57,7 @@ QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) if (udev) { helper = new QDeviceDiscoveryUDev(types, udev, parent); } else { - qWarning("Failed to get udev library context."); + qWarning("Failed to get udev library context"); } return helper; @@ -72,18 +67,12 @@ QDeviceDiscoveryUDev::QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev QDeviceDiscovery(types, parent), m_udev(udev), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "New UDeviceHelper created for type" << types; -#endif - if (!m_udev) return; m_udevMonitor = udev_monitor_new_from_netlink(m_udev, "udev"); if (!m_udevMonitor) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning("Unable to create an Udev monitor. No devices can be detected."); -#endif + qWarning("Unable to create an udev monitor. No devices can be detected."); return; } @@ -128,11 +117,11 @@ QStringList QDeviceDiscoveryUDev::scanConnectedDevices() } if (m_types & Device_Tablet) udev_enumerate_add_match_property(ue, "ID_INPUT_TABLET", "1"); + if (m_types & Device_Joystick) + udev_enumerate_add_match_property(ue, "ID_INPUT_JOYSTICK", "1"); if (udev_enumerate_scan_devices(ue) != 0) { -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "UDeviceHelper scan connected devices for enumeration failed"; -#endif + qWarning("Failed to scan devices"); return devices; } @@ -158,9 +147,7 @@ QStringList QDeviceDiscoveryUDev::scanConnectedDevices() } udev_enumerate_unref(ue); -#ifdef QT_QPA_DEVICE_DISCOVERY_DEBUG - qWarning() << "UDeviceHelper found matching devices" << devices; -#endif + qCDebug(lcDD) << "Found matching devices" << devices; return devices; } @@ -251,6 +238,9 @@ bool QDeviceDiscoveryUDev::checkDeviceType(udev_device *dev) if ((m_types & Device_Tablet) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TABLET"), "1") == 0)) return true; + if ((m_types & Device_Joystick) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"), "1") == 0)) + return true; + if ((m_types & Device_DRM) && (qstrcmp(udev_device_get_subsystem(dev), "drm") == 0)) return true; diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h index d31ba72c96..196d6df77c 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ |