Documentskiosk-mode---swap-the-x-and-y-axes-of-the-mouse

Kiosk mode - swap the X and Y axes of the Mouse

If your touch screen is in portrait mode, the touch directions may need to be swapped to match.

When a touch screen is used in portrait mode, touch input can be off by an axis. You fix this by changing the coordinate matrix of the touch device. The method depends on the player OS.

Raspberry Pi OS Trixie (Wayland, labwc)

The xinput method further down works only under X11. Trixie runs Wayland with the labwc compositor, where xinput has no effect. Use libinput's calibration matrix in labwc instead. libinput takes 6 values (the first two rows of the 3x3 matrix), so the 9-value matrix becomes 6 values.

  1. Find the touch device name. Look for the entry with Capabilities: touch and note its Device: name (for example ILITEK ILITEK-TP).

    libinput list-devices
    
  2. Edit the labwc config file.

    sudo nano ~/.config/labwc/rc.xml
    
  3. Add a libinput device block inside the existing root element, with your device name.

    <libinput>
      <device deviceName="ILITEK ILITEK-TP">
        <calibrationMatrix>0 1 0 -1 0 1</calibrationMatrix>
      </device>
    </libinput>
    
  4. Apply the change.

    labwc --reconfigure
    

    You can also restart lightdm instead.

    sudo systemctl restart lightdm
    

Matrix values for each orientation

Orientation Matrix
Default / landscape 1 0 0 0 1 0
90° clockwise 0 -1 1 1 0 0
180° -1 0 1 0 -1 1
270° 0 1 0 -1 0 1

If the display is also rotated, bind touch input to that output with a <touch> element instead of relying on the matrix alone: <touch deviceName="..." mapToOutput="HDMI-A-1"/>


Legacy X11 players (xinput)

These steps apply only to legacy X11-based players.

  1. Install xinput.

    sudo apt-get install -y xinput
    
  2. Set the display to the HDMI monitor.

    export DISPLAY=:0.0
    
  3. List the input devices and find the ID of your touch device.

    xinput --list
    

    In this example output the ID is 7 (Logitech USB Receiver).

    Virtual core pointer                    id=2 [master pointer  (3)]
    
    ⎜   ↳ Virtual core XTEST pointer              id=4 [slave  pointer  (2)]
    
    ⎜   ↳ Logitech USB Receiver                   id=7 [slave  pointer  (2)]
    
    ⎣ Virtual core keyboard                   id=3 [master keyboard (2)]
    
        ↳ Virtual core XTEST keyboard             id=5 [slave  keyboard (3)]
    
        ↳ Logitech USB Receiver                   id=6 [slave  keyboard (3)]
    
        ↳ Logitech USB Receiver                   id=8 [slave  keyboard (3)]
    
  4. Apply the coordinate transformation matrix with that ID (7 in this example).

    xinput --set-prop 7 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
    

For wiring in buttons, switches or a keyboard see Connecting other hardware.