Hello, these two commands can remap two touch interfaces with same ID to the whole desktop perfectly spanned and not in mirrored mode for touch. This tutorial may work for other USB based touch screens. Please let me know in the comments. Sorry, I prefer not to use a mic, pause the video as needed.
UPDATE (2021/09/19) Caveat: This works well and every time UNLESS you change the arrangement of what's plugged into which USB port on your Pi! If you unplug or plug a USB device between boots (like unplugging a keyboard because your project doesn't need it) you will have to SSH/VNC back into the pi and redo this tutorial to change the values being remapped to the xinput manager.
I'm using 2 Sunfounder 1024 x 600 IPS USB Touchscreens for a project.
You can get them here: https://amzn.to/3nxBngw
They are connected to a Raspberry Pi 4 : https://amzn.to/3z97Qff
I'm also using VNC to connect and easily record what I'm doing, but all you really need is a USB keyboard plugged into your RPi 4/400.
First you need to identify which USB devices your Raspberry Pi desktop uses. CTRL+ALT+T and run this command:
xinput list
For the Sunfounder or similar looking touchscreens, the USB HID devices are the same chip ID, but Debian lists them as two
different devices as id=9 and id=10. Debian automatically just maps each touch input as mirrored across the whole screen. If you want each touch panel to register the mouse under your finger correctly, you just have to run the command:
xinput -map-to-output 9 HDMI-1
xinput -map-to-output 10 HDMI-2
This command remaps the touch input back to the touch inputs relative physical screens. Otherwise, the touch on each screen is mapped
to the whole 2048x600 screen in the X direction. Press up arrow to recall the last command and use the left/right
arrow keys and backspace/delete keys to edit the command accordingly for the right screen. Or, if you copied from this webpage, CTRL+SHIFT+V when you have the terminal window back in focus.
Now when you touch anywhere on the screen the mouse should follow exactly.
But when you login again, the touch goes back to mirrored mode. To fix this you need to just make a shell script, I made mine like this:
nano touchfix.sh
Make yours look like this:
#!/bin/bash
xinput -map-to-output 9 HDMI-1
xinput -map-to-output 10 HDMI-2
and you MUST leave an empty newline with ENTER at the bottom or the shell script won't run! CTRL+X, 'Y', ENTER. Now run:
sudo chmod +x touchfix.sh
to make the script you just wrote executable.
Your touchfix shell script is almost ready. One more file to modify for the autorun to work run this command:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Enter:
@sh /home/pi/touchfix.sh
at the bottom of the file, CTRL+X, 'Y', ENTER to save the edit.
Now reboot, the settings should be executed automatically from the shell script you wrote earlier
and the touchscreens should respond perfectly! Enjoy.