From bc3cfebc66a046e0c6548624ada9f49701faf0d1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 1 Jun 2012 10:36:51 +0300 Subject: evdevtablet plugin Change-Id: Ie8fbaac929180e6d4c626253c4c20d1b3a9083f5 Reviewed-by: Paul Olav Tvete Reviewed-by: Girish Ramakrishnan --- src/plugins/generic/evdevtablet/README | 44 +++++++++++++ src/plugins/generic/evdevtablet/evdevtablet.json | 3 + src/plugins/generic/evdevtablet/evdevtablet.pro | 13 ++++ src/plugins/generic/evdevtablet/main.cpp | 79 ++++++++++++++++++++++++ src/plugins/generic/generic.pro | 2 +- 5 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/plugins/generic/evdevtablet/README create mode 100644 src/plugins/generic/evdevtablet/evdevtablet.json create mode 100644 src/plugins/generic/evdevtablet/evdevtablet.pro create mode 100644 src/plugins/generic/evdevtablet/main.cpp (limited to 'src/plugins') diff --git a/src/plugins/generic/evdevtablet/README b/src/plugins/generic/evdevtablet/README new file mode 100644 index 0000000000..a7bb481d07 --- /dev/null +++ b/src/plugins/generic/evdevtablet/README @@ -0,0 +1,44 @@ +Generic plug-in for accessing pen-based tablets via evdev + +To test, run the demo app from examples/widgets/tablet with the +command-line argument -plugin EvdevTablet + +Known to work with 3rd generation Wacom Bamboo Pen & Touch. Recent +tablets like this one may need an updated wacom kernel driver for +kernels 3.2 and older. + +Supports x, y, pressure, pen & eraser pointer types, proximity enter, +proximity leave. The additional advanced fields of QTabletEvent will +not be utilized. + +Connecting the tablet will result in two input devices: one for finger +touch and the tablet buttons, and another for pen input including the +stylus buttons. This plugin cares about the latter only. For touch, +try the evdevtouch plugin. + +The plugin generates QTabletEvents only. For compatibility with Qt 4, +TabletPress, Move and Release are only sent when the stylus is +touching the screen. + +TabletEnterProximity and TabletLeaveProximity are always sent to the +QGuiApplication instance. Use an event filter (or subclass) to handle +these. In proximity events most of the data (incl. position) will be +left unspecified as these are mere indication of the fact that the +stylus entered the range of the tablet. + +When running under X, it is likely that no events are received due to +the input device being grabbed. A temporary workaround is to disable +the device from X via +xinput set-prop 0. + + +TODO #1: Indicate motion when lifted but still in proximity. Needs new +event types. + +TODO #1.1: Where to report ABS_DISTANCE? Needs a new QTabletEvent member +(unless we hijack z). + +TODO #2: QKeyEvent from the stylus buttons (BTN_STYLUS, BTN_STYLUS2, +but there are no suitable Qt::Key_* constants?) + +TODO #3: QKeyEvent in evdevtouch (or this plugin?) from tablet buttons diff --git a/src/plugins/generic/evdevtablet/evdevtablet.json b/src/plugins/generic/evdevtablet/evdevtablet.json new file mode 100644 index 0000000000..7190668162 --- /dev/null +++ b/src/plugins/generic/evdevtablet/evdevtablet.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "EvdevTablet" ] +} diff --git a/src/plugins/generic/evdevtablet/evdevtablet.pro b/src/plugins/generic/evdevtablet/evdevtablet.pro new file mode 100644 index 0000000000..5b5edc28d6 --- /dev/null +++ b/src/plugins/generic/evdevtablet/evdevtablet.pro @@ -0,0 +1,13 @@ +TARGET = qevdevtabletplugin +load(qt_plugin) + +DESTDIR = $$QT.gui.plugins/generic +target.path = $$[QT_INSTALL_PLUGINS]/generic +INSTALLS += target + +SOURCES = main.cpp + +QT += core-private platformsupport-private + +OTHER_FILES += \ + evdevtablet.json diff --git a/src/plugins/generic/evdevtablet/main.cpp b/src/plugins/generic/evdevtablet/main.cpp new file mode 100644 index 0000000000..9863defad0 --- /dev/null +++ b/src/plugins/generic/evdevtablet/main.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + +class QEvdevTabletPlugin : public QGenericPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtablet.json") + +public: + QEvdevTabletPlugin(); + + QStringList keys() const; + QObject* create(const QString &key, const QString &specification); +}; + +QEvdevTabletPlugin::QEvdevTabletPlugin() +{ +} + +QStringList QEvdevTabletPlugin::keys() const +{ + return QStringList() << "EvdevTablet"; +} + +QObject *QEvdevTabletPlugin::create(const QString &key, + const QString &spec) +{ + if (!key.compare(QLatin1String("EvdevTablet"), Qt::CaseInsensitive)) + return new QEvdevTabletHandlerThread(spec); + + return 0; +} + +QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/generic/generic.pro b/src/plugins/generic/generic.pro index 86b529b39e..f2e3bd3f44 100644 --- a/src/plugins/generic/generic.pro +++ b/src/plugins/generic/generic.pro @@ -3,5 +3,5 @@ TEMPLATE = subdirs linux-g++-maemo: SUBDIRS += meego contains(QT_CONFIG, evdev) { - SUBDIRS += evdevmouse evdevtouch evdevkeyboard + SUBDIRS += evdevmouse evdevtouch evdevkeyboard evdevtablet } -- cgit v1.2.3