summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJohannes Zellner <johannes.zellner@nokia.com>2012-05-21 15:41:58 -0700
committerQt by Nokia <qt-info@nokia.com>2012-05-24 07:15:02 +0200
commitce5c1db2d3db7d7c7af28e9053ca591f76c6101c (patch)
tree60ef0eac7ad658e9715f2a940dbf7c5a3b6787a4 /src/plugins
parent7dd64fd2bbb18a424577543307f2821ace963b8b (diff)
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 <girish.1.ramakrishnan@nokia.com> Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp24
-rw-r--r--src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h8
-rw-r--r--src/plugins/generic/evdevmouse/qevdevmousemanager.cpp26
-rw-r--r--src/plugins/generic/evdevmouse/qevdevmousemanager.h8
-rw-r--r--src/plugins/generic/evdevtouch/qevdevtouch.cpp14
5 files changed, 24 insertions, 56 deletions
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 <QtPlatformSupport/private/qudevicehelper_p.h>
-#endif // QT_NO_LIBUDEV
+#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <QObject>
#include <QHash>
@@ -70,9 +68,7 @@ private slots:
private:
QString m_spec;
QHash<QString,QEvdevKeyboardHandler*> 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 <QScreen>
#include <QWindowSystemInterface>
-#define QT_QPA_MOUSEMANAGER_DEBUG
+//#define QT_QPA_MOUSEMANAGER_DEBUG
#ifdef QT_QPA_MOUSEMANAGER_DEBUG
#include <QDebug>
@@ -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 <QtPlatformSupport/private/qudevicehelper_p.h>
-#endif // QT_NO_LIBUDEV
+#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <QObject>
#include <QHash>
@@ -73,9 +71,7 @@ private slots:
private:
QString m_spec;
QHash<QString,QEvdevMouseHandler*> 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 <QGuiApplication>
#include <QDebug>
#include <QtCore/private/qcore_unix_p.h>
-#ifndef QT_NO_LIBUDEV
-#include <QtPlatformSupport/private/qudevicehelper_p.h>
-#endif // QT_NO_LIBUDEV
+#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <linux/input.h>
#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<QUDeviceHelper> udeviceHelper(QUDeviceHelper::createUDeviceHelper(QUDeviceHelper::UDev_Touchpad | QUDeviceHelper::UDev_Touchscreen, this));
- if (udeviceHelper) {
- QStringList devices = udeviceHelper->scanConnectedDevices();
+ QScopedPointer<QDeviceDiscovery> 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);