Touchscreen Orientation Using udev Rules

Touchscreen Orientation Using udev Rules

Configure Touchscreen Orientation in Linux Using udev Rules

When using a DISPLAX touch controller on Linux, the touch orientation may need to be adjusted to match the display orientation. This can be achieved by creating a udev rule that applies a libinput calibration matrix automatically whenever the controller is connected.

This method is particularly useful for:

  • Rotated displays (Portrait mode)

  • Inverted touch coordinates


Step 1 – Identify the DISPLAX Touch Controller

Locate the DISPLAX touch controller in the output and note its kernel path:

/dev/input/eventX

Replace X with the event number corresponding to your controller.

Next, retrieve the Vendor ID and Model ID:

udevadm info -q property -n /dev/input/eventX | grep -E "ID_VENDOR_ID|ID_MODEL_ID"

Example output:

ID_VENDOR_ID=14e1
ID_MODEL_ID=6000

Record both values, as they will be required when creating the rule.


Step 2 – Choose the Appropriate Calibration Matrix

libinput uses a calibration matrix to transform touch coordinates.

Select the matrix that matches your installation:

OrientationMatrix
Standard (Default)1 0 0 0 1 0
Invert X-axis-1 0 1 0 1 0
Invert Y-axis1 0 0 0 -1 1
Rotate 180°-1 0 1 0 -1 1
Rotate 90° Clockwise0 -1 1 1 0 0
Rotate 90° Counter-Clockwise0 1 0 -1 0 1

Tip: If the touch orientation is incorrect after applying a matrix, simply modify the rule and test another orientation.


Step 3 – Create the udev Rule

Create a new rule file:

sudo nano /etc/udev/rules.d/99-touchscreen-calibration.rules

Add the following line:

ENV{ID_VENDOR_ID}=="XXXX", ENV{ID_MODEL_ID}=="YYYY", ENV{LIBINPUT_CALIBRATION_MATRIX}="<insert_matrix_here>"

Replace:

  • XXXX with the Vendor ID

  • YYYY with the Model ID

  • <insert_matrix_here> with the desired calibration matrix

Example

For a touchscreen that requires Y-axis inversion:

ENV{ID_VENDOR_ID}=="14e1", ENV{ID_MODEL_ID}=="6000", ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 -1 1"

Save the file and exit the editor.


Step 4 – Apply the New Configuration

Reload the udev rules:

sudo udevadm control --reload-rules
sudo udevadm trigger

Verify that the calibration matrix is attached to the device:

udevadm info -q property -n /dev/input/eventX | grep LIBINPUT_CALIBRATION_MATRIX

The output should display the configured matrix.


Step 5 – Reinitialize the Touch Controller

To ensure the new settings take effect:

  • Disconnect and reconnect the controller's USB cable, or

  • Log out and back into the Linux session

On Wayland-based systems, logging out and back in is often required for the compositor to reload the input device configuration.


Troubleshooting

The touch orientation did not change

  • Verify that the correct /dev/input/eventX device was used.

  • Confirm the Vendor ID and Model ID match the connected controller.

  • Check the rule syntax for typing errors.

  • Reload the udev rules after every modification.

The calibration matrix is not shown

Run:

udevadm info -q property -n /dev/input/eventX

and verify that the LIBINPUT_CALIBRATION_MATRIX property appears in the output.