Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6987

Graphics, sound and multimedia • Missing SDL2 or pygame FINGERMOTION events

$
0
0
## Issue

Not observing the FINGERMOTION event in SDL2 or pygame when using the KMS/DRM driver (for direct rendering without X11).
This happens when using Waveshare SPI resistive screens that do not support multi-touch protocol.

## Background

Waveshare resistive SPI displays connected over the 40 pin header originally used the framebuffer driver which was deprecated
in favor of KMS/DRM. The "KMSDRM" driver is now the only supported driver by SDL2 which is the backend of pygame.
In order to use KMS/DRM one needs to avoid following the Waveshare instructions and use the `piscreen,drm` driver instead.

Code:

#/boot/firmware/config.txt :dtparam=spi=ondtoverlay=piscreen,drm,speed=16000000
The `fbcon` driver is no longer supported by SDL.
BTW: SDL2 is deprecated by SDL3.

SDL2 uses evdev to get its events related to the touchscreen.

## Explanation

The single touch drivers (piscreen) will issue the `BTN_TOUCH` and `ABS_X` or `ABS_Y` evdev events.
The `BTN_TOUCH` event is then translated into FINGERDOWN and FINGERUP events.
Those do not repeat, so the `ABS_X/Y` are not tracked between `UP/DOWN` in SDL.


Only, the `ABS_MT_POSITION_X` or `ABS_MT_POSITION_Y` evdev events are translated into FINGERMOTION.
The multi-touch also needs to register the finger to track it using the `ABS_MT_TRACKING_ID` event.

In short the single-touch protocol is only translated into `UP/DOWN` by SDL.

## Solutions

1.) Use capacitive displays. Generally, much better user experience.
2.) Use evdev events directly. Requires calibration as the values are raw.
3.) Try to hint SDL2 to translate into MOUSE events (if compiled in).
4.) Patch SDL code to translate single-touch events to FINGERMOTION

.

Statistics: Posted by czaky — Wed Dec 24, 2025 2:53 pm — Replies 0 — Views 25



Viewing all articles
Browse latest Browse all 6987

Trending Articles