Touchscreen with dual monitors
Solution 1:
First, list all input sources with xinput --list
:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Sony Vaio Jogdial id=8 [slave pointer (2)]
⎜ ↳ Advanced Silicon S.A CoolTouch(TM) System id=11 [slave pointer (2)]
⎜ ↳ HID-compliant Mouse HID-compliant Mouse id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Sony Vaio Keys id=7 [slave keyboard (3)]
↳ Video Bus id=9 [slave keyboard (3)]
↳ Power Button id=10 [slave keyboard (3)]
↳ IR camera id=12 [slave keyboard (3)]
↳ Cherry USB keyboard id=14 [slave keyboard (3)]
↳ Cherry USB keyboard id=15 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=16 [slave keyboard (3)]
Take the device that interests you (in this case, I am using "Advanced Silicon S.A CoolTouch(TM) System"), and note its ID.
Now, you need to find out the display that you want to map the input device to. The most straight-forward way is to use xrandr
:
Screen 0: minimum 8 x 8, current 3200 x 1080, maximum 16384 x 16384
HDMI-0 connected 1280x1024+1920+0 (normal left inverted right x axis y axis) 338mm x 270mm
1280x1024 60.02*+
1280x960 60.00
1280x720 60.00 59.94
1152x864 75.00 70.00
1024x768 60.00
800x600 60.32
720x480 59.94
640x480 59.94 59.93
LVDS-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+ 59.94
In this case, I want to map my touch device to the output LVDS-0
.
Combine the ID from the first step (11
here) with the screen name from the second step (LVDS-0
here) and run this command:
xinput --map-to-output INPUT-ID SCREEN
In my example, this command would be:
xinput --map-to-output 11 LVDS-0
Your touch device should not be properly mapped to the input device and should not require any additional configuration.
These settings will not persist between reboots. Please see this question on how to make xinput
commands persistent.
Solution 2:
The archlinux wiki is the best description of how to solve this, but here is something a bit more specific.
You should run xinput --list to identify the name of your input device. I created a spreadsheet to calculate the transformation values.
Spreadsheet here: https://docs.google.com/spreadsheets/d/13CNQjWfzpEkHM4ZdCcUWDTdQNaFqQ6TYTwatQsYcHcQ/edit?usp=sharing
I ran your numbers (dual 1920x1080 displays).
If your touchscreen is on the left, the command would be ('Advanced Silicon S.A CoolTouch(TM) System' is the name of my input device, replace with yours):
xinput set-prop 'Advanced Silicon S.A CoolTouch(TM) System' --type=float 'Coordinate Transformation Matrix' 0.5 0 0 0 1 0 0 0 1
For the right, it should be:
xinput set-prop 'Advanced Silicon S.A CoolTouch(TM) System' --type=float 'Coordinate Transformation Matrix' 0.5 0 0.5 0 1 0 0 0 1
Solution 3:
See: https://wiki.archlinux.org/index.php/Calibrating_Touchscreen
Your matrix is one of the following:
Touch screen on the left: 0. 5 0 0 0 1 0 0 0 1
Touch screen on the right: 0. 5 0 0. 5 0 1 0 0 0 1
I have almost the same configuration (but screens one on top of the others) and I experience multiple clicks after setting the correct matrix, as described on the bottom line of the link above. I haven't found a way to rebuild xorg-server
under Ubuntu; for sure the described procedure doesn't work.
Solution 4:
Since this is a firs google search result for this problem, I decided to post my solution that for me looks simple.
I found this link on archlinux, and you can use
xinput --map-to-output <stylus device ID> <screen ID>
so I don't need to play with "Coordinate Transformation Matrix"...