summaryrefslogtreecommitdiffstats
path: root/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-12-17 21:15:50 +0200
committerQt by Nokia <qt-info@nokia.com>2011-12-19 17:29:10 +0100
commit2edada763af005367810dda09ca0cdb5adc494b9 (patch)
treea597225b584dc26f9b9f4b6d986fb7dd54b3c885 /src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
parent87679491cb21088223fcd656e0e49793874e4a9e (diff)
Update the touchscreen plug-in.
Now works with bcm5974: Added manual contact tracking for drivers that do not report a tracking id and fixed abs limit querying to use ABS_MT_* instead of ABS_*. Fixed reported area: The incoming point was the top-left point instead of the center which was incorrect. Added pressure support. Tracking of event type has been removed as handleTouchEvent no longer needs it. Broken debug prints have been removed. Changed udev auto-detection to pick only /dev/input/event*. Fixed multiple released state reports with some drivers. Name and capabilities are now set properly for the QTouchDevice. Change-Id: I8f026c9a14465bfb6d567f4dcf36c5c03f843868 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp')
-rw-r--r--src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
index a62f9360c7..2a1f3d5ef3 100644
--- a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
+++ b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
@@ -47,8 +47,6 @@
QT_BEGIN_NAMESPACE
-//#define POINT_DEBUG
-
QTouchEventSenderQPA::QTouchEventSenderQPA(const QString &spec)
{
m_forceToActiveWindow = spec.split(QLatin1Char(':')).contains(QLatin1String("force_window"));
@@ -58,12 +56,22 @@ QTouchEventSenderQPA::QTouchEventSenderQPA(const QString &spec)
QWindowSystemInterface::registerTouchDevice(m_device);
}
-void QTouchEventSenderQPA::touch_configure(int x_min, int x_max, int y_min, int y_max)
+void QTouchEventSenderQPA::touch_configure(int x_min, int x_max, int y_min, int y_max,
+ int pressure_min, int pressure_max,
+ const QString &dev_name)
{
hw_range_x_min = x_min;
hw_range_x_max = x_max;
hw_range_y_min = y_min;
hw_range_y_max = y_max;
+
+ hw_pressure_min = pressure_min;
+ hw_pressure_max = pressure_max;
+
+ m_device->setName(dev_name);
+
+ if (hw_pressure_max > hw_pressure_min)
+ m_device->setCapabilities(m_device->capabilities() | QTouchDevice::Pressure);
}
void QTouchEventSenderQPA::touch_point(const QList<QWindowSystemInterface::TouchPoint> &points)
@@ -78,32 +86,28 @@ void QTouchEventSenderQPA::touch_point(const QList<QWindowSystemInterface::Touch
winRect = QGuiApplication::primaryScreen()->geometry();
}
-#ifdef POINT_DEBUG
- qDebug() << "QPA: Mapping" << points.size() << "points to" << winRect << state;
-#endif
+ const int hw_w = hw_range_x_max - hw_range_x_min;
+ const int hw_h = hw_range_y_max - hw_range_y_min;
QList<QWindowSystemInterface::TouchPoint> touchPoints = points;
- // Translate the coordinates and set the normalized position. QPA expects
- // 'area' to be in screen coordinates, while the device reports them in its
- // own system with (0, 0) being the center point of the device.
+ // Map the coordinates based on the normalized position. QPA expects 'area'
+ // to be in screen coordinates.
for (int i = 0; i < touchPoints.size(); ++i) {
QWindowSystemInterface::TouchPoint &tp(touchPoints[i]);
- const int hw_w = hw_range_x_max - hw_range_x_min;
- const int hw_h = hw_range_y_max - hw_range_y_min;
-
- qreal nx = tp.normalPosition.x();
- qreal ny = tp.normalPosition.y();
-
- // Generate a screen position that is always inside the active window or the default screen.
- const int wx = winRect.left() + int(nx * winRect.width());
- const int wy = winRect.top() + int(ny * winRect.height());
+ // Generate a screen position that is always inside the active window
+ // or the primary screen.
+ const int wx = winRect.left() + int(tp.normalPosition.x() * winRect.width());
+ const int wy = winRect.top() + int(tp.normalPosition.y() * winRect.height());
const qreal sizeRatio = (winRect.width() + winRect.height()) / qreal(hw_w + hw_h);
- tp.area = QRect(wx, wy, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio);
+ tp.area = QRect(0, 0, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio);
+ tp.area.moveCenter(QPoint(wx, wy));
-#ifdef POINT_DEBUG
- qDebug() << " " << i << tp.area << tp.state << tp.id << tp.flags << tp.pressure;
-#endif
+ // Calculate normalized pressure.
+ if (!hw_pressure_min && !hw_pressure_max)
+ tp.pressure = tp.state == Qt::TouchPointReleased ? 0 : 1;
+ else
+ tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min);
}
QWindowSystemInterface::handleTouchEvent(0, m_device, touchPoints);