# Difference between revisions of "Talk:Calibrating Touchscreen"

Jump to: navigation, search

## Touch area

Are you sure about your math? Given the ratio touch_area_width / total_width, you're saying that if the touch area is smaller than the total width, the scaling factor will be less than 1, and thus make the result even smaller yet. On my device, the ratio total_width/touch_area_width is the right value to use for c0. Similar comment for the height/c2 value.

If you're in there, you might mention that all values are normalized WRT 1.0 before being multiplied by this matrix. It's easier to see the point of c1 and c3's equations if you have that fact in mind. Also, for cases where the touchscreen area is a subset of the screen area, these coefficients need to be negative.

Thanks for the most useful article on X's transformation matrices that I could find! Vandyswa (talk) 01:19, 6 October 2013 (UTC) Andy Valencia

## Google Docs calculator

This document is amazing, I created a google docs calculator to build the command for me. It really should not be this difficult to do this, but your instructions worked *perfectly* for me.

Here is the google doc of the calculator: https://docs.google.com/spreadsheets/d/13CNQjWfzpEkHM4ZdCcUWDTdQNaFqQ6TYTwatQsYcHcQ/edit?usp=sharing

Sportpeppers (talk) 19:26, 21 April 2014 (UTC)

## the spreadsheet method is obsolete in most cases

As described on the Touchscreen page, now I can do this instead:

xinput --map-to-output \$(xinput list --id-only "Advanced Silicon S.A CoolTouch(TM) System") DVI-0

This page is now showing only the hard way. As the header says, the two pages need merging. But the hard way is still relevant when xrandr cannot identify the separate screens because they've been merged into one large screen. —This unsigned comment is by Ecloud (talk) 17:12, 13 July 2016‎. Please sign your posts with ~~~~!

Did you open this to explain your edit? If yes: there is no need for such (as long as an edit is as self-explaining, please use the edit summary box for the edit reason). If you open this item for another point you want to discuss, it does not come across. --Indigo (talk) 20:04, 13 July 2016 (UTC)

## Libinput breaks xinput_calibrator

On my Panasonic CF-30, the xorg conf file generated by xinput_calibrator does not work with libinput. I worked out a very messy way of recalibrating. This could easily be scripted / xinput_calibrator forked, but I'm too lazy to do that at the moment. Here's my notes on how to do it manually:

1. Delete all xorg conf files for calibration and reload X.

2. Find your touchpanel name with the command:

```\$ xinput
```

Mine was "Fujitsu Component USB Touch Panel".

3. Verify your current calibration with this command (replace panel name):

```\$ xinput list-props "Fujitsu Component USB Touch Panel" | grep "libinput Calibration Matrix"
```

The matrix should be 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

4. Run xinput_calibrator in verbose mode:

```\$ xinput_calibrator -v
```

Do the calibration, then look for the DEBUG output lines:

```DEBUG: Adding click 0 (X=181, Y=132)
DEBUG: Adding click 1 (X=862, Y=129)
DEBUG: Adding click 2 (X=186, Y=661)
DEBUG: Adding click 3 (X=868, Y=665)
```

We need the X and Y values from click 0 and click 3.

5. Get display resolution using xrandr:

```\$ xrandr | grep current
Screen 0: minimum 8 x 8, current 1024 x 768, maximum 32767 x 32767
```

6. We now need to calculate four values, called "a", "c", "e", and "f" (reference).

```a = (screen_width * 6 / 8) / (click_3_X - click_0_X)
c = ((screen_width / 8) - (a * click_0_X)) / screen_width
e = (screen_height * 6 / 8) / (click_3_Y - click_0_Y)
f = ((screen_height / 8) - (e * click_0_Y)) / screen_height
```

7. Test the values with the following command (replace a, c, e, and f with your calculated numbers):

```\$ xinput set-prop "Fujitsu Component USB Touch Panel" "libinput Calibration Matrix" a, 0.0, c, 0.0, e, f, 0.0, 0.0, 1.0
```

The touchscreen should be calibrated now. If not, you can undo the calibration with this reset command:

```\$ xinput set-prop "Fujitsu Component USB Touch Panel" "libinput Calibration Matrix" 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0
```

8. Determine which udev device corresponds to your panel. I did this by testing all the mouse* devices in /sys/class/input with the following command:

```\$ udevadm info -a -p /sys/class/input/mouse0
```

Try each mouse device until you see your panel. You're looking for the lowest block that includes the text SUBSYSTEMS=="input", like so:

``` looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/0003:0430:0501.0001/input/input5':
KERNELS=="input5"
SUBSYSTEMS=="input"
DRIVERS==""
ATTRS{name}=="Fujitsu Component USB Touch Panel"
ATTRS{phys}=="usb-0000:00:1d.0-2/input0"
ATTRS{properties}=="0"
ATTRS{uniq}==""
```

9. Edit a new udev config file like so:

```sudo nano /etc/udev/rules.d/98-touchscreen-cal.rules
```

Fill in like so, using the ATTRS{name} found in step 8 and filling in the calculated numbers in place of a, c, e, and f):

```ATTRS{name}=="Fujitsu Component USB Touch Panel", ENV{LIBINPUT_CALIBRATION_MATRIX}="a 0.0 c 0.0 e f"
```

10. Reboot and verify.

Zootboy (talk) 01:11, 31 January 2017 (UTC)