Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Touchscreen calibration procedue for Debian9 (stretch)

Touchscreen Calibration in Debian9

Unfortunately xinput-calibrator does not work at all for calibrating a touchscreen in Debian9. This is apparently because X server now uses libinput to handle input devices instead of evdev. I spent huge amount of trying to fiddling with xinput-calibrator and 99-calibration.conf files until I finely found this issue on GitHub that gave me some hints as how to proceed. This is mostly for my own reference, but I hope it might also help others in the same situation.

Install xinput

This not not seem to be installed by defaults on Debian9

$ sudo apt-get install xinput

Determine the screen size

You probably already know this, but if you have multiple screens they might be see as one big screen. So to determine the total size run

$ xrandr

This will print out a good bit of information, but what you are interested in is the current vales in the first line, which will look something like this:

Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192

Determine the name of the touch device

Next step it to find the touch device's name

$ xinput list

Look for the touch device in the Virtual core pointer section. In my case the device name is Elo TouchSystems 2700 IntelliTouch(r).

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Elo TouchSystems 2700 IntelliTouch(r)     id=12   [slave  pointer  (2)]
⎜   ↳ 2.4G Mouse                                id=10   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]

Now run

$ xinput list-props <device name>

were <device-name> is the name you determined in the last step.

Confirm that the list of properties includes near the top a property called Coordinate Transformation Matrix. If it does not, you probably have the wrong device name.

Set the Coordinate Transformation Matrix

The screen is calibrated using a Coordinate Transformation Matrix, which defaults to the identity matrix.

[1 0 0]
[0 1 0]
[0 0 1]

for convenient entry, the matrix is flatted into a single line like this

1 0 0 0 1 0 0 0 1

were the valuse seem to map like this

[hscale] [vskew] [hoffset] [hskew] [vscale] [voffset] 0 0 1

Here is a very nice interactive tool for visualizing the effect of the various values:

Apply the calibration matrix by saying

xinput set-prop '<device name>' 'Coordinate Transformation Matrix' 1.04 0 -0.02 0 1.04 -0.02 0 0 1

I just experimented with the values until I had the scree calibrated, it only took a few iterations to get so the pointer was exactly under were I touched.


Copy link

Rowbotronics commented Jan 14, 2019

This was super helpful for me, thanks for posting it!

Copy link

0E800 commented Apr 11, 2019

Thank you for leaving breadcrumbs. Excellent material.

Copy link

zhenisotarbay commented Apr 17, 2019

What if I have done rotation first, shall I do the same commands?

Copy link

pquiring commented Jun 24, 2019

Thanks for this post!
For my Elo 2218 the x=22 and y=38 and I use a for loop since the device id seems to change sometimes (if I have a keyboard plugged in).

for i in {4..15}
  xinput set-prop $i "libinput Calibration Matrix" 1.22 0.0 -0.11 0.0 1.38 -0.19 0.0 0.0 1.0

Copy link

cabassi commented Sep 18, 2019

Hi Kurt,
thanks for posting this! As it appears this is not a well know issue, and I did 2 days of researching and trying other solutions before finding this post.
You saved me! Thank you!

Copy link

KurtJacobson commented Sep 18, 2019

Copy link

ostanki commented May 1, 2020

Thanks! (Also for the Calibrating_Touchscreen link in Your references that shows how to make it stick !)

Copy link

feer9 commented Aug 30, 2020

Thanks, this helped a lot with an old Genius MousePen i608 Tablet, together with an xorg.conf file

Copy link

kreijack commented Jan 15, 2021

I created a project derived from xinput_calibrator called xlibinput_calibrator. It uses libinput , so it works with the new Xorg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment