diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-10-13 13:50:49 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-10-16 13:08:06 +0200 |
commit | cf046ccec0e9a2f174e6dc47f23cc8c4d5c1a935 (patch) | |
tree | 2b463f94769fff21a829e5fc6cf46e0dd1989a1d | |
parent | 5cd6cd198c87bc31cb1189d6c605b4a3bd005257 (diff) |
Clean up tslib plugin
The code is now cleaned up, properly divided between platformsupport and
the actual plugin (like evdev) and categorized logging is in use.
This will allow us to use tslib as a built-in input handler in eglfs in
the future.
Change-Id: Ic87cdcfe8049bb98530e7f26ffa7a77611a8ede3
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
-rw-r--r-- | src/platformsupport/input/input.pri | 4 | ||||
-rw-r--r-- | src/platformsupport/input/tslib/qtslib.cpp (renamed from src/plugins/generic/tslib/qtslib.cpp) | 30 | ||||
-rw-r--r-- | src/platformsupport/input/tslib/qtslib_p.h (renamed from src/plugins/generic/tslib/qtslib.h) | 8 | ||||
-rw-r--r-- | src/platformsupport/input/tslib/tslib.pri | 7 | ||||
-rw-r--r-- | src/plugins/generic/tslib/main.cpp | 15 | ||||
-rw-r--r-- | src/plugins/generic/tslib/tslib.pro | 7 |
6 files changed, 35 insertions, 36 deletions
diff --git a/src/platformsupport/input/input.pri b/src/platformsupport/input/input.pri index 1524eb454e..c1fd95703b 100644 --- a/src/platformsupport/input/input.pri +++ b/src/platformsupport/input/input.pri @@ -4,3 +4,7 @@ contains(QT_CONFIG, evdev) { include($$PWD/evdevtouch/evdevtouch.pri) include($$PWD/evdevtablet/evdevtablet.pri) } + +contains(QT_CONFIG, tslib) { + include($$PWD/tslib/tslib.pri) +} diff --git a/src/plugins/generic/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index a8f60b69ff..dea2c7cb72 100644 --- a/src/plugins/generic/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the plugins module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage @@ -31,32 +31,32 @@ ** ****************************************************************************/ - -#include "qtslib.h" - +#include "qtslib_p.h" #include <QSocketNotifier> #include <QStringList> #include <QPoint> +#include <QLoggingCategory> + #include <qpa/qwindowsysteminterface.h> #include <errno.h> #include <tslib.h> -#include <qdebug.h> - QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(qLcTsLib, "qt.qpa.input") + QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, - const QString &specification) + const QString &specification) : m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false) { - qDebug() << "QTsLibMouseHandler" << key << specification; + qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification; setObjectName(QLatin1String("TSLib Mouse Handler")); QByteArray device = qgetenv("TSLIB_TSDEVICE"); - if (specification.startsWith("/dev/")) + if (specification.startsWith(QStringLiteral("/dev/"))) device = specification.toLocal8Bit(); if (device.isEmpty()) @@ -69,27 +69,26 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, } if (ts_config(m_dev)) - perror("Error configuring\n"); + qErrnoWarning(errno, "ts_config() failed"); - m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive); + m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive); 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, SIGNAL(activated(int)), this, SLOT(readMouseData())); } else { - qWarning("Cannot open mouse input device '%s': %s", device.constData(), strerror(errno)); + qErrnoWarning(errno, "tslib: Cannot open input device %s", device.constData()); } } - QTsLibMouseHandler::~QTsLibMouseHandler() { if (m_dev) ts_close(m_dev); } - static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode) { if (rawMode) @@ -98,7 +97,6 @@ static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode return (ts_read(dev, sample, 1) == 1); } - void QTsLibMouseHandler::readMouseData() { ts_sample sample; @@ -123,8 +121,6 @@ void QTsLibMouseHandler::readMouseData() } QPoint pos(x, y); - //printf("handleMouseEvent %d %d %d %ld\n", m_x, m_y, pressed, sample.tv.tv_usec); - QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton); m_x = x; diff --git a/src/plugins/generic/tslib/qtslib.h b/src/platformsupport/input/tslib/qtslib_p.h index cd11ca5e2f..da18abea46 100644 --- a/src/plugins/generic/tslib/qtslib.h +++ b/src/platformsupport/input/tslib/qtslib_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the plugins module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage @@ -34,13 +34,13 @@ #ifndef QTSLIB_H #define QTSLIB_H -#include <qobject.h> -//#include <Qt> +#include <QObject> + +struct tsdev; QT_BEGIN_NAMESPACE class QSocketNotifier; -struct tsdev; class QTsLibMouseHandler : public QObject { diff --git a/src/platformsupport/input/tslib/tslib.pri b/src/platformsupport/input/tslib/tslib.pri new file mode 100644 index 0000000000..c9fef1ca8f --- /dev/null +++ b/src/platformsupport/input/tslib/tslib.pri @@ -0,0 +1,7 @@ +HEADERS += \ + $$PWD/qtslib_p.h + +SOURCES += \ + $$PWD/qtslib.cpp + +LIBS += -lts diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp index 737b175941..1fbe440bb5 100644 --- a/src/plugins/generic/tslib/main.cpp +++ b/src/plugins/generic/tslib/main.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include <QtGui/qgenericplugin.h> -#include "qtslib.h" +#include <QtPlatformSupport/private/qtslib_p.h> QT_BEGIN_NAMESPACE @@ -42,21 +42,16 @@ class QTsLibPlugin : public QGenericPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "tslib.json") public: - QTsLibPlugin(); - QObject* create(const QString &key, const QString &specification); }; -QTsLibPlugin::QTsLibPlugin() - : QGenericPlugin() -{ -} - QObject* QTsLibPlugin::create(const QString &key, - const QString &specification) + const QString &specification) { - if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) + if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) + || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) return new QTsLibMouseHandler(key, specification); + return 0; } diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro index bc05efcc32..be6fc4fbea 100644 --- a/src/plugins/generic/tslib/tslib.pro +++ b/src/plugins/generic/tslib/tslib.pro @@ -5,12 +5,9 @@ PLUGIN_EXTENDS = - PLUGIN_CLASS_NAME = QTsLibPlugin load(qt_plugin) -HEADERS = qtslib.h +SOURCES = main.cpp -SOURCES = main.cpp \ - qtslib.cpp - -QT += gui-private +QT += gui-private platformsupport-private LIBS += -lts |