|
|
| (26 intermediate revisions not shown) |
| Line 1: |
Line 1: |
| | Random tidbits of information about projects I'm hacking on... | | Random tidbits of information about projects I'm hacking on... |
| | | | |
| - | ==multi-point-touch==
| + | * [[User:Jketreno/multi-point-touch|Multi-Point-Touch on MeeGo]] |
| - | During the MeeGo Conference I gave a presentation on multi-point-touch support on MeeGo ([http://conference2010.meego.com/session/multi-touch-meego-hardware-user overview and video] [http://conference2010.meego.com/sites/all/files/sessions/meego-conference-2010-multi-point-touch.odp slides]). As mentioned during that presentation, to add multi-point-touch to Qt applications running on top of MeeGo 1.1 requires a few changes.
| + | * [[User:Jketreno/content|Improving MeeGo Content Management]] |
| - | | + | * [[User:Jketreno/scaling|A Density Independent UI on MeeGo]] |
| - | The components that need to be changed are:
| + | * [[User:Jketreno/theme-assets|Theme Assets]] |
| - | * Kernel -- You need kernel touch drivers that are in sync with upstream | + | * [[User:Jketreno/meego-image-resize|MeeGo Image Resize script]] |
| - | * Qt -- You need a version of Qt that does not have the RX71 code path enabled<sup>1</sup>
| + | |
| - | | + | |
| - | 1. '''NOTE''' The QT_RX71_MULTITOUCH code has been disabled in Trunk as of 4.7.1. See [http://bugs.meego.com/show_bug.cgi?id=8025 BMC#8025]
| + | |
| - | | + | |
| - | New components:
| + | |
| - | * mtdev -- Library to translate kernel protocol A and B to protocol B, adding tracking information
| + | |
| - | * xf86-input-mtev -- X input driver that communicates with mtdev to obtain multi-point data from the kernel | + | |
| - | * multipointtouchplugin -- in-application plugin which hooks to the Qt input event filter to process XInput events sent from xf86-input-mtev and injects QTouchEvent's into the Qt event queue
| + | |
| - | | + | |
| - | To get the above, you can add my home project:
| + | |
| - | cd /etc/zypp/repos.d
| + | |
| - | sudo wget http://download.meego.com/live/home:/jketreno/Trunk/home:jketreno.repo
| + | |
| - | sudo sed -i -e 's,^gpg,#gpg,g' home:jketreno.repo
| + | |
| - | zypper refresh
| + | |
| - | | + | |
| - | Next, force a re-installation of the packages provided from my home project:
| + | |
| - | zypper install -f --from=home_jketreno kernel-netbook mtdev xf86-input-mtev multipointtouchplugin
| + | |
| - | | + | |
| - | It will prompt you to switch to the versions of the various packages provided from the above repository. Accept the changes, and reboot.
| + | |
| - | | + | |
| - | ==enabling a native application==
| + | |
| - | The mechanism to talk to the xf86-input-mtev driver is not merged into the Qt package itself. Until that occurs, applications interested in working with touch events need to add the following to the beginning of their application, within the '''main()''' function:
| + | |
| - | foreach (QString path, QCoreApplication::libraryPaths()) {
| + | |
| - | QPluginLoader loader(path + "/libmultipointtouchplugin.so");
| + | |
| - | loader.load();
| + | |
| - | if (loader.isLoaded()) {
| + | |
| - | loader.instance();
| + | |
| - | break;
| + | |
| - | }
| + | |
| - | }
| + | |
| - | At the beginning of the file, you also need to include QPluginLoader:
| + | |
| - | #include <QPluginLoader>
| + | |
| - | And that's it.
| + | |
| - | ==enabling a QML application==
| + | |
| - | The version of qmlviewer provided with the Qt package does not include the plug-in loader logic. As such, touch events are not available when running QML applications under qmlviewer. To work around this, you need to provide a native loader for your QML, adding the code described the steps above for '''enabling a native applications'''.
| + | |
| - | | + | |
| - | ==qml-gesturearea==
| + | |
| - | As Frederik Gladhorn indicated during [http://conference2010.meego.com/session/gestures-qt his talk] at the MeeGo Conference in Dublin, the folks over at Qt have been working on an improved QML GestureArea component.
| + | |
| - | | + | |
| - | You can pull and play with what they're cooking as follows:
| + | |
| - | git clone git://gitorious.org/qt-labs/qml-gesturearea.git
| + | |
| - | git clone git://gitorious.org/qt-labs/qml-gestures-examples.git
| + | |
| - | If you are building qml-gesturearea with a version of Qt prior to 4.7.1, you may need to patch it to get it to build:
| + | |
| - | cd qml-gesturearea
| + | |
| - | sed -i -e 's,q->timeout(),700,g' qdeclarativegesturerecognizers.cpp
| + | |
| - | qmake
| + | |
| - | make && sudo make install
| + | |
| - | ===install multipointtouchplugin into qml-gesturearea===
| + | |
| - | In order to work with the xf86-input-mtev and multipointtouchplugin, we need to pump the touch events into the application process. Since we aren't modifying Qt, we can modify the qml-gesturearea plugin to load this by adding the following code to plugin.cpp:
| + | |
| - | | + | |
| - | In the beginning of the file:
| + | |
| - | @@ -44,6 +44,8 @@
| + | |
| - | #include "gestureareaplugin_p.h"
| + | |
| - | #include "qdeclarativegesturearea_p.h"
| + | |
| - | #include "qdeclarativegesturerecognizers_p.h"
| + | |
| - | +#include <QPluginLoader>
| + | |
| - | +#include <QCoreApplication>
| + | |
| - |
| + | |
| - | QT_BEGIN_NAMESPACE
| + | |
| - | and then at the end of GestureAreaQmlPlugin::registerTypes():
| + | |
| - | @@ -81,6 +83,16 @@ void GestureAreaQmlPlugin::registerTypes(const char *uri)
| + | |
| - | QGestureRecognizer::registerRecognizer(new QPinchGestureRecognizer());
| + | |
| - | QGestureRecognizer::registerRecognizer(new QSwipeGestureRecognizer());
| + | |
| - | #endif
| + | |
| - | +
| + | |
| - | + // Hack to load multipointtouchplugin
| + | |
| - | + foreach (QString path, QCoreApplication::libraryPaths()) {
| + | |
| - | + QPluginLoader loader(path + "/libmultipointtouchplugin.so");
| + | |
| - | + loader.load();
| + | |
| - | + if (loader.isLoaded()) {
| + | |
| - | + loader.instance();
| + | |
| - | + break;
| + | |
| - | + }
| + | |
| - | + }
| + | |
| - | }
| + | |
| - | | + | |
| - | ==how multipointouchplugin works==
| + | |
| - | The multi-point touch plugin is intended to proof out multi-point touch interaction with Qt, without having to make invasive changes to Qt 4.7 itself. Ultimately, by MeeGo 1.2, we need to create a patch to Qt deployed on MeeGo such that each application does not have to load the plug-in.
| + | |
| - | | + | |
| - | Internally, the plug-in (in the MultiPointTouch constructor) first make sure the XInput extension exists and supports version 2.0 of the protocol.
| + | |
| - | | + | |
| - | When an X FocusIn event is received, the plugin walks through all of the available input devices looking for any that expose a valuator with the "Abs MT Tracking ID" label. Any X input device using xf86-input-mtev will expose this data. For each device found, it subscribes to button press, release, and motion events.
| + | |
| - | | + | |
| - | When an X FocusOut event is received, the same logic is used to find which devices to unsubscribe from.
| + | |
| - | | + | |
| - | The plug-in's registered eventFilter does a few checks to determine that an inbound event is the correct type, and if so, it then calls a method to translate the event to Touch events (translateEvent)
| + | |
| - | | + | |
| - | Within translateEvent, the valuators are parsed, scaled, and set onto list of active QTouchEvent::TouchPoint's.
| + | |
| - | | + | |
| - | If each touch point is immediately fed into the Qt input queue, via qt_translateRawTouchEvent, input becomes very laggy and the Qt application behaves very sluggishly. So, each of the TouchPoints is instead placed into a pending queue and then all events remaining in the Qt input queue are processed via processEvents(). Once that returns, the batch of queued touch events are dispatched.
| + | |
| - | | + | |
| - | ==core pointer==
| + | |
| - | If you do nothing, X will default to binding the touch device to the Core Pointer. This means that as you move your finger around, mouse events will be generated, the cursor will move, etc. If X is already running, you can use the xinput utility to "float" the touch device. On the Lenovo S10, running 'xinput list' shows something like the following:
| + | |
| - | | + | |
| - | ⎡ Virtual core pointer id=2 [master pointer (3)]
| + | |
| - | ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
| + | |
| - | ⎜ ↳ Cando Corporation Cando 10.1 Multi Touch Panel with Controller id=13 [slave pointer (2)]
| + | |
| - | ⎜ ↳ SynPS/2 Synaptics TouchPad id=16 [slave pointer (2)]
| + | |
| - | ...
| + | |
| - | | + | |
| - | Looking at the above, you can see the touch device (Cando Corporation...) is device id 13. To float that input device, run:
| + | |
| - | | + | |
| - | xinput float 13
| + | |
| - | | + | |
| - | and verify that touching the screen no longer moves the mouse pointer.
| + | |
| - | | + | |
| - | To perform the following every time you start X, you can add:
| + | |
| - | Option "SendCoreEvents" "false"
| + | |
| - | to the InputClass section for the device, for example you can place the following in /usr/share/X11/xorg.conf.d as 60-cando.conf:
| + | |
| - | Section "InputClass"
| + | |
| - | Identifier "Cando Multi Touch Panel"
| + | |
| - | MatchVendor "Cando"
| + | |
| - | MatchDevicePath "/dev/input/event*"
| + | |
| - | Driver "mtev"
| + | |
| - | Option "SendCoreEvents" "false"
| + | |
| - | EndSection
| + | |
| - | | + | |
| - | Having the input device disconnected from the Core Pointer, combined with the FocusIn/FocusOut mechanism in the multipointtouchplugin means that window focus will have to be given to windows via an actual mouse pointer (since X will no longer be parsing touch input as an Core pointer input device) or by other means (pressing the application in the app switcher, for example)
| + | |
Random tidbits of information about projects I'm hacking on...