Skip to content

Troubleshooting / Touchscreen

Official Raspberry Pi Touchscreen Is Upside Down

Rotate a Raspberry Pi touchscreen and align touch input, with current desktop guidance and legacy X11 Coordinate Transformation Matrix commands.

Raspberry PiOfficial TouchscreenBy Vilros

Overview

Display orientation and touch coordinates are separate settings. Rotate the picture first, then check whether touches line up at all four corners. The correct method depends on your OS and desktop session.

Use desktop orientation settings first

On current Raspberry Pi OS desktop, open Preferences → Control Centre → Screens, select the touch display and choose its orientation. Older desktops may call this tool Screen Configuration. Apply the change and test touches at each corner.

To identify the current session, run this in a terminal inside the logged-in desktop:

echo "$XDG_SESSION_TYPE"

If it reports wayland, use the compositor or desktop's touch-mapping settings; the X11 commands below do not configure native Wayland input. If touch already follows the rotated picture correctly, do not add another transform.

Legacy LCD flip

For older firmware-controlled display setups, lcd_rotate=2 in /boot/config.txt is a legacy 180-degree LCD flip. Back up the file before editing it and reboot to test; remove the added setting to undo.

Do not treat lcd_rotate=1 or lcd_rotate=3 as universal 90/270-degree display and touch rotation settings. Modern KMS and desktop input systems use different controls. For a non-desktop KMS setup, consult the official Touch Display documentation rather than combining arbitrary desktop and Device Tree transforms.

Map touch coordinates on legacy X11

Run these commands in an X11 desktop terminal.

They change touch coordinates only. They do not rotate the picture, and they do not belong in config.txt. Use them only when touch still needs alignment after the display is rotated.

  1. Confirm the session command above reports x11.
  2. Find the touchscreen's actual device name:
    xinput list
  3. Inspect its properties and record the existing nine Coordinate Transformation Matrix values before making a change:
    xinput list-props 'raspberrypi-ts'

    raspberrypi-ts is an example from older official-display setups. Replace it in every command if your touchscreen has another name.

  4. Choose one of the options below, then test every corner. Do not run all four commands in sequence.

These are full-panel mappings for normalized coordinates with the origin at the top-left, x increasing rightward and y downward. Their labels describe touch-coordinate movement, not screen rotation. Existing calibration or multi-monitor mapping may require a different combined transform.

Clockwise 90-degree coordinate mapping

(x, y) → (1 − y, x)

xinput set-prop 'raspberrypi-ts' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

180-degree coordinate mapping

(x, y) → (1 − x, 1 − y)

xinput set-prop 'raspberrypi-ts' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1

Counterclockwise 90-degree coordinate mapping

(x, y) → (y, 1 − x)

xinput set-prop 'raspberrypi-ts' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

Identity / no coordinate rotation

(x, y) → (x, y)

xinput set-prop 'raspberrypi-ts' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1

Undo and persistence

If alignment is wrong, run xinput set-prop for the same device and property with the nine values you recorded. The identity option above only restores an originally untransformed mapping; it is not a universal reset for a system with calibration or multi-screen mapping.

Runtime settings can be lost at logout or device reconnection. Test first, then use an appropriate X11 desktop autostart mechanism if you need persistence. Keep shell commands out of config.txt, and avoid applying a second touch transform on top of an already-correct desktop mapping.

Further help

For another display fault, see vertical lines on the official 7-inch touchscreen. When asking for help, include the display model, OS version, session type and the orientation or mapping changes you tried.