Skip to content

Instantly share code, notes, and snippets.

@francip
Last active April 7, 2024 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francip/4183e2a860af34dd4aa0d1c98366f76b to your computer and use it in GitHub Desktop.
Save francip/4183e2a860af34dd4aa0d1c98366f76b to your computer and use it in GitHub Desktop.
Raspberry Pi touch input rotate for 1920 x 480 HDMI IPS Display
#!/bin/bash
# Rotate the display input
DEVICE_NAME="wch.cn USB2IIC_CTP_CONTROL"
PROPERTY_NAME="Coordinate Transformation Matrix"
# To run from SSH uncomment the following line
#export DISPLAY=:0
# Get the device ID
DEVICE_ID=$(xinput list | grep "$DEVICE_NAME" | awk '{print $5}' | tr -d 'id=')
if [ -n "$DEVICE_ID" ]; then
# Get the property ID
PROPERTY_ID=$(xinput list-props "$DEVICE_ID" | grep "$PROPERTY_NAME" | awk '{print $4}' | tr -d '(' | tr -d '):')
# Set the transformation matrix for 270-degree rotation
xinput set-prop "$DEVICE_ID" "$PROPERTY_ID" 0 -1 1 1 0 0 0 0 1
else
echo "Device not found"
fi
@ludufre
Copy link

ludufre commented Apr 6, 2024

Another option with persistance:

Create file at: /etc/X11/xorg.conf.d/99-calibration.conf

Section "InputClass"
	Identifier	"calibration"
	MatchProduct	"wch.cn USB2IIC_CTP_CONTROL"
	Option		"TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection

@francip
Copy link
Author

francip commented Apr 7, 2024

Interesting. I'll have to give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment