From 093a1a6232083e5b9c18a9e85e5759ba3ce280fb Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 25 Mar 2019 12:47:21 +0100 Subject: tslib: use ts_setup() to find the device This automatically searches for some default devices. This not only reduces the amount of code, it also makes sure that Qt will by default find the same input devices that tslib (e.g. ts_calibrate) will find. Fixes: QTBUG-74680 Change-Id: Ied3fff7e8ed9d6637d2b8cf32119660133d251a3 Reviewed-by: Laszlo Agocs --- src/platformsupport/input/tslib/qtslib.cpp | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src/platformsupport/input') diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index f8fdc151ec..c4caea5c80 100644 --- a/src/platformsupport/input/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -62,31 +62,15 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification; setObjectName(QLatin1String("TSLib Mouse Handler")); - QByteArray device = qgetenv("TSLIB_TSDEVICE"); - - if (specification.startsWith(QLatin1String("/dev/"))) - device = specification.toLocal8Bit(); - - if (device.isEmpty()) - device = QByteArrayLiteral("/dev/input/event1"); - - m_dev = ts_open(device.constData(), 1); + m_dev = ts_setup(nullptr, 1); if (!m_dev) { - qErrnoWarning(errno, "ts_open() failed"); + qErrnoWarning(errno, "ts_setup() failed"); return; } - if (ts_config(m_dev)) - qErrnoWarning(errno, "ts_config() failed"); - - int fd = ts_fd(m_dev); - if (fd >= 0) { - qCDebug(qLcTsLib) << "tslib device is" << device; - m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(m_notify, &QSocketNotifier::activated, this, &QTsLibMouseHandler::readMouseData); - } else { - qErrnoWarning(errno, "tslib: Cannot open input device %s", device.constData()); - } + qCDebug(qLcTsLib) << "tslib device is" << ts_get_eventpath(m_dev); + m_notify = new QSocketNotifier(ts_fd(m_dev), QSocketNotifier::Read, this); + connect(m_notify, &QSocketNotifier::activated, this, &QTsLibMouseHandler::readMouseData); } QTsLibMouseHandler::~QTsLibMouseHandler() -- cgit v1.2.3