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.

    • Related Articles

    • Rotate or Swap Touch Calibration - Linux

      How can I rotate or swap the X and Y touch coordinates on Linux? On Linux systems—or any operating system that does not support DISPLAX Connect—you may need to manually rotate or swap the touch coordinates. This is common on platforms such as ...
    • DISPLAX Skin Works With Linux

      Can DISPLAX Skin touch sensors be used with Linux? Yes. DISPLAX products work with Linux, provided the operating system includes a HID multitouch driver. DISPLAX products behave like other standard USB HID devices (such as keyboards, mice, or USB ...
    • DISPLAX Connect Does Not Start on Ubuntu

      Why does DISPLAX Connect fail to launch on Ubuntu? On some Ubuntu systems, DISPLAX Connect may fail to start because a required Qt library dependency is missing. Qt applications rely on several system libraries that are not always installed by ...
    • One Skin with Dual Monitors (Skin working on just one monitor)

      How can I use one DISPLAX Skin with dual monitors and enable touch on only one screen? When using dual monitors on Ubuntu (or similar Linux distributions), touch input may default to only one display or behave incorrectly. To ensure the DISPLAX Skin ...
    • Touch Accuracy Offset

      Overview After achieving optimal touch performance and completing calibration, you may notice a touch accuracy offset—where the physical touch position does not match the location shown on the display. This issue is usually caused by display scaling ...