Touchscreen Orientation (old, earlier notes from when using libinput)

Set the orientation, per Matrix Structure for screen rotation

xinput set-prop "Elo TouchSystems, Inc. Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "Coordinate Transformation Matrix" -1.000000, 0.000000, 1.000000, 0.000000, -1.000000, 1.000000, 0.000000, 0.000000, 1.000000

Success! Now the touchscreen input is the correct orientation, but it's scale is wrong (the pointer doesn't move as fast as the finger)

NOTE: Hmm, according to the Elo website If you have an AccuTouch (resistive) touchscreen and if you have access to the controller connections,you can remove the touchscreen connector from the controller, flip the connector over and reconnect it.

Touchscreen Offset/Calibaration (old, earlier notes from when using libinput)

Now, following the instructions at Talk: Archlinux - Calibrating Touchscreen

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

$ xinput_calibrator -v

DEBUG: Adding click 0 (X=205, Y=150)
DEBUG: Adding click 3 (X=825, Y=601)

Get display resolution

$ xrandr | grep current
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 4096 x 4096

Calculate four values, called "a", "c", "e", and "f", where:

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

a = (1024 * 6 / 8) / (825 - 205)
c = ((1024 / 8) - (a * 205)) / 1024
e = (768 * 6 / 8) / (601 - 150)
f = ((768 / 8) - (e * 150)) / 768

using linux bc command to do the math on command line:

$ echo "(1024 * 6 / 8) / (825 - 205)"|bc -l
1.23870967741935483870
$ echo "((1024 / 8) - (a * 205)) / 1024"|bc -l
.12500000000000000000
$ echo "(768 * 6 / 8) / (601 - 150)"|bc -l
1.27716186252771618625
$ echo "((768 / 8) - (e * 150)) / 768"|bc -l
.12500000000000000000

xinput set-prop "Elo TouchSystems, Inc. Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "libinput Calibration Matrix" 1.238709, 0.0, 0.125, 0.0, 1.277161, 0.125000, 0.0, 0.0, 1.0

Now the scale is correct, but there's still an offset (pointer a few inches distance from finger, though consistant)

Then I found this post, Touchscreen Calibration in Debian9 that explains the Coordinate Transformation matrix mapping:

[hscale] [vskew] [hoffset] [hskew] [vscale] [voffset] 0 0 1

And by incrementing the values for [hoffset] and [voffset], arrived at:

xinput set-prop "Elo TouchSystems, Inc. Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "Coordinate Transformation Matrix" -1.000000, 0.000000, 1.240000, 0.000000, -1.000000, 1.260000, 0.000000, 0.000000, 1.000000

Configure touchscreen automatically each boot (old, earlier notes from when using libinput)

Note: I don't have the udev rule working, so most of this section is just for notes, except for the bash script at the end of the section.

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

ENV{ID_VENDOR_ID}=="2149",ENV{ID_MODEL_ID}=="2703",ENV{WL_OUTPUT}="DVI1",ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0  0 1 0"

Substitute your own touchscreen's vendor ID, model ID (use lsusb?), 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.

ENV{ID_VENDOR_ID}=="2149",ENV{ID_MODEL_ID}=="2703",ENV{WL_OUTPUT}="DVI1",ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0  0 1 0"


$ lsusb

Bus 004 Device 002: ID 04e7:0050 Elo TouchSystems 2216 AccuTouch® Touchmonitor Interface

$ xrandr
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 4096 x 4096
LVDS1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00*+
   800x600       60.32    56.25  
   640x480       59.94  
VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00* 
   800x600       60.32    56.25  
   848x480       60.00  
   640x480       59.94

sudo nano /etc/udev/rules.d/99-Elo_TouchSystems.rules
    ENV{ID_VENDOR_ID}=="04e7",ENV{ID_MODEL_ID}=="0050",ENV{WL_OUTPUT}="LVDS1",ENV{LIBINPUT_CALIBRATION_MATRIX}="1.238709, 0.0, 0.125, 0.0, 1.277161, 0.125000, 0.0, 0.0, 1.0",ENV{COORDINATE_TRANSFORMATION_MATRIX}="-1.000000, 0.000000, 1.240000, 0.000000, -1.000000, 1.260000, 0.000000, 0.000000, 1.000000"

That doesn't seem to be doing anything... so I will just run a bash file at the start of the user GUI session for now (most linux GUI should support running startup applications/scripts):

#/bin/bash!
xinput set-prop "Elo TouchSystems, Inc. Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "libinput Calibration Matrix" 1.238709, 0.0, 0.125, 0.0, 1.277161, 0.125000, 0.0, 0.0, 1.0
xinput set-prop "Elo TouchSystems, Inc. Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "Coordinate Transformation Matrix" -1.000000, 0.000000, 1.240000, 0.000000, -1.000000, 1.260000, 0.000000, 0.000000, 1.000000

@electroluckydip