User avatar
Posts: 190
Joined: Mon Mar 07, 2016 6:10 am

Solution for Pygame and Touchscreens on Raspbian Buster OS

Tue Aug 27, 2019 4:59 am

The current version of the Pygame library leverages libsdl1.2. The version of the libsdl1.2 on Raspbian Buster OS has the issues with touchscreens. One of the solutions is to build that library with proper touchscreen support. This solution was suggested by Gerhard the author of NewtronRadio ... tron-radio On his behalf I'm creating this post hoping that it will be also helpful for other developers.

You can either download the patched libsdl1.2 package from the Gerhard's Dropbox account: ... _armhf.deb
and then install the package:

Code: Select all

sudo dpkg -i libsdl1.2debian_1.2.15+veloci1-1_armhf.deb
sudo apt-get -f install
Or you can build that library yourself by following these steps:

1. Install libts-dev

Code: Select all

sudo apt install libts-dev

2. Get the required packages

Code: Select all


3. Extract the packages

Code: Select all

tar xvzf libsdl1.2_1.2.15+dfsg2.orig.tar.gz
cd SDL-1.2.15
tar xvfJ ../libsdl1.2_1.2.15+dfsg2-4.debian.tar.xz

4. Install libSDL dependencies (can be found in debian/control)

Code: Select all

sudo apt install libx11-dev libxext-dev libxt-dev libxv-dev x11proto-core-dev libpulse-dev libgl1-mesa-dev libasound2-dev libcaca-dev libglu1-mesa-dev

5. Install packages for building .deb-packages

Code: Select all

sudo apt install build-essential debhelper

6. Add libts-dev to the "Build-Depends:"-section and to the "Depends:"-section for "Package: libsdl1.2-dev" in /home/pi/SDL-1.2.15/debian/control

7. Remove the "opts="-line in /home/pi/SDL-1.2.15/debian/watch so that it looks like this:

Code: Select all

# run "uscan --report" to check or "gpb import-orig --uscan" to update
8. Edit /home/pi/SDL-1.2.15/debian/changelog (add to top)

Code: Select all

libsdl1.2 (1.2.15+veloci1-1) unstable; urgency=medium

  * re-add support for libts
 -- veloci <>  Thu, 11 Jul 2019 11:12:13 +0200
9. Rename libsdl1.2_1.2.15+dfsg2.orig.tar.gz to libsdl1.2_1.2.15+veloci1.orig.tar.gz

Code: Select all

mv /home/pi/SDL-1.2.15/libsdl1.2_1.2.15+dfsg2.orig.tar.gz /home/pi/SDL-1.2.15/libsdl1.2_1.2.15+veloci1.orig.tar.gz

10. Build the whole thing (in folder /home/pi/SDL-1.2.15)

Code: Select all

debian/rules clean
dpkg-source -b .
debian/rules build

11. Create the packages (in folder /home/pi/SDL-1.2.15)

Code: Select all

fakeroot debian/rules binary
12. Install new package

Code: Select all

cd ..
sudo dpkg -i libsdl1.2debian_1.2.15+veloci1-1_armhf.deb
Many thanks to Gerhard for the suggested solution!

Posts: 1
Joined: Fri Sep 06, 2019 2:28 pm

Re: Solution for Pygame and Touchscreens on Raspbian Buster OS

Fri Sep 06, 2019 2:52 pm

I have serious problems with your solution on my configuration: Buster, RPi B+, Linux 4.19.58+, Python 2.7.16, Pygame 1.9.4.post1, Watterott 2.8".
The initial installation of your precompiled libsdl1.2debian_1.2.15+veloci1-1_armhf.deb package failed due to the absence of libts0. After installing libts0_1.19-1_armhf.deb a rerun of your .deb completed.
But now, my Python script exits from Python with the "Illegal instruction" message directly after "import pygame".
I have been struggling with getting the touch capability to work for weeks, and would like your solution to work. Can you help?

Posts: 1
Joined: Mon Mar 16, 2015 1:11 pm

Re: Solution for Pygame and Touchscreens on Raspbian Buster OS

Sun Sep 15, 2019 12:31 pm

What does "dpkg -s libsdl1.2debian" show?

Return to “Python”