summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input/evdevtouch
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-06-06 14:09:41 +0300
committerQt by Nokia <qt-info@nokia.com>2012-06-06 15:29:34 +0200
commit0cf0a2ae7c12a96883b4287005c0be1c4875cb76 (patch)
tree484a0a6bdf2ed4b07e2a046c99e2861adb6f61b6 /src/platformsupport/input/evdevtouch
parent302e6968f1152d5dee8d5debafb313bd53fa55ff (diff)
Test if the device is grabbed in some of the evdev plugins
Even though they target embedded devices, the touch and tablet plugins are very often used on desktop, under X, for development and experimenting. However the X.org drivers like to grab the input devices, resulting in getting no events when reading directly. Inspired by evtest, we show a warning from now on in this case so the user has a clue what's going on. Change-Id: I19474f1fcc5163f2601e7000aaee0cce54f99367 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/platformsupport/input/evdevtouch')
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouch.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
index 6bf9ba769e..76314b3443 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
@@ -179,7 +179,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &spec, QObject
m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
connect(m_notify, SIGNAL(activated(int)), this, SLOT(readData()));
} else {
- qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
+ qErrnoWarning(errno, "Cannot open input device %s", qPrintable(dev));
return;
}
@@ -220,6 +220,12 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &spec, QObject
qDebug("device name: %s", name);
}
+ bool grabSuccess = !ioctl(m_fd, EVIOCGRAB, (void *) 1);
+ if (grabSuccess)
+ ioctl(m_fd, EVIOCGRAB, (void *) 0);
+ else
+ qWarning("ERROR: The device is grabbed by another process. No events will be read.");
+
#ifdef USE_MTDEV
const char *mtdevStr = "(mtdev)";
d->m_typeB = true;