diff mbox series

[kirkstone,7/7] weston-init: add a simple touchscreen calibration check

Message ID 20230524181122.35202-8-rs@ti.com
State Accepted
Delegated to: Ryan Eatmon
Headers show
Series Rootless Weston and Weston patch cleanup | expand

Commit Message

Randolph Sapp May 24, 2023, 6:11 p.m. UTC
From: Randolph Sapp <rs@ti.com>

The old touchscreen calibration script created a generic UDEV rule for
all touch devices that applied the LIBINPUT_CALIBRATION_MATRIX of the
last calibrated display. This attempts to replace that to an extent.

This script executes at the start of Weston and if it detects a touch
input device, uses Weston's built in touchscreen calibrator and
touchscreen calibrator interface to apply the current calibration
without restarting Weston. This script does not attempt to make these
calibration values persistent.

If a user wants calibration values to persist for all Weston users they
should add the calibration to /etc/default/weston using the
LIBINPUT_CALIBRATION_MATRIX variable themselves. The script will bypass
calibration if it detects this variable is already set.

Signed-off-by: Randolph Sapp <rs@ti.com>
---
 .../recipes-graphics/wayland/weston-init.bbappend   | 13 ++++++++++---
 .../wayland/weston-init/weston-launch-calibrator.sh | 13 +++++++++++++
 .../recipes-graphics/wayland/weston-init/weston.ini |  4 ++++
 3 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100644 meta-arago-distro/recipes-graphics/wayland/weston-init/weston-launch-calibrator.sh
diff mbox series

Patch

diff --git a/meta-arago-distro/recipes-graphics/wayland/weston-init.bbappend b/meta-arago-distro/recipes-graphics/wayland/weston-init.bbappend
index a73b669d..4d5db58c 100644
--- a/meta-arago-distro/recipes-graphics/wayland/weston-init.bbappend
+++ b/meta-arago-distro/recipes-graphics/wayland/weston-init.bbappend
@@ -2,6 +2,13 @@  FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
 
 PR:append = ".arago12"
 
-#SRC_URI:append = " \
-#    file://weston.ini \
-#"
+SRC_URI:append = " \
+    file://weston.ini \
+    file://weston-launch-calibrator.sh \
+"
+
+do_install:append() {
+    install -Dm755 weston-launch-calibrator.sh ${D}/${bindir}/weston-launch-calibrator
+}
+
+FILES:${PN}:append = "${bindir}/weston-launch-calibrator"
diff --git a/meta-arago-distro/recipes-graphics/wayland/weston-init/weston-launch-calibrator.sh b/meta-arago-distro/recipes-graphics/wayland/weston-init/weston-launch-calibrator.sh
new file mode 100644
index 00000000..45863ecd
--- /dev/null
+++ b/meta-arago-distro/recipes-graphics/wayland/weston-init/weston-launch-calibrator.sh
@@ -0,0 +1,13 @@ 
+#!/bin/sh
+
+if [ -e /dev/input/touchscreen0 ]; then
+	echo "Touch screen detected..."
+	if [ -n "$LIBINPUT_CALIBRATION_MATRIX" ]; then
+		echo "Calibration matrix already present, skipping calibration..."
+	else
+		echo "Calibrating touchscreen..."
+		exec weston-calibrator
+	fi
+else
+	echo "Touch screen not detected, skipping calibration..."
+fi
diff --git a/meta-arago-distro/recipes-graphics/wayland/weston-init/weston.ini b/meta-arago-distro/recipes-graphics/wayland/weston-init/weston.ini
index 4cc2683a..b9610fa8 100644
--- a/meta-arago-distro/recipes-graphics/wayland/weston-init/weston.ini
+++ b/meta-arago-distro/recipes-graphics/wayland/weston-init/weston.ini
@@ -11,6 +11,10 @@  startup-animation=fade
 [libinput]
 touchscreen_calibrator=true
 
+[autolaunch]
+# launch the calibrator on startup if a touchscreen is detected
+path=/usr/bin/weston-launch-calibrator
+
 [screensaver]
 # Uncomment path to disable screensaver
 #path=@libexecdir@/weston-screensaver