Touchscreen

From ArchWiki
Revision as of 05:29, 12 August 2011 by KerrickStaley (Talk | contribs) (Added information about multi-head with touchscreens.)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Touchscreen#)

If you ever tried to set up a touchscreen device in linux, you might have noticed that it's either working out of the box (besides some calibration) or is very tedious, especially when it isn't supported by the kernel.

Introduction

This article assumes that your touchscreen device is supported by the kernel (e.g. by the usbtouchscreen module). That means there exists a /dev/input/event* node for your device. Check out

less /proc/bus/input/devices

to see if your device is listed or try

cat /dev/input/event? # replace ? with the event numbers

for every of your event nodes while touching the display.

If you found the corresponding node, it's likely that you will be able to get the device working.

Available X11 drivers

There are a lot of touchscreen input drivers for X11 out there. The most common ones are in the extra repository:

Less common drivers, not contained in the repository, are:

  • xf86-input-magictouch
  • xf86-input-plpevtch
  • xf86-input-palmax,
  • xf86-input-elo2300 (*)
  • xf86-input-microtouch (*)

(Note: (*) are deprecated and thus were removed from the repos [1])

Some for some devices proprietary drivers exists as well, as e.g. Template:Package AUR but it's recommended to try the open source drivers first.

Depending on your touchscreen device choose an appropriated driver.

The evtouch input drivers support a wide variety of touchscreens from different vendors like Fujitsu, eGalax, IDEACO, ITM, Touchkit. Template:Box YELLOW

evtouch drivers

First, install xf86-input-evtouch from the AUR.

This package already includes a set of udev rules to create a permanent node for your input device in Template:Filename.

If everything worked fine so far, you should have a symlink Template:Filename to your input device. If not, your touch device might not work with evtouch, but you can add a custom udev rule for your device and try it anyway.

In case you configured X server to use HAL hot-plugging, the touchscreen should work now after restarting the X server. Else you have to add the corresponding "InputDevice" section to xorg.conf as described on evtouch's webside.

Calibration

It's assumed that you have the touchscreen working now in X11 and that you're using hot-plugging for configuration. If you manually set up your input devices and thus switched off hot-plugging, you have to add the X11 options of this section to the xorg.conf file instead (see evtouch's webside for details again).

Rough calibration

For touchscreen calibration the Template:Package AUR package includes a calibration program.

sudo /usr/lib/xf86-input-evtouch/calibrate.sh

No matter whether you started it from TTY or X11, this will start a new X server and bring up a white screen. Move the pen around the display border, along all edges a view times to get the minimum and maximum coordinates. Press Template:Keypress. Then tab exactly on the red cross. The next cross will turn red, touch it again and repeat this procedure for all crosses. When your done you should return to command line. The calibration data was written to Template:Filename.

To restore the calibration data after booting add evtouch_config to the DAEMONS variable in Template:Filename

DAEMONS=( ... evtouch_config ... )

This will read the calibration data from Template:Filename and set the corresponding X options using HAL.

You can now (re)start your X server and enjoy your calibrated touchscreen.

Fine calibration (optional)

If your not satisfied with the calibration you can do further tweaking by changing the values in Template:Filename manually. MINX, MINY, MAXX, MAXY are the minimal and maximal coordinates and the nine X?,Y? pairs are the coordinates of the calibration points in the order you touched them.

Correct orientation of the coordinate system

The 9 point calibration assures that the coordinate axis are orientated in a way that your cursor moves to the right when your pen does (due to the signs of the X,Y pairs). In case you nevertheless notice your cursor is moving in the wrong direction you can add

hal_set swapx 1
hal_set swapy 1

to /etc/rc.d/evtouch_config (of course this will get overwritten when you upgrade the package)

When X and Y axis are swaped and your touchscreen uses the usbtouchscreen kernel module you can add the following line to Template:Filename

options usbtouchscreen swap_xy=1

Make the calibration persistent to unplugging or suspending

You may notice that after unplugging the touch device and replugging it while the X server is running, your calibration is messed up. The same happens when you resume from hibernation or suspend.

The reason is, that your calibration setting get set only once, at boot time by evtouch_config. When you unplug it the settings are removed when evtouch is unloaded. On plugging it in HAL sets the default settings as specified in Template:Filename and loads the evtouch driver, which reads the calibration settings into its memory. Therefore it doesn't work to simply call evtouch_config while the X window system is running.

The only way I found to make the calibration settings survive a replug-in or a hibernation is to set them directly in the HAL policy file. The following command converts the calibration settings to HAL policy format and prints the result on stdout.

awk -F= '{print "        <merge key=\"input.x11_options."tolower($1)"\" type=\"string\">"$2"</merge>"}' /etc/evtouch/config

Replace the corresponding merge commands in the policy file (Template:Filename) corresponding to your device.

Of course you don't need the evtouch_config daemon any more when you use this method, so you can remove it from Template:Filename.

Note: when you have problems with right clicking or drag and drop you can try tweaking the settings ([2] [3]) in the fdi file. You can also set the swapx, swapy options here in case you need them.

WARNING: The fdi files will be overwritten when you upgrade Template:Package AUR, so all your changes will be lost.

Using a touchscreen in a multi-head setup

To use multiple displays (some of which are touchscreens), you need to tell Xorg the mapping between the touch surface and the screen. This can be done using Template:Codeline to set the touchscreen's coordinate transformation matrix, as described in the X.Org Wiki.

You will need to run the Template:Codeline command every time you attach the monitor. You can use Udev to automate this; more details to follow once I get it working myself.

Note: If, after following these instructions, multiple clicks occur in different places when you touch the screen, you will need to build the Template:Package Official package using the ABS, applying this patch before you build the package.