summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2016-10-27 13:29:13 +0200
committerGunnar Sletta <gunnar@sletta.org>2016-12-13 13:59:46 +0000
commite63f861e52b80aa3e6dbeb3c50649f666bc025b1 (patch)
treef6ca8e00fb67e89b42591179edae56720b45fca4 /src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
parent6755ec891a1740110c48895afd53d39e8370704a (diff)
Add support for filtering in the qevdevtouch plugin
This patch adds a Kalman filter to the evdev touch plugin which samples velocity and position in x and y direction and uses this to emit touch points in sync with the application's repaint rate. The filter also allows for basic prediction based on current position and velocity estimates. Filtering is opt-in, and can be enabled by passing for instance > app -plugin evdevtouch:/dev/touchscreen:filtered:prediction=16 The logic relies on a stable QWindow::requestUpdate() and will work best in combination with QtQuick and blocking swap buffers (or equivalent). QScreen::refreshRate() will also have to be reasonably accurate. [ChangeLog][Platform Specific Changes] The evdevtouch plugin now has the option to apply filtering and prediction. Enabled by passing "filtered" as an argument. Prediction can be specified by passing "prediction=X" as an argument, where X is in milliseconds. Change-Id: I682db4386fe3a7cef8b4a08ea0d16c1491efb873 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h')
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
index 6554d4998c..d22aca3266 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins module of the Qt Toolkit.
@@ -58,6 +59,7 @@
#include <QThread>
#include <QtCore/private/qthread_p.h>
#include <qpa/qwindowsysteminterface.h>
+#include "qevdevtouchfilter_p.h"
#if QT_CONFIG(mtdev)
struct mtdev;
@@ -78,10 +80,18 @@ public:
QTouchDevice *touchDevice() const;
+ bool isFiltered() const;
+
private slots:
void readData();
+signals:
+ void touchPointsUpdated();
+
private:
+ friend class QEvdevTouchScreenData;
+ friend class QEvdevTouchScreenHandlerThread;
+
void registerTouchDevice();
void unregisterTouchDevice();
@@ -104,16 +114,36 @@ public:
bool isTouchDeviceRegistered() const;
+ bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+
+public slots:
+ void scheduleTouchPointUpdate();
+
signals:
void touchDeviceRegistered();
private:
Q_INVOKABLE void notifyTouchDeviceRegistered();
+ void filterAndSendTouchPoints();
+ QRect targetScreenGeometry() const;
+
QString m_device;
QString m_spec;
QEvdevTouchScreenHandler *m_handler;
bool m_touchDeviceRegistered;
+
+ bool m_touchUpdatePending;
+ QWindow *m_filterWindow;
+
+ struct FilteredTouchPoint {
+ QEvdevTouchFilter x;
+ QEvdevTouchFilter y;
+ QWindowSystemInterface::TouchPoint touchPoint;
+ };
+ QHash<int, FilteredTouchPoint> m_filteredPoints;
+
+ float m_touchRate;
};
QT_END_NAMESPACE