diff options
Diffstat (limited to 'src/platformsupport/input/evdevtouch/qevdevtouch.cpp')
-rw-r--r-- | src/platformsupport/input/evdevtouch/qevdevtouch.cpp | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp index d0d8b783a4..5215f7da0a 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouch.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 module 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$ @@ -36,9 +36,11 @@ #include <QHash> #include <QSocketNotifier> #include <QGuiApplication> -#include <QDebug> +#include <QLoggingCategory> #include <QtCore/private/qcore_unix_p.h> #include <QtPlatformSupport/private/qdevicediscovery_p.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qinputdevicemanager_p_p.h> #include <linux/input.h> #if !defined(QT_NO_MTDEV) @@ -49,6 +51,8 @@ extern "C" { QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input") + /* android (and perhaps some other linux-derived stuff) don't define everything * in linux/input.h, so we'll need to do that ourselves. */ @@ -144,6 +148,12 @@ void QEvdevTouchScreenData::registerDevice() m_device->setCapabilities(m_device->capabilities() | QTouchDevice::Pressure); QWindowSystemInterface::registerTouchDevice(m_device); + + // No monitoring of added/removed devices is done here, so for now just + // increase the number of touch devices. + QInputDeviceManager *imgr = QGuiApplicationPrivate::inputDeviceManager(); + QInputDeviceManagerPrivate::get(imgr)->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, + imgr->deviceCount(QInputDeviceManager::DeviceTypeTouch) + 1); } #define LONG_BITS (sizeof(long) << 3) @@ -164,7 +174,8 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, { setObjectName(QLatin1String("Evdev Touch Handler")); - bool printDeviceInfo = qgetenv("QT_QPA_EVDEV_DEBUG").toInt(); + if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG")) + ((QLoggingCategory &) qLcEvdevTouch()).setEnabled(QtDebugMsg, true); // only the first device argument is used for now QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS")); @@ -215,13 +226,11 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, } if (dev.isEmpty()) { - if (printDeviceInfo) - qDebug("evdevtouch: No touch devices found"); + qCDebug(qLcEvdevTouch, "evdevtouch: No touch devices found"); return; } - if (printDeviceInfo) - qDebug("evdevtouch: Using device %s", qPrintable(dev)); + qCDebug(qLcEvdevTouch, "evdevtouch: Using device %s", qPrintable(dev)); m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); @@ -257,25 +266,22 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, } #endif - if (printDeviceInfo) - qDebug("evdevtouch: Protocol type %c %s (%s)", d->m_typeB ? 'B' : 'A', - mtdevStr, d->m_singleTouch ? "single" : "multi"); + qCDebug(qLcEvdevTouch, "evdevtouch: Protocol type %c %s (%s)", d->m_typeB ? 'B' : 'A', + mtdevStr, d->m_singleTouch ? "single" : "multi"); input_absinfo absInfo; memset(&absInfo, 0, sizeof(input_absinfo)); bool has_x_range = false, has_y_range = false; if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X)), &absInfo) >= 0) { - if (printDeviceInfo) - qDebug("evdevtouch: min X: %d max X: %d", absInfo.minimum, absInfo.maximum); + qCDebug(qLcEvdevTouch, "evdevtouch: min X: %d max X: %d", absInfo.minimum, absInfo.maximum); d->hw_range_x_min = absInfo.minimum; d->hw_range_x_max = absInfo.maximum; has_x_range = true; } if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y)), &absInfo) >= 0) { - if (printDeviceInfo) - qDebug("evdevtouch: min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum); + qCDebug(qLcEvdevTouch, "evdevtouch: min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum); d->hw_range_y_min = absInfo.minimum; d->hw_range_y_max = absInfo.maximum; has_y_range = true; @@ -285,8 +291,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, qWarning("evdevtouch: Invalid ABS limits, behavior unspecified"); if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) { - if (printDeviceInfo) - qDebug("evdevtouch: min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum); + qCDebug(qLcEvdevTouch, "evdevtouch: min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum); if (absInfo.maximum > absInfo.minimum) { d->hw_pressure_min = absInfo.minimum; d->hw_pressure_max = absInfo.maximum; @@ -296,8 +301,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, char name[1024]; if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) { d->hw_name = QString::fromLocal8Bit(name); - if (printDeviceInfo) - qDebug("evdevtouch: device name: %s", name); + qCDebug(qLcEvdevTouch, "evdevtouch: device name: %s", name); } // Fix up the coordinate ranges for am335x in case the kernel driver does not have them fixed. @@ -310,9 +314,8 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, d->hw_range_y_min = 220; d->hw_range_y_max = 3907; } - if (printDeviceInfo) - qDebug("evdevtouch: found ti-tsc, overriding: min X: %d max X: %d min Y: %d max Y: %d", - d->hw_range_x_min, d->hw_range_x_max, d->hw_range_y_min, d->hw_range_y_max); + qCDebug(qLcEvdevTouch, "evdevtouch: found ti-tsc, overriding: min X: %d max X: %d min Y: %d max Y: %d", + d->hw_range_x_min, d->hw_range_x_max, d->hw_range_y_min, d->hw_range_y_max); } bool grabSuccess = !ioctl(m_fd, EVIOCGRAB, (void *) 1); @@ -551,6 +554,10 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) while (it.hasNext()) { it.next(); Contact &contact(it.value()); + + if (!contact.state) + continue; + if (contact.state == Qt::TouchPointReleased) { if (m_typeB) contact.state = static_cast<Qt::TouchPointState>(0); |