Touchscreen calibration

I found that I use my laptop’s touch screen more frequently – it is particularly useful for image editing. However, when I work in my (home) office I also use a multi-screen set-up with three monitors. The problem is that the touch region of the laptop screen automatically gets scaled to the overall size of my screen, which spans multiple monitors.

Therefore an updated calibration of the laptop touchscreen was in order.

xinput
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ ELAN Touchscreen id=11 [slave pointer (2)] ⎜ ↳ DLL075B:01 06CB:76AF Touchpad id=13 [slave pointer (2)] ⎜ ↳ PS/2 Generic Mouse id=26 [slave pointer (2)] ⎜ ↳ HID 1267:0103 Consumer Control id=14 [slave pointer (2)] ⎜ ↳ MOSART Semi. 2.4G Keyboard Mouse Consumer Control id=17 [slave pointer (2)] ⎜ ↳ MOSART Semi. 2.4G Keyboard Mouse id=27 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ Sleep Button id=9 [slave keyboard (3)] ↳ Integrated_Webcam_HD: Integrate id=12 [slave keyboard (3)] ↳ Intel Virtual Button driver id=21 [slave keyboard (3)] ↳ Intel HID events id=22 [slave keyboard (3)] ↳ Intel HID 5 button array id=23 [slave keyboard (3)] ↳ Dell WMI hotkeys id=24 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=25 [slave keyboard (3)] ↳ MOSART Semi. 2.4G Keyboard Mouse id=10 [slave keyboard (3)] ↳ HID 1267:0103 Consumer Control id=15 [slave keyboard (3)] ↳ HID 1267:0103 System Control id=16 [slave keyboard (3)] ↳ MOSART Semi. 2.4G Keyboard Mouse Consumer Control id=18 [slave keyboard (3)] ↳ HID 1267:0103 id=19 [slave keyboard (3)] ↳ MOSART Semi. 2.4G Keyboard Mouse System Control id=20 [slave keyboard (3)]

Our touch screen device is listed as “ELAN Touchscreen” with device ID 11.

xinput list-props “ELAN Touchscreen”
Device ‘ELAN Touchscreen’: Device Enabled (146): 1 Coordinate Transformation Matrix (148): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 libinput Calibration Matrix (285): 0.526316, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 libinput Calibration Matrix Default (286): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 libinput Send Events Modes Available (268): 1, 0 libinput Send Events Mode Enabled (269): 0, 0 libinput Send Events Mode Enabled Default (270): 0, 0 Device Node (271): “/dev/input/event13” Device Product ID (272): 1267, 8400

The important line above is the one giving the nine transformation matrix components used in the conversion of raw x and y touch coordinates to display pixel positions.

For a 3200×1800 laptop screen resolution and 3x 4K external monitors, we would need to replace the x scaling factor of 1.0 with 0.206611570:

echo ‘scale=9; 3200/(3200+3*4096)’ | bc
.206611570
xinput set-float-prop “ELAN Touchscreen” “libinput Calibration Matrix” 0.206611570 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0

If the laptop resolution was 1600×900 and a single external monitor with 1440×900 resolution was connected to it, the command would be:

echo ‘scale=9; 1600/(1600+1440)’ | bc
.526315789
xinput set-float-prop “ELAN Touchscreen” “libinput Calibration Matrix” 0.526315789 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0

To reset the touchscreen scaling to the original values issue the following command (or one with the values you obtained during the initial check)

xinput set-float-prop “ELAN Touchscreen” “libinput Calibration Matrix” 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0

There is also a little program dedicated to calibrating touch devices:

sudo apt-get install xinput-calibrator xinput_calibrator –output-type xinput # …

… and another example

xinput set-float-prop “ELAN Touchscreen” “libinput Calibration Matrix” .555555555 0.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0

Leave a Reply

Your email address will not be published. Required fields are marked *