HMI
Rotating a Raspberry Pi 4 Touch Monitor

I recently had to develop an application (kiosk system) for/on a Raspberry Pi 4. The special thing about it was that 2 touch monitors were to be connected via HDMI, which also had to be rotated 90 degrees to the right. So, portrait mode, with 2 monitors on top of each other. Rotating the screen and arranging the monitors on top of one another did not cause any problems, since this is easily to do via the user interface – a "Raspbian Buster with desktop and recommended software" was installed. To do this, go to the menu "Raspberry -> Preferences -> Screen Configuration" and rotate the two HDMI monitors to the right, arrange them one above the other, and then save your settings. The problem with this is that the touch configuration is not automatically rotated and arranged one above the other, together providing a large touch area over 2 monitors. In order for the touch properties to work properly, 2 configuration files – /usr/share/X11/xorg.conf.d/40-libinput.conf and /home/pi/.profile – have to be adapted.

To do this, you first have to read the IDs of the connected monitors. To do this, open a terminal and enter the command

xinput list

. This will cause the connected monitors to be listed along with the associated IDs. In my case, the monitors had IDs 6 and 7.

Then, in the file /usr/share/X11/xorg.conf.d/40-libinput.conf, adapt the section "Section InputClass" with the "Identifier libinput touchpad catchall" as follows:

Section "InputClass" 
        Identifier "libinput touchpad catchall" 
        MatchIsTouchscreen "on" 
        Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1" 
        MatchDevicePath "/dev/input/event*" 
        Driver "libinput" 
EndSection

This causes the touch surface to rotate.

Finally, at the end of the /home/pi/.profile file, insert the element that subdivides the touch surface into 2 parts of the same size, so that this is loaded each time the system is started.

xinput set-prop "6" --type=float "Coordinate Transformation Matrix" 1 0 0 0 0.5 0 0 0 1
xinput set-prop "7" --type=float "Coordinate Transformation Matrix" 1 0 0 0 0.5 0.5 0 0 1