Blog Projects, Tips, Tricks, and How-Tos

Tech Tip – Touchscreen Calibration In Linux

Intro

Welcome, this is an Innovations Tech Tip. I recently did some work with an ELO Touchsystems 1515L 15″ LCD Desktop Touchmonitor. I was pleased with the touchmonitor’s hardware and performance, but in order to make it work properly in Linux I had to find a suitable calibration program. Out of the box on several distributions this touchscreen exhibits Y-axis inversion, where touching the top of the screen moves the cursor to the bottom and vice versa. xinput-calibrator is a freedesktop.org project that worked well for calibration, fixing the Y-axis inversion issue, and as a bonus it works for any standard Xorg touchscreen driver.

Video

Audio

Download

The Software

For this post I tested on Bodhi Linux 1.2.0 (based on Ubuntu 10.04 LTS), Fedora 15, and Ubuntu 11.04. xinput-calibrator, as I mentioned, was the screen calibration utility.

The Hardware

My test machine was an Intel based Lenovo T60 laptop with an attached ELO Touchsystems 1515L 15″ LCD Desktop Touchmonitor.

Installation

Click here to go to xinput-calibrator‘s website and choose your package. Be aware that if you’re using the ARM version of Bodhi (in alpha at the time of this writing) it’s based on Debian, so you’ll want to grab the Debian testing package. You can also add a PPA if you’re running Ubuntu, but I had trouble getting that to work during my tests. Last but not least, you can grab the source and compile it yourself by downloading the tarball or using git.

Before you actually install xinput-calibrator on a freshly installed Debian based system (including Ubuntu and Bodhi), make sure to update your package management system or you’ll get failed dependencies. This is because the package management system doesn’t know what packages are available in the repositories yet. This isn’t a problem with Fedora since the package management index is updated every time you use YUM. Once you’ve ensured that the system is or will be updated, you’ll be ready to install xinput-calibrator via the package that you downloaded or the PPA.

Calibration

Once xinput-calibrator is installed, it should show up in your application menu(s). Look for an item labeled “Calibrate Touchscreen”. If you don’t see it anywhere, you can launch it from the terminal with the xinput_calibrator (note the underscore) command.


Figure 1 – xinput_calibrator screenshot

Using It

The use of xinput-calibrator is very simple. You’re presented with a full-screen application that asks you to touch a series of 4 points. The instructions say that you can use a stylus to increase precision, but I find that using my finger works well for the ELO touchscreen. One of the nice features of xinput-calibrator is that it’s smart enough to know when it encounters an inverted axis. After I run through the calibration the Y-axis inversion problem is fixed, so I’m ready to start using the touchscreen.

Persistent Calibration

You’ll probably want your calibration to persist across reboots, so you’ll need to do a little more work now to make the settings permanent. First you’ll need to run the xinput_calibrator command from the terminal and then perform the calibration.

Listing 1

$ xinput_calibrator Calibrating EVDEV driver for "EloTouchSystems,Inc Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" id=9 current calibration values (from XInput): min_x=527, max_x=3579 and min_y=3478, max_y=603 Doing dynamic recalibration: Setting new calibration data: 527, 3577, 3465, 600 --> Making the calibration permanent <-- copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' Section "InputClass" Identifier "calibration" MatchProduct "EloTouchSystems,Inc Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" Option "Calibration" "527 3577 3465 600" EndSection

Toward the bottom of the output you can see instructions for "Making the calibration permanent". This section will vary depending what xinput_calibrator detects about your system. In my case under Ubuntu the output was an xorg.conf.d snippet, which I then copied into the xorg.conf.d directory on my distribution. Be aware that even though the output says that xorg.conf.d should be located in /etc/X11, it might actually be located somewhere else like /usr/share/X11 on your distribution. Once you've found the xorg.conf.d directory you can use your favorite text editor (with root privileges) to create the 99-calibration.conf file inside of it. Now when you reboot, you should see that your calibration has stayed in effect.

If you have a reason to avoid using an xorg.conf.d file to store your calibrations, you can run xinput_calibrator with the --output-type xinput option/argument combo.

Listing 2

$ xinput_calibrator --output-type xinput Calibrating EVDEV driver for "EloTouchSystems,Inc Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" id=9 current calibration values (from XInput): min_x=184, max_x=3932 and min_y=184, max_y=3932 Doing dynamic recalibration: Setting new calibration data: 524, 3581, 3482, 591 --> Making the calibration permanent <-- Install the 'xinput' tool and copy the command(s) below in a script that starts with your X session xinput set-int-prop "EloTouchSystems,Inc Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "Evdev Axis Calibration" 32 524 3581 3482 591

At the bottom of this output you can see that there are instructions for using xinput to make your calibration persistent. If it's not already present, you'll need to install xinput and then copy the command line in xinput_calibrator's instructions into a script that starts with your X session. You can usually also add it to your desktop manager's startup programs via something like gnome-session-properties if you would prefer.

Another option that might be of use to you is -v. The -v (--verbose) option displays extra output so that you can see more of what's going on behind the scenes. If you have any trouble getting your calibration to work, this would be a good place to start.

Your output will probably vary from what I have here depending on what type of hardware you have and which distribution you run. For instance, on Fedora 15 I get the xinput instructions by default instead of an xorg.conf.d snippet. Make sure that you run the above commands yourself, and don't copy the output from my listings.

If you have a desire or need to redo the calibration periodically, you might want to consider creating a wrapper script to automate the process of making the calibration permanent. Such a script might use sed to strip out the relevant code and then a simple echo statement to dump it into the correct xorg.conf.d file or startup script.

Wrapping Up

That concludes this Tech Tip. Have a look at innovationsts.com for other tips, projects, how-tos, and service offerings available from Innovations Technology Solutions. Thanks, and stay tuned for more from Innovations.

<

Resources

  1. xinput-calibrator Page
  2. xinput-calibrator On Github
  3. freedesktop.org Page
  4. Bodhi Linux Website
  5. Ubuntu Linux Website
  6. Fedora Linux Website

Comments (15)

  1. [...] Read more… This entry "Tech Tip – Touchscreen display Calibration Back in Linux | Innovations…" was posted on Tuesday, October 4th, 2011 and is filed under Related articles .Related posts: [...]

  2. [...] inversion issue, and as a bonus it works for any standard Xorg touchscreen driver.  Linux Read the full post on LXer… Share [...]

  3. [...] neste link o tutorial completo com VÍDEO que demonstra de forma fácil todo o passo a passo, que serve para a [...]

  4. Josiah

    2011/10/04 at 12:20 PM

    What Touchscreen driver are you using? elographics or evtouch?

  5. Jeremy Mack Wright

    2011/10/04 at 12:44 PM

    @Josiah – Actually, I just stayed with the generic evdev driver. That was what was used automatically for the touchscreen in my tests. xinput-calibrator should work fine with either the elographics or evtouch driver though since they’re both standard Xorg drivers. Are you having trouble getting it to work with either of those?

  6. [...] original post here: Tech Tip – Touchscreen Calibration In Linux | Innovations … Posted by gurkmooese 0 Responses [...]

  7. [...] Read more: Tech Tip – Touchscreen Calibration In Linux | Innovations … [...]

  8. [...] News excerpt from: Tech Tip – Touchscreen Calibration In Linux | Innovations … [...]

  9. [...] Tech Tip – Touchscreen Calibration In Linux [...]

  10. ctopher

    2011/10/07 at 12:37 PM

    I have this working with a Dell ST2220T under Fedora 15 and it works well. I use the xorg.conf.d method as it supports hutplugging (e.g if you use the xinput method, you have to but the command in an .xinputrc file so that the clibration is loaded at startup but if you unplug the monitor’s USB and plug it back in, the calibration is lost. Not so with the xorg.conf.d method.)

    But what I would like to be able to do is read out the current calibration. The xinput man page didn’t seem to show a way. evtest –query doesn’t appear to give that information

  11. ctopher

    2011/10/07 at 12:56 PM

    My bad, xinput does the job!
    Use xinput –list-props DEV and you’ll get all the properties. (replace DEV with the device name or number.

    The command:

    xinput –list-props DEV | grep “Evdev Axis Calibration” |
    awk ‘BEGIN{FS=”:t”;} {print $(NF);}’

    will print out the calibration values.

  12. Jeremy Mack Wright

    2011/10/07 at 1:45 PM

    @ctopher – Thanks for the feedback. That’s a good point about hotplugging and the xinput method, and I too prefer the xorg.conf.d snippet. I’m not sure if that method will continue to work in Ubuntu with the planned Xorg/Wayland change though. That will be something to watch.

    The –list-props option is a good one to point out. There are times when you just want to gather info about your touchscreen, and that does the trick.

    Do you have multi-touch working on the ST2220T?

  13. need help with X11 configuration

    2011/10/07 at 2:06 PM

    [...] The following might be slightly off topic, but it offers details about X11 configuration. http://www.innovationsts.com/blog/?p=3040 The "off topic" part is "touch calibration". The relevant part is that it [...]

  14. ctopher

    2011/10/14 at 10:37 AM

    @Jeremy – We have simple touch working. This is for a kiosk application so at this point, multi-touch might be asking too much of the general population user. I believe that the Dell ST2220T is capable of Multi-Touch, but the hacked driver we’re using does not support it.

    Another tip. After running for a long time the touch sometimes stops working. (Heat?) so we have a cron job that simulates plugging and unplugging the USB which fixes the problem. just a modprobe -r usbtouchscreen wait a sec to unload then modprobe usbtouchscreen and it is back in business.

  15. Jeremy Mack Wright

    2011/10/14 at 11:57 AM

    @ctopher – Thanks for the tip. So it’s a hardware issue and not the “hacked” driver module that’s crashing periodically?

    Most likely you already know this, but there was an ST2220T patch submitted at the end of July for the usbtouchscreen module. I’m not sure if the patch has been merged though.

    http://bit.ly/ql5FuK

The comments are now closed.