So for the last 3 weeks I have been trying to get this touchscreen(3,5" Resistive) to work properly, but I cannot, for the life of me, figure it out!

I have made a very simple SDL 1.2 program that opens a window, and displays a clickable rectangle. The touch works... but when I "touch move" X the mouse moves Y and vice versa.

I am using Raspbian Stretch Lite, and are not using X11 for the SDL-1.2 program.

When I run "evtest" I can see that the axis is actually inverted, but if I run the tslib test program(when you can draw) the touch works beautifully.

Also if I add "/dev/input/touchscreen" into the program, the mouse just flickers and jumps around.

So could it be some sort of driver problem? or could it be a user error...?

  • I have this exact same issue. evtest shows inverted input, but ts_test and ts_calibrate work perfectly. I am using this with pygame and pygame.mouse.get_pos() returns the wonky inverted results that evtest does. Did you ever figure this out? Oct 27, 2018 at 5:08
  • Hi! Sorry no i did not... maybe its something wrong the screen itself? I don’t know.
    – Teodor
    Oct 28, 2018 at 8:23

1 Answer 1


I had a very similar problem and when running ts_test and ts_calibrate I had perfect results. But when I used pygame to run a simple test program, the mouse was all over the place and very wonky.

I realized that the issue must be with pygame, but I couldn't figure out what it was. I guess I skipped over the suggestions from Adafruit in their guide, but eventually I figured out that the issue was with my SDL version. To solve it I used this script to downgrade SDL to 1.2 and now everything works properly!


# enable wheezy package sources
echo "deb http://archive.raspbian.org/raspbian wheezy main
" > /etc/apt/sources.list.d/wheezy.list

# set wheezy as default package source
echo "APT::Default-release \"wheezy\";
" > /etc/apt/apt.conf.d/10defaultRelease

# set the priority for libsdl from wheezy higher than the stretch package
echo "Package: libsdl1.2debian
Pin: release n=stretch
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl

# install
apt-get update
apt-get -y --allow-downgrades install libsdl1.2debian/wheezy

And this is the code I used for a simple test in pygame. Before running the previous script, the mouse was unreliable and all over the place. After running the previous script, it was doing a great job tracking with my finger.

import pygame
import os
from time import sleep

os.environ['SDL_VIDEODRIVER'] = 'fbcon'
os.environ['SDL_FBDEV'] = '/dev/fb1'
os.environ['SDL_MOUSEDRV'] = 'TSLIB'
os.environ['SDL_MOUSEDEV'] = '/dev/input/event0'

lcd = pygame.display.set_mode((320,480))

while True:
        for event in pygame.event.get():
                mouse_position = pygame.mouse.get_pos()
                print ""
                print ("Tap on window at: {}".format(mouse_position))


For this example, in my /boot/config.txt I have the following setting:


And make sure to run ts_calibrate if you change the rotation.

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0
  • Hi! Wow this sounds promising! will try it as soon as I have my raspberry up and running again... thanks! /Teodor
    – Teodor
    Nov 17, 2018 at 19:33
  • You're welcome! I hope it works for you :) Nov 17, 2018 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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