Calibrating a touch-screen on dual monitors (one touch one not)

touch screenx11xinputxrandr

I am using Debian 9. I have a little PC with 2 in-built monitors that I intend to use as a point of sale. It has one monitor facing the customer (non-touch screen) and one facing the cashier (touch screen). Each monitor has a resolution of 1366 x 768. I have a POS application that runs as the only x client – no window manager and no desktop manager exist. This way the system consumes minimal resources. I.e I can run it like so from the terminal:

xinit my-pos-app $* -- :1

The application runs fine so long as I use the mouse. However the intention is to have this work with just the touch screen.

The problem is that the touch screen is not calibrated. I can see that when I touch it, a spot about 10 cm to the right of where I touch is actually being activated. So I tried using xinput_calibrator – a program that brings up a gui showing points on the screen to touch and automatically calibrate the touchscreen. But with the setup as it currently is, it is impossible to complete this step. This is because only one monitor is a touch screen and the other monitor is not, but xinput_calibrator is not aware of this and it puts half the picture on each monitor. The calibrations points on the non-touch-screen monitor obviously cannot be touched and so I cannot complete the xinput_calibrator process.

I notice when I move the mouse to the right of the first monitor that it appears at the left of the second monitor. So the system appears to have positioned both monitors side-by-side. I don't know a whole lot about this low-level monitor configuration stuff, but going by the output from xrandr, the system seems to think it only has 1 display:

$ xrandr
Screen 0: minimum 320 x 200, current 2732 x 768, maximum 8192 x 8192
eDP-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm
x 193mm
1366x768  60.00*+  40.00
1360x768  59.80    59.96
1024x768  60.04    60.00
960x720   60.00
928x696   60.05
896x672   60.01
960x600   60.00
960x540   59.99
800x600   60.00    60.32    56.25
840x525   60.01    59.88
800x512   60.17
700x525   59.98
640x512   60.02
720x450   59.89
640x480   60.00    59.94
680x384   59.80    59.96
576x432   60.06
512x384   60.00
400x300   60.32    56.34
320x240   60.05
VGA-1 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1366x768+1366+0 (normal left inverted right x axis y axis) 344mm x 194mm
1366x768  60.00*+  40.00
HDMI-1 disconnected (normal left inverted right x axis y axis)

Also, xinput shows that device id for the touch screen is 12.

Please can someone tell me how to configure the touch-screen correctly. Do I need to split the screens in 2 using xrandr first? If so then how would I do that? I'm stuck.

Best Answer

I have it working now. The first thing I did was to install the latest version of the display driver from the xorg repo. I'm not sure if this step was absolutely necessary since it doesn't seem to have changed the output from xrandr much, but it didn't hurt anyway:

$ sudo apt-add-repository ppa:xorg-edgers/ppa
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ aptitude search <my-graphics-card-brand>
$ sudo apt-get install <corresponding package>

Now xrandr shows DP-1 with more properties:

$ xrandr
Screen 0: minimum 320 x 200, current 2732 x 768, maximum 8192 x 8192
eDP-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1366x768      60.00*+  40.00  
   1360x768      59.80    59.96  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   960x600       60.00  
   960x540       59.99  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   800x512       60.17  
   700x525       59.98  
   640x512       60.02  
   720x450       59.89  
   640x480       60.00    59.94  
   680x384       59.80    59.96  
   576x432       60.06  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
VGA-1 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1366x768+1366+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1360x768      59.80    59.96  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   960x600       60.00  
   960x540       59.99  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   800x512       60.17  
   700x525       59.98  
   640x512       60.02  
   720x450       59.89  
   640x480       60.00    59.94  
   680x384       59.80    59.96  
   576x432       60.06  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
HDMI-1 disconnected (normal left inverted right x axis y axis)

And then start X and run the following command to assign eDP-1 as the touchscreen:

$ xinput --map-to-output $(xinput list --id-only "Elan Touchscreen") eDP-1

The manpage of xinput (v.1.6.2) mentions that the device name can be given as a string as well. Therefore, this would also work:

$ xinput --map-to-output "Elan Touchscreen" eDP-1
Related Question