I connected yesterday a Raspberry Pi 3 Model B at a 3M touch Systems touchscreen. For installing I followed this tutorial that I found here: Inverted GPIO Touchscreen (Using 99-calibration.conf)

What I did was:

  • git clone https://github.com/swkim01/waveshare-dtoverlays.git
  • sudo cp waveshare-dtoverlays/waveshare35a-overlay.dtb /boot/overlays/
  • sudo nano /boot/config.txt
  • I added there: dtoverlay=waveshare35a:rotate=270,swapxy=1
  • I ran xinput-calibration
  • I added the values resulted from calibration into /X11/xorg.conf.d/99-calibration.conf and the following transformation matrix: 0 1 0 -1 0 1 0 0 1

The 99-calibration file looks like this:

Section "InputClass"
Identifier  "calibration"
MatchProduct    "3M 3M USB Touchscreen - EX II"
Option  "MinX"  "57679"
Option  "MaxX"  "7631"
Option  "MinY"  "8256"
Option  "MaxY"  "55187"
Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"

The problem is that the x axis is inverted. The SwapX or InvertX doesn't work. Also when I installed the raspberry pi the first time x and y axes were swaped. What should I do? Can You give me a Transformation Matrix that works both for x and y and doesn't swap them?

  • 1
    I just improved the formating so it can be easier to read and understand – Galescu Raul Apr 20 '18 at 9:57

Assuming you're using Raspbian stretch, touchscreens are now handled by libinput instead of evdev, and settings in 99-calibration.conf (mostly) no longer apply. A workaround is to download evdev and make touchscreens use evdev again instead of libinput - so 99-calibration.conf will once again be useful. However, the better fix is to set the proper coordinate transformation matrix by an xinput command.

I found the procedures outlined in https://gist.github.com/KurtJacobson/37288a0300a9c1b3e859c8dcff403300 to be very helpful. Since Raspbian is based on Debian, the procedure applies. It includes a link to an interactive tool to visualize changes in the transformation matrix. I simply used trial and error to adjust a transformation matrix to get perfect tracking on the touchscreen I was using.

But before you start, edit your 99-calibration.config file to delete or disable the transformation matrix. For some reason, the matrix in 99-calibration.config IS read.

Once you've fine-tuned your transformation matrix, you'll need to save it in ~/.xsessionrc, so it will be applied every time the system reboots. Here's mine as an example.

# Set coordinate transformation matrix for Pi-RAQ touch display
# (rotate left; adjust for accurate pointer tracking)
xinput set-prop 'TSC-50 DMC' 'Coordinate Transformation Matrix' 0 1.05 -0.025 -1.6 0 1.3 0 0 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.