An inverted touchscreen on Ubuntu 24.04.2 LTS can be incredibly frustrating – when you touch the bottom of your screen, the system registers input at the top, or left touches register as right. This comprehensive guide will walk you through multiple proven methods to diagnose and fix this issue, ensuring your touchscreen works exactly as intended.
Touchscreen inversion occurs when the coordinate system used by your touchscreen doesn't properly align with your display. On Ubuntu 24.04.2 LTS, this typically happens due to one of the following reasons:
Before attempting any fix, it's important to identify whether your system is using X11 or Wayland as the display server, as the solutions differ. You can check this by running echo $XDG_SESSION_TYPE
in a terminal.
The most direct approach for X11 users is modifying the touchscreen's Coordinate Transformation Matrix using the xinput command.
Open a terminal and run:
xinput list
Look for your touchscreen device in the output. It might appear as something like "eGalaxTouch", "ILITEK", "Wacom", or similar. Note the ID number or name.
To view the current properties for your device, run:
xinput list-props "Your Touchscreen Name"
Replace "Your Touchscreen Name" with the actual name from the previous step. Look for "Coordinate Transformation Matrix" in the output.
xinput set-prop "Your Touchscreen Name" "Coordinate Transformation Matrix" 1 0 0 0 -1 1 0 0 1
xinput set-prop "Your Touchscreen Name" "Coordinate Transformation Matrix" -1 0 1 0 1 0 0 0 1
xinput set-prop "Your Touchscreen Name" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
These changes will take effect immediately, allowing you to test if the transformation fixes your touchscreen inversion issue.
The xinput method works immediately but doesn't persist after reboots. For a permanent solution, creating a udev rule is recommended.
cat /proc/bus/input/devices
Look for your touchscreen device in the output and note details such as name, handler, etc.
sudo nano /etc/udev/rules.d/99-touchscreen-calibration.rules
Add the following line, replacing "Your Touchscreen Name" with your actual device name:
ATTRS{name}=="Your Touchscreen Name", ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 -1 1 0 0 1"
Choose the appropriate matrix values based on which axis needs to be inverted (see the transformation matrix options from Method 1).
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo reboot
After rebooting, your touchscreen should have the correct orientation permanently.
Ubuntu 24.04.2 LTS uses Wayland as the default display server, which handles touchscreen input differently than X11.
The easiest workaround is to switch to X11 which offers more straightforward touchscreen calibration:
For Wayland sessions, you can create a libinput configuration file:
sudo mkdir -p /etc/libinput
sudo nano /etc/libinput/local-overrides.quirks
Add the following content, adjusting the matrix values as needed:
[Touchscreen Calibration]
MatchName=Your Touchscreen Name
AttrCalibrationMatrix=1 0 0 0 -1 1 0 0 1
Save the file and reboot your system.
For convertible laptops or tablets, the autorotate command can be useful:
# To invert the display
autorotate invert --display eDP-1
# To restore normal orientation
autorotate normal --display eDP-1
Replace "eDP-1" with your actual display name, which you can find by running xrandr
.
Below is a visual comparison of the different methods to fix touchscreen inversion, rated across multiple factors:
The Coordinate Transformation Matrix is a 3x3 matrix that transforms touch input coordinates. Here's a reference table of common transformation matrices for different orientations:
Touchscreen Issue | Transformation Matrix | xinput Command |
---|---|---|
Normal (no inversion) | 1 0 0 0 1 0 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1 |
Y-axis inverted (top/bottom) | 1 0 0 0 -1 1 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" 1 0 0 0 -1 1 0 0 1 |
X-axis inverted (left/right) | -1 0 1 0 1 0 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" -1 0 1 0 1 0 0 0 1 |
Both X and Y inverted | -1 0 1 0 -1 1 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1 |
90° clockwise rotation | 0 1 0 -1 0 1 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1 |
90° counterclockwise rotation | 0 -1 1 1 0 0 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1 |
180° rotation | -1 0 1 0 -1 1 0 0 1 | xinput set-prop "Device" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1 |
This mindmap illustrates the various approaches to solving touchscreen inversion issues in Ubuntu 24.04.2 LTS, organized by display server and solution type:
This helpful video by Novaspirit Tech demonstrates how to create accel_mount_matrix data for tablet PCs to fix screen rotation issues in Ubuntu Linux, which applies to touchscreen inversion problems as well:
The video covers the creation of calibration matrices for Linux touchscreens, which is particularly useful if you're using a tablet PC or convertible laptop with Ubuntu 24.04.2 LTS. It demonstrates practical examples of how to apply the fixes discussed in this guide.
Below are images showing the touchscreen configuration process in Ubuntu:
Using xrandr to check your display configuration
Ubuntu Display Settings panel where you can adjust screen orientation
Adding transformation matrix to libinput configuration file
To ensure your touchscreen configuration persists across reboots, you can choose from several methods:
#!/bin/bash
# Place this script in ~/.config/autostart/
# Make it executable with: chmod +x ~/.config/autostart/fix-touchscreen.sh
xinput set-prop "Your Touchscreen Name" "Coordinate Transformation Matrix" 1 0 0 0 -1 1 0 0 1
As described in Method 2, this is the most robust solution for persistence across reboots.