summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-04-13 13:39:19 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2024-04-09 21:10:47 +0000
commit3941fe697b9fea633f85321031ece765c532d46d (patch)
tree55ec9f6d2805f63f0a2eaf86bb4109074c0542de /src/platformsupport/input
parenta35f57d4290c898cda686fccfa7a7a3e08beffd6 (diff)
libinput: Allow setting touchscreen matrix via env var
[ChangeLog][QtGui][libinput] The environment variable QT_QPA_LIBINPUT_TOUCH_MATRIX now can be set with a string of 6 space-separated numbers to set the touchscreen transformation matrix. See docs for libinput_device_config_calibration_set_matrix() Fixes: QTBUG-68698 Change-Id: I72ba94e1ee6d39d31d1689ce6ce85fa8e676ff13 Reviewed-by: Dominik Holland <dominik.holland@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/platformsupport/input')
-rw-r--r--src/platformsupport/input/libinput/qlibinputtouch.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp
index 7e69f9e370..e3a483dc84 100644
--- a/src/platformsupport/input/libinput/qlibinputtouch.cpp
+++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp
@@ -61,6 +61,33 @@ QPointF QLibInputTouch::getPos(libinput_event_touch *e)
return geom.topLeft() + QPointF(x, y);
}
+static void setMatrix(libinput_device *dev)
+{
+ if (libinput_device_config_calibration_has_matrix(dev)) {
+ QByteArray env = qgetenv("QT_QPA_LIBINPUT_TOUCH_MATRIX");
+ env = env.simplified();
+ if (env.size()) {
+ float matrix[6];
+ QList<QByteArray> list = env.split(' ');
+ if (list.length() != 6) {
+ qCWarning(qLcLibInput, "matrix length %lld wrong, should be 6", list.length());
+ return;
+ }
+ for (int i = 0; i < 6; i++) {
+ bool ok = true;
+ matrix[i] = list[i].toFloat(&ok);
+ if (!ok) {
+ qCWarning(qLcLibInput, "Invalid matrix entry %d %s ", i, list[i].constData());
+ return;
+ }
+ }
+ if (libinput_device_config_calibration_set_matrix(dev, matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS)
+ qCWarning(qLcLibInput, "Failed to set libinput calibration matrix ");
+ }
+ } else {
+ qCWarning(qLcLibInput, "Touch device doesn't support matrix");
+ }
+}
void QLibInputTouch::registerDevice(libinput_device *dev)
{
struct udev_device *udev_device;
@@ -92,6 +119,7 @@ void QLibInputTouch::registerDevice(libinput_device *dev)
if (!geom.isNull())
devPriv->setAvailableVirtualGeometry(geom);
QWindowSystemInterface::registerInputDevice(td);
+ setMatrix(dev);
}
void QLibInputTouch::unregisterDevice(libinput_device *dev)