Skip to content

Touch Calibration

When you rotate the display, touch input also needs rotation. The GUI method handles this automatically, but command-line rotation requires manual touch calibration.

Touch rotation uses a libinput calibration matrix. Each rotation angle has a specific matrix:

RotationMatrix Values
0° (default)1 0 0 0 1 0
90° (left)0 -1 1 1 0 0
180° (inverted)-1 0 1 0 -1 1
270° (right)0 1 0 -1 0 1

Create a udev rule file:

Terminal window
sudo nano /etc/udev/rules.d/99-waveshare-touch.rules

Add the appropriate line for your rotation:

Terminal window
# For 90° rotation
ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 -1 1 1 0 0"
# For 180° rotation
# ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1"
# For 270° rotation
# ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1"

Uncomment only the line matching your display rotation.

Reboot to apply:

Terminal window
sudo reboot

The display supports two touch modes in Raspberry Pi OS:

  • Single touch controls mouse cursor
  • Tap = left click
  • Long press = right click
  • Double-tap supported
  • Best for desktop use
  • Full 10-point multitouch
  • Pinch-to-zoom, gestures
  • No right-click or double-tap
  • Best for touch-optimized applications
  1. Open Menu → Preferences → Control Center → Screens
  2. Select Touchscreen tab
  3. Choose Mouse Emulation or Multitouch
  4. Click Apply
Terminal window
# List input devices
cat /proc/bus/input/devices | grep -A5 "Goodix"

You should see:

N: Name="Goodix Capacitive TouchScreen"
Terminal window
# Install evtest if needed
sudo apt install evtest
# Monitor touch events
sudo evtest /dev/input/event0

Touch the screen - you should see coordinate data.

IssueSolution
Touch doesn’t respondCheck power connection, verify GT9271 detected
Touch offset from displayApply calibration matrix matching rotation
Touch invertedWrong matrix - try different rotation value
Multitouch not workingEnable Multitouch mode in Screen Configuration

See Touch Problems for more solutions.