We have devices with touchscreens that we calibrate using xinput_calibrator, then apply the settings in a launch script for our application, along the lines of
xinput set-int-prop "Microchip Technology Inc. AR1100 HID-MOUSE" "Evdev Axis Calibration" 32 109 3841 161 3973
xinput set-int-prop "Microchip Technology Inc. AR1100 HID-MOUSE" "Evdev Axes Swap" 8 1
xinput set-int-prop "Microchip Technology Inc. AR1100 HID-MOUSE" "Evdev Axis Calibration" 32 3852 112 3970 159
This works well - sometimes. At other times, following a power cycle, the calibration will not take effect - the axes are swapped, in particular, and scaling seems off, though that's harder to say. A couple more power cycles and it will work again, then not.
We're new to X11 and aren't sure why this is happening. It's as though our xinput statements are being processed sometimes and ignored other times, though nothing has changed other than rebooting.
Any thoughts on how to address this are appreciated.
Since there seems to be a race condition between X11 server startup process and xinput
call, you will have to wait for the startup process to complete. I suggest you check this answer for hints on how to detect that X server is running normally.
If that doesn't work, you should try to check the return code of xinput
and wait for a success before configuring the touchscreen. For example:
ts_dev="Microchip Technology Inc. AR1100 HID-MOUSE"
ts_calibrate="Evdev Axis Calibration"
ts_swap="Evdev Axes Swap"
# repeat until xinput returns success for the first time
while ! xinput set-int-prop "$ts_dev" "$ts_calibrate" 32 109 3841 161 3973
do
sleep 1
done
xinput set-int-prop "$ts_dev" "$ts_swap" 8 1
xinput set-int-prop "$ts_dev" "$ts_calibrate" 32 3852 112 3970 159
You may need to adapt the script for the values that xinput
returns on your system.