Coordinate transformation matrix linux

What «Coordinate Transformation Matrix» must I use to get my touchscreen working correctly?

Can someone please assist me, I’m pulling my hair out here. I’ve been trying for days to figure this out. Ubuntu 18.04.4 Display Set: Right Touch Frame: IRTOUCH System If i use the following command in terminal to try calibrate my touch i get the following results

xinput set-prop "USB Touchscreen 6615:0001" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1 
xinput set-prop "USB Touchscreen 6615:0001" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1 

My left/right is incorrect but my Up/Down is correct I’m trying to figure out what combination to use to configure my touch correctly. I’ve tried installing the driver which i downloaded from the manufacturer but that also does not work. Does anyone know what «Coordinate Transformation Matrix» i must use to get my Left/Right and Up/Down working correctly.

2 Answers 2

I managed to figure this out. There are 2 different Coordinate Transformation Matrix combinations for this particular touch frame. This depends on the screen rotation and if the touch panel has been mounted correctly or incorrectly «upside down»

Left Screen Rotate — Correct Mount Touch Panel xinput set-prop «USB Touchscreen 6615:0001» —type=float «Coordinate Transformation Matrix» 0 -1 1 -1 0 1 0 0 1

Left Screen Rotate — Incorrect Mount Touch Panel xinput set-prop «USB Touchscreen 6615:0001» —type=float «Coordinate Transformation Matrix» 0 1 0 1 0 0 0 0 1

Right Screen Rotate — Correct Mount Touch Panel xinput set-prop «USB Touchscreen 6615:0001» —type=float «Coordinate Transformation Matrix» 0 1 0 1 0 0 0 0 1

Right Screen Rotate — Incorrect Mount Touch Panel

xinput set-prop «USB Touchscreen 6615:0001» —type=float «Coordinate Transformation Matrix» 0 -1 1 -1 0 1 0 0 1

Hope this helps someone in the future

Just in case someone else stumbles over this thread looking for a way to configure a pointer to a display using a certain rotation, I’ll link my script here: https://github.com/SimonLammer/dotfiles/blob/0b98315b06b9393df6235457007b84831f1646f5/data/scripts/xinput-configure-pointer

#!/bin/sh # Limits a pointer to a display with an orientation. # This can be used to limit a rotated graphics tablet to one display. set -e ZENITY='zenity --width 500 --height 500' # Select pointer pointers=`xinput | grep pointer | tail -n +2 | sed -E 's/[^a-zA-Z0-9]*((\S+ ?)+[a-zA-Z0-9\(\)]+)\s*id=(4+)\s*(.*)/"\3" "\1" "\4"/'` #echo $pointers pointer=`echo $pointers | xargs $ZENITY --list --text "Choose a pointer" --column Id --column Name --column Info` #echo $pointer # Select display displays=`xrandr | grep \ con | sed -E 's/(\S+)[^0-9]*(.*)/"\1" "\2"/'` #echo $displays display=`echo $displays | xargs $ZENITY --list --text "Choose a display" --column Id --column Info` #echo $display # Map pointer to display to get initial coordinate transformation matrix xinput map-to-output "$pointer" "$display" mat0=`xinput list-props $pointer | grep "Coordinate Transformation Matrix" | cut -d ':' -f 2` # Select orientation o1="0°C" o2="90°C" o3="180°C" o4="270°C" orientation=`$ZENITY --list --text "Choose an orientation" --column Orientation --column Name "$o1" "Normal" "$o2" "Rotate left" "$o3" "Invert" "$o4" "Rotate right"` # https://wiki.ubuntu.com/X/InputCoordinateTransformation if [ "$orientation" = "$o1" ]; then mat1="1 0 0 0 1 0 0 0 1" elif [ "$orientation" = "$o2" ]; then mat1="0 -1 1 1 0 0 0 0 1" elif [ "$orientation" = "$o3" ]; then mat1="-1 0 1 0 -1 1 0 0 1" else mat1="0 1 0 -1 0 1 0 0 1" fi # Multiply matrices (mat2 = mat0 * mat1) # https://www.mymathtables.com/calculator/matrix/3-cross-3-matrix-multiplication.html perl_expr="@a=split(/,? /,'$mat0');@b=split(/ /,'$mat1');print \"\"\ .(\$a[0]*\$b[0]+\$a[1]*\$b[3]+\$a[2]*\$b[6]).\" \".(\$a[0]*\$b[1]+\$a[1]*\$b[4]+\$a[2]*\$b[7]).\" \".(\$a[0]*\$b[2]+\$a[1]*\$b[5]+\$a[2]*\$b[8]).\" \"\ .(\$a[3]*\$b[0]+\$a[4]*\$b[3]+\$a[5]*\$b[6]).\" \".(\$a[3]*\$b[1]+\$a[4]*\$b[4]+\$a[5]*\$b[7]).\" \".(\$a[3]*\$b[2]+\$a[4]*\$b[5]+\$a[5]*\$b[8]).\" \"\ .(\$a[6]*\$b[0]+\$a[7]*\$b[3]+\$a[8]*\$b[6]).\" \".(\$a[6]*\$b[1]+\$a[7]*\$b[4]+\$a[8]*\$b[7]).\" \".(\$a[6]*\$b[2]+\$a[7]*\$b[5]+\$a[8]*\$b[8]).\" \"\ .\"\\n\"" #echo $perl_expr mat2=`perl -E "$perl_expr"` xinput set-prop "$pointer" --type=float "Coordinate Transformation Matrix" $mat2 

Источник

Читайте также:  Intel parallel studio linux

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.

This is a guide to do that, the old-fashioned way, in cases when xrandr does not know about your separate screens because they have been merged into one (e.g., when using TwinView). Everyone else, please go to Touchscreen to do it the easy way.

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.

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 | grep \* # xrandr uses "*" to identify the screen being used

You should see a line like this:

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

and find it by its name. Find the item containing [slave pointer (2)] , which is usually your own device name. E.g. if the line can look like this

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

Tip: If your device contains both a stylus and a touch screen and more touch devices, then please pay attention to the name when determining the device.

$ 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, please try another one.)

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)
Читайте также:  Рутокен lite драйвер linux

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
[ c0 0 c1 ] [ 0 c2 c3 ] [ 0 0 1 ]

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

Apply the Matrix

$ xinput set-prop "Device Name" --type=float "Coordinate Transformation Matrix" c0 0 c1 0 c2 c3 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

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

Do it automatically via a udev rule

Create a file something like /etc/udev/rules.d/99-acer-touch.rules with contents like this:

/etc/udev/rules.d/99-acer-touch.rules
ENV=="2149",ENV=="2703",ENV="DVI1",ENV="1 0 0 0 1 0"

Substitute your own touchscreen’s vendor ID, model ID, the xrandr output name, and the calibration matrix that you calculated above. This is based on the assumption that you are using the libinput driver for your touchscreen.

Wayland

Using libinput you can calibrate your touchscreen on Wayland compositors. See the libinput documentation.

If you have weston installed, you can use the weston-calibrator utility to get the transformation matrix. You can then apply it using a udev rule.

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.)

Using libinput

The libinput package provides a few utilities to debug input events:

  • The libinput debug-events command provides a list of events emitted by all devices, including the touchscreen driver. You can use the —verbose option to get more information.
  • libinput debug-gui provides a graphical debug environment. This can be useful to verify visually that the transformation matrix has the correct values.
  • libinput list-devices lists all input devices. This can be useful to identify the name and eventual attributes of an input device. Using this command you can also verify that the transformation matrix was applied correctly.

For more information see the troubleshooting section of the libinput page.

See also

Источник

Ubuntu Wiki

Recent X.org servers have incorporated a property for setting how input device events are translated to screen coordinates. This property can be used to ensure a touchscreen is not stretched across a multi-monitor setup or to rotate the touch screen input when you rotate the physical device.

Printing the Coordinate Transformation Matrix

First, we need to determine the name of the input device. Run the following:

⎡ Virtual core pointer [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad [slave pointer (2)] ⎣ Virtual core keyboard [master keyboard (2)] ↳ Virtual core XTEST keyboard [slave keyboard (3)] ↳ Power Button [slave keyboard (3)] ↳ Video Bus [slave keyboard (3)] ↳ Power Button [slave keyboard (3)] ↳ HID 413c:8161 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard [slave keyboard (3)]

We’ll operate on the «SynPS/2 Synaptics TouchPad». To print the Coordinate Transformation Matrix (CTM), run the following:

$ xinput list-props 'SynPS/2 Synaptics TouchPad' | grep "Coordinate Transformation Matrix"

By default, this will output:

Coordinate Transformation Matrix (137): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

This is a 3×3 coordinate transformation matrix. It’s encoded in row-major order, so the matrix would look like the following in a text book:

Читайте также:  Error failed to send host log message linux

Astute readers will recognize that this is the identity matrix.

Using the Coordinate Transformation Matrix

By default, the CTM for every input device in X is the identity matrix. As an example, lets say you touch a touchscreen at point (400, 197) on the screen:

⎡ 1 0 0 ⎤ ⎡ 400 ⎤ ⎡ 400 ⎤ ⎜ 0 1 0 ⎥ · ⎜ 197 ⎥ = ⎜ 197 ⎥ ⎣ 0 0 1 ⎦ ⎣ 1 ⎦ ⎣ 1 ⎦

The X and Y coordinates of the device event are input in the second matrix of the calculation. The result of the calculation is where the X and Y coordinates of the event are mapped to the screen. As shown, the identity matrix maps the device coordinates to the screen coordinates without any changes.

The transformation matrix used is called an affine transformation matrix. Note that the translation values are in normalized floating point coordinates.

Left rotate (clockwise 90°)

Lets say we physically rotate the screen by 90° (from left) to the right. The X server screen can be rotated so that the display output matches the new orientation:

Not all graphics drivers support rotation

Now we want to map our touchscreen to the new orientation (90° (from left) to the right) as well. Using the affine transformation rules we would want our transformation matrix to be:

Right rotate (counterclockwise 90°)

For 90° (from right) to the left.

Not all graphics drivers support rotation

with a transformation matrix of:

Invert rotate (clockwise or counterclockwise 180°)

Not all graphics drivers support rotation

with a transformation matrix of:

Limit Range

Instead, lets say we have two monitors side by side, and our touchscreen is on the right monitor. They have the same resolution in the X direction. We don’t want our touchscreen mapped across both monitors, so we need to map the device coordinates to only the right half of the screen. Again, using the affine transformation rules we would want our transformation matrix to be:

Setting the Coordinate Transformation Matrix

Once we have determined the CTM, we need to set the matrix for the input device. We’ll assume the device name has been retrieved using ‘xinput list’ as described above. To set the matrix, run:

$ xinput set-prop » ‘Coordinate Transformation Matrix’

For example, to set the CTM to:

xinput set-prop '' 'Coordinate Transformation Matrix' 0.5 0 1 0 1 0 0 0 1

X/InputCoordinateTransformation (последним исправлял пользователь li200-146 2014-09-04 02:33:09)

The material on this wiki is available under a free license, see Copyright / License for details.

Источник

Оцените статью
Adblock
detector