Solutions to several problems I had with linux on a touchscreen-equiped laptop.
When installing linux on laptop, I started having a few problems with the touchscreen, especially when trying to rotate or extend the screen.
Know how to identify your devices
To manipulate input devices, I use xinput
. To deal with displays, I use
xrandr
or the graphical interface. I need the identifiers of my devices
in order to be able to interact with these.
xinput list --long | less
By examining the output of xinput, you can identify the device mentioning “touch” and get its id. In my case:
export TOUCHSCREEN='ATML1000:00 E206:5883'
Xrandr can tell you how your monitors are named.
xrandr | less
In my case, I get:
export MAINSCREEN='eDP-1'
export HDMISCREEN='HDMI-1'
How to disable the touchscreen
xinput --enable "$TOUCHSCREEN"
xinput --disable "$TOUCHSCREEN"
My setup is a simple script that flips the touchscreen on and off.
Code
Extending the screen
When using the graphical interface or xrandr
to extend your screen, you might
experience some trouble with the touchscreen.
xrandr --output "$MAINSCREEN" --mode "1920x1080" --primary \
--output "$HDMISCREEN" --mode "1920x1080" --right-of "$MAINSCREEN"
In my case, the touch area gets mapped to the whole display area: if I touch on the right part of the touchscreen, it clicks on the right display.
A simple solution to that is to tell xinput
that the touchscreen corresponds
only to the main display.
xinput map-to-output "$TOUCHSCREEN" "$MAINSCREEN"
Rotating the screen
I use xrandr
to rotate the screen in order to use the “tablet” mode.
xrandr --output "$MAINSCREEN" --rotate inverted
However, the touchscreen does not get “rotated” and you can guess that the result is a huge mess. This can be solved by using xinput.
xinput set-prop "$TOUCHSCREEN" "Coordinate Transformation Matrix" "-1 0 1 0 -1 1 0 0 1"
Here’s how my script looks like.