Difference between revisions of "Calibrating Touchscreen"

From ArchWiki
Jump to: navigation, search
(Calibrate a Touchscreen)
(Corrected the labels of the inconsistent transformation variables.)
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
[[Category:Input devices]]
 +
{{Merge|Touchscreen}}
 +
 
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 {{Ic|xinput}} to set the touchscreen's coordinate transformation matrix, as described [http://www.x.org/wiki/XInputCoordinateTransformationMatrixUsage in the X.Org Wiki].
 
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 {{Ic|xinput}} to set the touchscreen's coordinate transformation matrix, as described [http://www.x.org/wiki/XInputCoordinateTransformationMatrixUsage in the X.Org Wiki].
  
 
This shall be a guide to do that.
 
This shall be a guide to do that.
  
You will need to run the {{Ic|xinput}} command every time you attach the monitor. You can use [[Udev]] to automate this; more details to follow once I get it working myself.
+
You will need to run the {{Ic|xinput}} command every time you attach the monitor or log in. Or course, you can add the command to your session-autostart.
 +
You can also use [[Udev]] to automate this; more details to follow once I get it working myself.
  
 
==Using nVidia's TwinView==
 
==Using nVidia's TwinView==
Line 37: Line 41:
 
Now, calculate these as accurate as possible:
 
Now, calculate these as accurate as possible:
 
* c0 = touch_area_width / total_width
 
* c0 = touch_area_width / total_width
* c4 = touch_area_height / total_height
+
* c2 = touch_area_height / total_height
* c2 = touch_area_x_offset / total_width
+
* c1 = touch_area_x_offset / total_width
* c5 = touch_area_y_offset / total_height
+
* c3 = touch_area_y_offset / total_height
  
 
The matrix is
 
The matrix is
  [ c0 0  c2 ]
+
  [ c0 0  c1 ]
  [ 0  c3 c4 ]
+
  [ 0  c2 c3 ]
 
  [ 0  0  1  ]
 
  [ 0  0  1  ]
 
which is represented as a row-by-row array:
 
which is represented as a row-by-row array:
  c0 0 c2 0 c3 c4 0 0 1
+
  c0 0 c1 0 c2 c3 0 0 1
  
  
 
===Apply the Matrix===
 
===Apply the Matrix===
 
Execute
 
Execute
  xinput set-prop "Device Name" --type=float "Coordinate Transformation Matrix" c0 0 c2 0 c4 c5 0 0 1
+
  xinput set-prop "Device Name" --type=float "Coordinate Transformation Matrix" c0 0 c1 0 c2 c3 0 0 1
 
e.g.
 
e.g.
 
  xinput set-prop "Acer T230H" --type=float "Coordinate Transformation Matrix" 0.533333333 0 0 0 0.87804878 0.12195122 0 0 1
 
  xinput set-prop "Acer T230H" --type=float "Coordinate Transformation Matrix" 0.533333333 0 0 0 0.87804878 0.12195122 0 0 1
Line 57: Line 61:
  
 
==Troubleshooting==
 
==Troubleshooting==
If, after following these instructions, multiple clicks occur in different places when you touch the screen, you will need to build the {{Pkg|xorg-server}} package using the [[ABS]], applying [http://patchwork.freedesktop.org/patch/5024/ this patch] before you build the package.
+
If, after following these instructions, multiple clicks occur in different places when you touch the screen, you will need to build the {{Pkg|xorg-server}} package using the [[ABS]], applying [http://patchwork.freedesktop.org/patch/5024/ this patch] before you build the package. (This patch fails on the current xorg source, but the bug is present on at least 1 system.)
  
 
==See also==
 
==See also==
[http://www.x.org/wiki/XInputCoordinateTransformationMatrixUsage in the X.Org Wiki]
+
[http://www.x.org/wiki/XInputCoordinateTransformationMatrixUsage Calibrate Translation Matrix Documentation in the X.Org Wiki]

Revision as of 20:35, 6 October 2012

Merge-arrows-2.pngThis article or section is a candidate for merging with Touchscreen.Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Calibrating Touchscreen#)

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 xinput to set the touchscreen's coordinate transformation matrix, as described in the X.Org Wiki.

This shall be a guide to do that.

You will need to run the xinput command every time you attach the monitor or log in. Or course, you can add the command to your session-autostart. You can also use Udev to automate this; more details to follow once I get it working myself.

Using nVidia's TwinView

Get to know your system

Your screen

Using TwinView, X will see all your Screens as one big screen. You can get your total height and width by executing

$ xrandr

. You should see a line like this:

 3600x1230      50.0* 

what means, your total width is 3600 and your total height is 1230.

Your touch device

Your next job is to get your device's name. Execute

$ xinput list

and find it by it's name. E.g. if the line can look like this

⎜   ↳ Acer T230H                              	id=24	[slave  pointer  (2)]

your device name is

Acer T230H

Execute

xinput list-props "Device Name"

and make sure there is a property called

Coordinate Transformation Matrix

(If not, you may probably selected the wrong device)

Touch area

You need to shrink your touch area into a rectangle which is smaller than the total screen. This means, you have to know four values:

  • Height of touch area
  • Width of touch area
  • horizontal offset (x offset) (amount of pixels between the left edge of your total screen and the left edge of your touch area)
  • vertical offset (y offset) (amount of pixels between the top edge of your total screen and the top edge of your touch area)

Calculate the Coordinate Transformation Matrix

Now, calculate these as accurate as possible:

  • c0 = touch_area_width / total_width
  • c2 = touch_area_height / total_height
  • c1 = touch_area_x_offset / total_width
  • c3 = touch_area_y_offset / total_height

The matrix is

[ c0 0  c1 ]
[ 0  c2 c3 ]
[ 0  0  1  ]

which is represented as a row-by-row array:

c0 0 c1 0 c2 c3 0 0 1


Apply the Matrix

Execute

xinput set-prop "Device Name" --type=float "Coordinate Transformation Matrix" c0 0 c1 0 c2 c3 0 0 1

e.g.

xinput set-prop "Acer T230H" --type=float "Coordinate Transformation Matrix" 0.533333333 0 0 0 0.87804878 0.12195122 0 0 1

to calibrate your touchscreen device. Now, it should work properly.

Troubleshooting

If, after following these instructions, multiple clicks occur in different places when you touch the screen, you will need to build the xorg-server package using the ABS, applying this patch before you build the package. (This patch fails on the current xorg source, but the bug is present on at least 1 system.)

See also

Calibrate Translation Matrix Documentation in the X.Org Wiki