diff options
Diffstat (limited to 'src/platformsupport/input')
18 files changed, 256 insertions, 55 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri b/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri index c058498ba0..445f230fa5 100644 --- a/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri +++ b/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri @@ -7,6 +7,5 @@ SOURCES += \ $$PWD/qevdevkeyboardhandler.cpp \ $$PWD/qevdevkeyboardmanager.cpp -contains(QT_CONFIG, libudev) { - LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV -} +qtConfig(libudev): \ + QMAKE_USE_PRIVATE += libudev diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index ffe9f82325..94ebae8f42 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -84,10 +84,9 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this); if (m_deviceDiscovery) { // scan and add already connected keyboards - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) { + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addKeyboard(device); - } connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString))); diff --git a/src/platformsupport/input/evdevmouse/evdevmouse.pri b/src/platformsupport/input/evdevmouse/evdevmouse.pri index 7e7a9e1629..a8c9c663f3 100644 --- a/src/platformsupport/input/evdevmouse/evdevmouse.pri +++ b/src/platformsupport/input/evdevmouse/evdevmouse.pri @@ -6,7 +6,6 @@ SOURCES += \ $$PWD/qevdevmousehandler.cpp \ $$PWD/qevdevmousemanager.cpp -contains(QT_CONFIG, libudev) { - LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV -} +qtConfig(libudev): \ + QMAKE_USE_PRIVATE += libudev diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index 129654c99b..2d96691b09 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -90,10 +90,9 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this); if (m_deviceDiscovery) { // scan and add already connected keyboards - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) { + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addMouse(device); - } connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString))); diff --git a/src/platformsupport/input/evdevtablet/evdevtablet.pri b/src/platformsupport/input/evdevtablet/evdevtablet.pri index fb9489353c..ea1712ad2f 100644 --- a/src/platformsupport/input/evdevtablet/evdevtablet.pri +++ b/src/platformsupport/input/evdevtablet/evdevtablet.pri @@ -6,6 +6,5 @@ SOURCES += \ $$PWD/qevdevtablethandler.cpp \ $$PWD/qevdevtabletmanager.cpp -contains(QT_CONFIG, libudev) { - LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV -} +qtConfig(libudev): \ + QMAKE_USE_PRIVATE += libudev diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp index 00a8c7a65d..89a60df98d 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp @@ -85,8 +85,8 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery"; m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this); if (m_deviceDiscovery) { - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addDevice(device); connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); diff --git a/src/platformsupport/input/evdevtouch/evdevtouch.pri b/src/platformsupport/input/evdevtouch/evdevtouch.pri index c2edc13143..58fafcd8f9 100644 --- a/src/platformsupport/input/evdevtouch/evdevtouch.pri +++ b/src/platformsupport/input/evdevtouch/evdevtouch.pri @@ -6,12 +6,12 @@ SOURCES += \ $$PWD/qevdevtouchhandler.cpp \ $$PWD/qevdevtouchmanager.cpp -contains(QT_CONFIG, libudev) { - LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV -} +INCLUDEPATH += $$PWD/../shared + +qtConfig(libudev): \ + QMAKE_USE_PRIVATE += libudev -contains(QT_CONFIG, mtdev) { +qtConfig(mtdev) { CONFIG += link_pkgconfig PKGCONFIG_PRIVATE += mtdev } - diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 435f411f96..32ec9d5452 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qevdevtouchhandler_p.h" +#include "qtouchoutputmapping_p.h" #include <QStringList> #include <QHash> #include <QSocketNotifier> @@ -49,7 +50,7 @@ #include <QtGui/private/qguiapplication_p.h> #include <linux/input.h> -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) extern "C" { #include <mtdev.h> } @@ -116,6 +117,7 @@ public: int findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist); void addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates); void reportPoints(); + void loadMultiScreenMappings(); int hw_range_x_min; int hw_range_x_max; @@ -124,10 +126,12 @@ public: int hw_pressure_min; int hw_pressure_max; QString hw_name; + QString deviceNode; bool m_forceToActiveWindow; bool m_typeB; QTransform m_rotate; bool m_singleTouch; + int m_screenIndex; }; QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args) @@ -137,7 +141,8 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co hw_range_x_min(0), hw_range_x_max(0), hw_range_y_min(0), hw_range_y_max(0), hw_pressure_min(0), hw_pressure_max(0), - m_typeB(false), m_singleTouch(false) + m_typeB(false), m_singleTouch(false), + m_screenIndex(-1) { m_forceToActiveWindow = args.contains(QLatin1String("force_window")); } @@ -145,7 +150,7 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co #define LONG_BITS (sizeof(long) << 3) #define NUM_LONGS(bits) (((bits) + LONG_BITS - 1) / LONG_BITS) -#if defined(QT_NO_MTDEV) +#if !QT_CONFIG(mtdev) static inline bool testBit(long bit, const long *array) { return (array[bit / LONG_BITS] >> bit % LONG_BITS) & 1; @@ -154,7 +159,7 @@ static inline bool testBit(long bit, const long *array) QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const QString &spec, QObject *parent) : QObject(parent), m_notify(Q_NULLPTR), m_fd(-1), d(Q_NULLPTR), m_device(Q_NULLPTR) -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) , m_mtdev(Q_NULLPTR) #endif { @@ -198,7 +203,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const return; } -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) m_mtdev = static_cast<mtdev *>(calloc(1, sizeof(mtdev))); int mtdeverr = mtdev_open(m_mtdev, m_fd); if (mtdeverr) { @@ -210,7 +215,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const d = new QEvdevTouchScreenData(this, args); -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) const char *mtdevStr = "(mtdev)"; d->m_typeB = true; #else @@ -222,7 +227,9 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const } #endif - qCDebug(qLcEvdevTouch, "evdevtouch: %s: Protocol type %c %s (%s)", qPrintable(device), + d->deviceNode = device; + + qCDebug(qLcEvdevTouch, "evdevtouch: %s: Protocol type %c %s (%s)", qPrintable(d->deviceNode), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi"); input_absinfo absInfo; @@ -292,12 +299,20 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const if (inverty) d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5); + QTouchOutputMapping mapping; + if (mapping.load()) { + d->m_screenIndex = mapping.screenIndexForDeviceNode(d->deviceNode); + if (d->m_screenIndex >= 0) + qCDebug(qLcEvdevTouch, "evdevtouch: Mapping device %s to screen index %d", + qPrintable(d->deviceNode), d->m_screenIndex); + } + registerTouchDevice(); } QEvdevTouchScreenHandler::~QEvdevTouchScreenHandler() { -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) if (m_mtdev) { mtdev_close(m_mtdev); free(m_mtdev); @@ -322,7 +337,7 @@ void QEvdevTouchScreenHandler::readData() ::input_event buffer[32]; int events = 0; -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) forever { do { events = mtdev_get(m_mtdev, m_fd, buffer, sizeof(buffer) / sizeof(::input_event)); @@ -647,8 +662,23 @@ void QEvdevTouchScreenData::reportPoints() return; winRect = QHighDpi::toNativePixels(win->geometry(), win); } else { - QScreen *primary = QGuiApplication::primaryScreen(); - winRect = QHighDpi::toNativePixels(primary->geometry(), primary); + // Now it becomes tricky. Traditionally we picked the primaryScreen() + // and were done with it. But then, enter multiple screens, and + // suddenly it was all broken. + // + // For now we only support the display configuration of the KMS/DRM + // backends of eglfs. See QTouchOutputMapping. + // + // The good news it that once winRect refers to the correct screen + // geometry in the full virtual desktop space, there is nothing else + // left to do since qguiapp will handle the rest. + QScreen *screen = QGuiApplication::primaryScreen(); + if (m_screenIndex >= 0) { + const QList<QScreen *> screens = QGuiApplication::screens(); + if (m_screenIndex < screens.count()) + screen = screens.at(m_screenIndex); + } + winRect = QHighDpi::toNativePixels(screen->geometry(), screen); } const int hw_w = hw_range_x_max - hw_range_x_min; @@ -679,10 +709,12 @@ void QEvdevTouchScreenData::reportPoints() tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min); } + // Let qguiapp pick the target window. QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, q->touchDevice(), m_touchPoints); } + QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent) : QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(Q_NULLPTR), m_touchDeviceRegistered(false) { diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h index a423bbd2ef..6554d4998c 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QObject> #include <QString> #include <QList> @@ -58,7 +59,7 @@ #include <QtCore/private/qthread_p.h> #include <qpa/qwindowsysteminterface.h> -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) struct mtdev; #endif @@ -88,7 +89,7 @@ private: int m_fd; QEvdevTouchScreenData *d; QTouchDevice *m_device; -#if !defined(QT_NO_MTDEV) +#if QT_CONFIG(mtdev) mtdev *m_mtdev; #endif }; diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index 2de0816ef5..d0c6c10224 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -85,8 +85,8 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif qCDebug(qLcEvdevTouch) << "evdevtouch: Using device discovery"; m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this); if (m_deviceDiscovery) { - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addDevice(device); connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); diff --git a/src/platformsupport/input/input.pri b/src/platformsupport/input/input.pri index 3b9593eb31..eb4d8a983d 100644 --- a/src/platformsupport/input/input.pri +++ b/src/platformsupport/input/input.pri @@ -1,14 +1,18 @@ -contains(QT_CONFIG, evdev) { +qtConfig(evdev) { include($$PWD/evdevmouse/evdevmouse.pri) include($$PWD/evdevkeyboard/evdevkeyboard.pri) include($$PWD/evdevtouch/evdevtouch.pri) include($$PWD/evdevtablet/evdevtablet.pri) } -contains(QT_CONFIG, tslib) { +qtConfig(tslib) { include($$PWD/tslib/tslib.pri) } -contains(QT_CONFIG, libinput) { +qtConfig(libinput) { include($$PWD/libinput/libinput.pri) } + +qtConfig(evdev)|qtConfig(libinput) { + include($$PWD/shared/shared.pri) +} diff --git a/src/platformsupport/input/libinput/libinput.pri b/src/platformsupport/input/libinput/libinput.pri index 35d962ff3c..f922769a37 100644 --- a/src/platformsupport/input/libinput/libinput.pri +++ b/src/platformsupport/input/libinput/libinput.pri @@ -10,14 +10,11 @@ SOURCES += \ $$PWD/qlibinputkeyboard.cpp \ $$PWD/qlibinputtouch.cpp -INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV $$QMAKE_INCDIR_LIBINPUT -LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV $$QMAKE_LIBS_LIBINPUT +QMAKE_USE_PRIVATE += libudev libinput -contains(QT_CONFIG, xkbcommon-evdev) { - INCLUDEPATH += $$QMAKE_INCDIR_XKBCOMMON_EVDEV - LIBS_PRIVATE += $$QMAKE_LIBS_XKBCOMMON_EVDEV -} else { - DEFINES += QT_NO_XKBCOMMON_EVDEV -} +INCLUDEPATH += $$PWD/../shared -DEFINES += QT_LIBINPUT_VERSION_MAJOR=$$QMAKE_LIBINPUT_VERSION_MAJOR QT_LIBINPUT_VERSION_MINOR=$$QMAKE_LIBINPUT_VERSION_MINOR +qtConfig(xkbcommon-evdev): \ + QMAKE_USE_PRIVATE += xkbcommon_evdev +else: \ + DEFINES += QT_NO_XKBCOMMON_EVDEV diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index d5a3a8b437..3b583ec99d 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -96,7 +96,7 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e) void QLibInputPointer::processAxis(libinput_event_pointer *e) { -#if QT_LIBINPUT_VERSION_MAJOR == 0 && QT_LIBINPUT_VERSION_MINOR <= 7 +#if QT_LIBRARY_VERSION(libinput) < QT_VERSION_CHECK(0, 8, 0) const double v = libinput_event_pointer_get_axis_value(e) * 120; const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL ? Qt::Vertical : Qt::Horizontal; diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index 0a0e9daccb..42925a18e1 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -41,6 +41,7 @@ #include <libinput.h> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> +#include <QtGui/private/qhighdpiscaling_p.h> QT_BEGIN_NAMESPACE @@ -63,10 +64,14 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e static inline QPointF getPos(libinput_event_touch *e) { - const QSize screenSize = QGuiApplication::primaryScreen()->geometry().size(); - const double x = libinput_event_touch_get_x_transformed(e, screenSize.width()); - const double y = libinput_event_touch_get_y_transformed(e, screenSize.height()); - return QPointF(x, y); + // TODO Map to correct screen using QTouchOutputMapping. + // Perhaps investigate libinput_device_get_output_name as well. + // For now just use the primary screen. + QScreen *screen = QGuiApplication::primaryScreen(); + const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); + const double x = libinput_event_touch_get_x_transformed(e, geom.width()); + const double y = libinput_event_touch_get_y_transformed(e, geom.height()); + return geom.topLeft() + QPointF(x, y); } void QLibInputTouch::registerDevice(libinput_device *dev) diff --git a/src/platformsupport/input/shared/qtouchoutputmapping.cpp b/src/platformsupport/input/shared/qtouchoutputmapping.cpp new file mode 100644 index 0000000000..55c1dc34f4 --- /dev/null +++ b/src/platformsupport/input/shared/qtouchoutputmapping.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtouchoutputmapping_p.h" +#include <QFile> +#include <QVariantMap> +#include <QJsonDocument> +#include <QJsonObject> +#include <QJsonArray> + +QT_BEGIN_NAMESPACE + +bool QTouchOutputMapping::load() +{ + static QByteArray configFile = qgetenv("QT_QPA_EGLFS_KMS_CONFIG"); + if (configFile.isEmpty()) + return false; + + QFile file(QString::fromUtf8(configFile)); + if (!file.open(QFile::ReadOnly)) { + qWarning("touch input support: Failed to open %s", configFile.constData()); + return false; + } + + const QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); + if (!doc.isObject()) { + qWarning("touch input support: Failed to parse %s", configFile.constData()); + return false; + } + + // What we are interested is the virtualIndex and touchDevice properties for + // each element in the outputs array. + const QJsonArray outputs = doc.object().value(QLatin1String("outputs")).toArray(); + for (int i = 0; i < outputs.size(); ++i) { + const QVariantMap output = outputs.at(i).toObject().toVariantMap(); + if (!output.contains(QStringLiteral("touchDevice"))) + continue; + if (!output.contains(QStringLiteral("virtualIndex"))) { + qWarning("evdevtouch: Output %d specifies touchDevice but not virtualIndex, this is wrong", i); + continue; + } + const QString &deviceNode = output.value(QStringLiteral("touchDevice")).toString(); + const int screenIndex = output.value(QStringLiteral("virtualIndex")).toInt(); + m_screenIndexTable.insert(deviceNode, screenIndex); + } + + return true; +} + +int QTouchOutputMapping::screenIndexForDeviceNode(const QString &deviceNode) +{ + return m_screenIndexTable.value(deviceNode, -1); +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/input/shared/qtouchoutputmapping_p.h b/src/platformsupport/input/shared/qtouchoutputmapping_p.h new file mode 100644 index 0000000000..74999d93ce --- /dev/null +++ b/src/platformsupport/input/shared/qtouchoutputmapping_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTOUCHOUTPUTMAPPING_P_H +#define QTOUCHOUTPUTMAPPING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QString> +#include <QHash> + +QT_BEGIN_NAMESPACE + +class QTouchOutputMapping +{ +public: + bool load(); + int screenIndexForDeviceNode(const QString &deviceNode); + +private: + QHash<QString, int> m_screenIndexTable; +}; + +QT_END_NAMESPACE + +#endif // QTOUCHOUTPUTMAPPING_P_H diff --git a/src/platformsupport/input/shared/shared.pri b/src/platformsupport/input/shared/shared.pri new file mode 100644 index 0000000000..1443235244 --- /dev/null +++ b/src/platformsupport/input/shared/shared.pri @@ -0,0 +1,5 @@ +HEADERS += \ + $$PWD/qtouchoutputmapping_p.h + +SOURCES += \ + $$PWD/qtouchoutputmapping.cpp diff --git a/src/platformsupport/input/tslib/tslib.pri b/src/platformsupport/input/tslib/tslib.pri index c9fef1ca8f..9efd126e13 100644 --- a/src/platformsupport/input/tslib/tslib.pri +++ b/src/platformsupport/input/tslib/tslib.pri @@ -4,4 +4,4 @@ HEADERS += \ SOURCES += \ $$PWD/qtslib.cpp -LIBS += -lts +QMAKE_USE += tslib |