From ce5c1db2d3db7d7c7af28e9053ca591f76c6101c Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 21 May 2012 15:41:58 -0700 Subject: udev: UDevHelper becomes DeviceDiscovery Rename QUDeviceHelper to QDeviceDiscovery and add a static device discovery fallback in case we dont have udev. The fallback so far only scans /dev/input/event* and /dev/dri/card* at startup and detects device nodes only by device path. Change-Id: I7a423910b30ae16a10d8f1f47b86c6b4d2c2ec36 Reviewed-by: Girish Ramakrishnan Reviewed-by: Donald Carr --- .../evdevkeyboard/qevdevkeyboardmanager.cpp | 24 ++++++-------------- .../generic/evdevkeyboard/qevdevkeyboardmanager.h | 8 ++----- .../generic/evdevmouse/qevdevmousemanager.cpp | 26 +++++++--------------- .../generic/evdevmouse/qevdevmousemanager.h | 8 ++----- src/plugins/generic/evdevtouch/qevdevtouch.cpp | 14 +++++------- 5 files changed, 24 insertions(+), 56 deletions(-) (limited to 'src/plugins/generic') diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp index 6a891a4cb7..412695579d 100644 --- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -56,11 +56,6 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & { Q_UNUSED(key); -#ifndef QT_NO_LIBUDEV - bool useUDev = true; -#else - bool useUDev = false; -#endif // QT_NO_LIBUDEV QStringList args = specification.split(QLatin1Char(':')); QStringList devices; @@ -69,7 +64,6 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & // if device is specified try to use it devices.append(arg); args.removeAll(arg); - useUDev = false; } } @@ -80,27 +74,23 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & foreach (const QString &device, devices) addKeyboard(device); -#ifndef QT_NO_LIBUDEV - if (useUDev) { + if (devices.isEmpty()) { #ifdef QT_QPA_KEYMAP_DEBUG - qWarning() << "Use UDev for device discovery"; + qWarning() << "Use device discovery"; #endif - m_udeviceHelper = QUDeviceHelper::createUDeviceHelper(QUDeviceHelper::UDev_Keyboard, this); - if (m_udeviceHelper) { + m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this); + if (m_deviceDiscovery) { // scan and add already connected keyboards - QStringList devices = m_udeviceHelper->scanConnectedDevices(); + QStringList devices = m_deviceDiscovery->scanConnectedDevices(); foreach (QString device, devices) { addKeyboard(device); } - connect(m_udeviceHelper, SIGNAL(deviceDetected(QString,QUDeviceTypes)), this, SLOT(addKeyboard(QString))); - connect(m_udeviceHelper, SIGNAL(deviceRemoved(QString,QUDeviceTypes)), this, SLOT(removeKeyboard(QString))); + connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString))); + connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString))); } } -#else - Q_UNUSED(useUDev) -#endif // QT_NO_LIBUDEV } QEvdevKeyboardManager::~QEvdevKeyboardManager() diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h index a505ce834e..e76814209e 100644 --- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h +++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h @@ -44,9 +44,7 @@ #include "qevdevkeyboardhandler.h" -#ifndef QT_NO_LIBUDEV -#include -#endif // QT_NO_LIBUDEV +#include #include #include @@ -70,9 +68,7 @@ private slots: private: QString m_spec; QHash m_keyboards; -#ifndef QT_NO_LIBUDEV - QUDeviceHelper *m_udeviceHelper; -#endif // QT_NO_LIBUDEV + QDeviceDiscovery *m_deviceDiscovery; }; QT_END_HEADER diff --git a/src/plugins/generic/evdevmouse/qevdevmousemanager.cpp b/src/plugins/generic/evdevmouse/qevdevmousemanager.cpp index 07d7d0fe06..8547e444f0 100644 --- a/src/plugins/generic/evdevmouse/qevdevmousemanager.cpp +++ b/src/plugins/generic/evdevmouse/qevdevmousemanager.cpp @@ -46,7 +46,7 @@ #include #include -#define QT_QPA_MOUSEMANAGER_DEBUG +//#define QT_QPA_MOUSEMANAGER_DEBUG #ifdef QT_QPA_MOUSEMANAGER_DEBUG #include @@ -59,11 +59,6 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif { Q_UNUSED(key); -#ifndef QT_NO_LIBUDEV - bool useUDev = true; -#else - bool useUDev = false; -#endif // QT_NO_LIBUDEV QStringList args = specification.split(QLatin1Char(':')); QStringList devices; @@ -72,7 +67,6 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif // if device is specified try to use it devices.append(arg); args.removeAll(arg); - useUDev = false; } else if (arg.startsWith("xoffset=")) { m_xoffset = arg.mid(8).toInt(); } else if (arg.startsWith("yoffset=")) { @@ -87,27 +81,23 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif foreach (const QString &device, devices) addMouse(device); -#ifdef QT_NO_LIBUDEV - Q_UNUSED(useUDev) -#else - if (useUDev) { + if (devices.isEmpty()) { #ifdef QT_QPA_MOUSEMANAGER_DEBUG - qWarning() << "Use UDev for device discovery"; + qWarning() << "Use device discovery"; #endif - m_udeviceHelper = QUDeviceHelper::createUDeviceHelper(QUDeviceHelper::UDev_Mouse | QUDeviceHelper::UDev_Touchpad, this); - if (m_udeviceHelper) { + m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this); + if (m_deviceDiscovery) { // scan and add already connected keyboards - QStringList devices = m_udeviceHelper->scanConnectedDevices(); + QStringList devices = m_deviceDiscovery->scanConnectedDevices(); foreach (QString device, devices) { addMouse(device); } - connect(m_udeviceHelper, SIGNAL(deviceDetected(QString,QUDeviceTypes)), this, SLOT(addMouse(QString))); - connect(m_udeviceHelper, SIGNAL(deviceRemoved(QString,QUDeviceTypes)), this, SLOT(removeMouse(QString))); + connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString))); + connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString))); } } -#endif // QT_NO_LIBUDEV } QEvdevMouseManager::~QEvdevMouseManager() diff --git a/src/plugins/generic/evdevmouse/qevdevmousemanager.h b/src/plugins/generic/evdevmouse/qevdevmousemanager.h index 7a1e705ed1..b90347986b 100644 --- a/src/plugins/generic/evdevmouse/qevdevmousemanager.h +++ b/src/plugins/generic/evdevmouse/qevdevmousemanager.h @@ -44,9 +44,7 @@ #include "qevdevmousehandler.h" -#ifndef QT_NO_LIBUDEV -#include -#endif // QT_NO_LIBUDEV +#include #include #include @@ -73,9 +71,7 @@ private slots: private: QString m_spec; QHash m_mice; -#ifndef QT_NO_LIBUDEV - QUDeviceHelper *m_udeviceHelper; -#endif // QT_NO_LIBUDEV + QDeviceDiscovery *m_deviceDiscovery; int m_x; int m_y; int m_xoffset; diff --git a/src/plugins/generic/evdevtouch/qevdevtouch.cpp b/src/plugins/generic/evdevtouch/qevdevtouch.cpp index 37db20a419..c372b0d1ff 100644 --- a/src/plugins/generic/evdevtouch/qevdevtouch.cpp +++ b/src/plugins/generic/evdevtouch/qevdevtouch.cpp @@ -46,9 +46,7 @@ #include #include #include -#ifndef QT_NO_LIBUDEV -#include -#endif // QT_NO_LIBUDEV +#include #include #ifdef USE_MTDEV @@ -159,22 +157,20 @@ QTouchScreenHandler::QTouchScreenHandler(const QString &spec) } } -#ifndef QT_NO_LIBUDEV if (dev.isEmpty()) { // try to let udev scan for already connected devices - QScopedPointer udeviceHelper(QUDeviceHelper::createUDeviceHelper(QUDeviceHelper::UDev_Touchpad | QUDeviceHelper::UDev_Touchscreen, this)); - if (udeviceHelper) { - QStringList devices = udeviceHelper->scanConnectedDevices(); + QScopedPointer deviceDiscovery(QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this)); + if (deviceDiscovery) { + QStringList devices = deviceDiscovery->scanConnectedDevices(); // only the first device found is used for now if (devices.size() > 0) dev = devices[0]; } } -#endif // QT_NO_LIBUDEV if (dev.isEmpty()) - dev = QLatin1String("/dev/input/event0"); + return; qDebug("evdevtouch: Using device %s", qPrintable(dev)); m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); -- cgit v1.2.3