From a89c5d34160fd16bfbc434b231200636cd0782b0 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Tue, 6 Sep 2022 13:56:46 +0200 Subject: weston-init: support weston touch calibration Add a new PACKAGECONFIG touchscreen-calibration, when it's enabled, add the following fields in weston.ini: ``` [libinput] enable_tap=true touchscreen_calibrator=true calibration_helper=/usr/bin/toradex-save-touchscreen-calibration ``` When weston-touch-calibrator is called by an end user, /usr/bin/toradex-save-touchscreen-calibration will be triggered to create a udev rule to export LIBINPUT_CALIBRATION_MATRIX then trigger that udev rule. The end users need to restart weston to let the new calibration matrix to take effect. Related-to: ELB-4570 Signed-off-by: Ming Liu --- recipes-graphics/wayland/weston-init.bbappend | 19 +++++++++++++++++++ .../toradex-save-touchscreen-calibration.sh | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 recipes-graphics/wayland/weston-init.bbappend create mode 100755 recipes-graphics/wayland/weston-init/toradex-save-touchscreen-calibration.sh diff --git a/recipes-graphics/wayland/weston-init.bbappend b/recipes-graphics/wayland/weston-init.bbappend new file mode 100644 index 0000000..7a385c0 --- /dev/null +++ b/recipes-graphics/wayland/weston-init.bbappend @@ -0,0 +1,19 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" + +SRC_URI += "file://toradex-save-touchscreen-calibration.sh" + +PACKAGECONFIG[touchscreen-calibration] = ",," +PACKAGECONFIG:append:tdx = " touchscreen-calibration" + +INI_UNCOMMENT_ASSIGNMENTS:append:tdx = " \ + \\[libinput\\] \ + enable_tap=true \ +" + +do_install:append:tdx() { + if [ "${@bb.utils.contains('PACKAGECONFIG', 'touchscreen-calibration', 'yes', 'no', d)}" = "yes" ]; then + sed -i -e "/^\[libinput\]/a calibration_helper=${bindir}/toradex-save-touchscreen-calibration" ${D}${sysconfdir}/xdg/weston/weston.ini + sed -i -e "/^\[libinput\]/a touchscreen_calibrator=true" ${D}${sysconfdir}/xdg/weston/weston.ini + install -Dm0755 ${WORKDIR}/toradex-save-touchscreen-calibration.sh ${D}${bindir}/toradex-save-touchscreen-calibration + fi +} diff --git a/recipes-graphics/wayland/weston-init/toradex-save-touchscreen-calibration.sh b/recipes-graphics/wayland/weston-init/toradex-save-touchscreen-calibration.sh new file mode 100755 index 0000000..e2871fc --- /dev/null +++ b/recipes-graphics/wayland/weston-init/toradex-save-touchscreen-calibration.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$#" -ne 7 ]; then + echo "This script is to be called by weston with new touch calibration data, it requires 7 parameters." + exit 1 +fi + +echo 'ACTION=="add|change", SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}=''"'"$2 $3 $4 $5 $6 $7"'"' > /etc/udev/rules.d/libinput.rules + +# Make udev process the new rule by triggering a "change" event: +udevadm trigger "$1" -- cgit v1.2.3