Skip to content

Commit

Permalink
A few fixes to evdev touch filtering
Browse files Browse the repository at this point in the history
- Clamp the position to the bounding rect of the device
- Send TouchRelease only once

Change-Id: I8776079dbc886612e6adfb1fef5ec7cf14a8af3b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
  • Loading branch information
sletta committed Jan 9, 2017
1 parent 5dce744 commit 1d15a17
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
Expand Up @@ -878,8 +878,12 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints()

tp.velocity = QVector2D(f.x.velocity() * winRect.width(), f.y.velocity() * winRect.height());

tp.normalPosition = QPointF(f.x.position() + f.x.velocity() * m_handler->d->m_prediction / 1000.0,
f.y.position() + f.y.velocity() * m_handler->d->m_prediction / 1000.0);
qreal filteredNormalizedX = f.x.position() + f.x.velocity() * m_handler->d->m_prediction / 1000.0;
qreal filteredNormalizedY = f.y.position() + f.y.velocity() * m_handler->d->m_prediction / 1000.0;

// Clamp to the screen
tp.normalPosition = QPointF(qBound<qreal>(0, filteredNormalizedX, 1),
qBound<qreal>(0, filteredNormalizedY, 1));

qreal x = winRect.x() + (tp.normalPosition.x() * (winRect.width() - 1));
qreal y = winRect.y() + (tp.normalPosition.y() * (winRect.height() - 1));
Expand All @@ -889,7 +893,10 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints()
// Store the touch point for later so we can release it if we've
// missed the actual release between our last update and this.
f.touchPoint = tp;
filteredPoints[tp.id] = f;

// Don't store the point for future reference if it is a release.
if (tp.state != Qt::TouchPointReleased)
filteredPoints[tp.id] = f;
}

for (QHash<int, FilteredTouchPoint>::const_iterator it = m_filteredPoints.constBegin(), end = m_filteredPoints.constEnd(); it != end; ++it) {
Expand Down

0 comments on commit 1d15a17

Please sign in to comment.