I have inherited a process that used Evdev as the touchscreen driver, It is from 7 years ago at least. Running on a Panasonic Toughbook. This is for touchscreen calibration. The issue is now we are running Ubuntu 22.04 and it uses libinput and not evdev to handle devices.
The previous touch screen mechanism is as follows:
- The system runs a bash1 file
- The bash file runs a program called 'setup'The 'setup' program operates as an evdev devise interface, with output relevant to configuring an evdev device driver.3.The output of 'setup' is parsed and put into a new file bash2
- bash2 is run every time the user logs in to maintain the calibration.
bash1 needs to be modified. It parses the output of 'setup' which has the below.
Matchproduct "Fujitsu Component USB Touch Panel"Option "MinX" "2197"Option "MaxX" "62185"Option "MinY" "6421"Option "MaxY" "2197"
It does a Sed command parsing this output and creates the Bash 2 file. This doesn't work now because the libinput calibration matrix is different. Can I just use the Sed command to hardcode the calibration for libinput? Trying to think of the best approach to this. Any advice is appreciated. libinput calibration is below.
Bash2 that is created doesn't work.xinput set-prop "Fujitsu Component USB Touch Panel" --format=32 "MinX" "2677"xinput set-prop "Fujitsu Component USB Touch Panel" --format=32 "MaxX" "61641"xinput set-prop "Fujitsu Component USB Touch Panel" --format=32 "MinY" "6706"xinput set-prop "Fujitsu Component USB Touch Panel" --format=32 "MaxY" "63300"
Certainly! To calibrate a touchscreen using libinput on Wayland, follow these steps:
Get to Know Your System:Determine the total width and height of your screen by running:$ xrandr | grep "*"
Note the values for width and height.Identify Your Touch Device:Run:$ xinput list
Find your touch device by its name (usually listed as [slave pointer (2)]).Execute:$ xinput list-props "Device Name"
Ensure there is a property called “Coordinate Transformation Matrix.”Define the Touch Area:Decide on the dimensions of your touch area (height, width, x offset, and y offset).Calculate the Calibration Matrix:Calculate the following values:c0 = touch_area_width / total_widthc2 = touch_area_height / total_heightc1 = touch_area_x_offset / total_widthc3 = touch_area_y_offset / total_heightThe matrix is represented as:[ c0 0 c1 ][ 0 c2 c3 ][ 0 0 1 ]
Apply the Matrix:Execute:$ xinput set-prop "Device Name" --type=float "Coordinate Transformation Matrix" c0 0 c1 0 c2 c3 0 0 1
Replace "Device Name" with your actual device name and use the calculated matrix values.Remember to adjust the values based on your specific touchscreen and monitor setup. If you encounter any issues, refer to the libinput documentation for further details.