SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Motion events emulation & multitouch gestures for touch events broken as of 2.0.22 on certain devices (X11)

Open mil opened this issue 2 years ago • 11 comments

As of upgrading to 2.0.22 on certain devices on X11, the emulation of motion events for touch devices is broken. Specifically I'm testing on the Pinephone on X11. What I've observed is that SDL_MOUSEBUTTONUP and SDL_MOUSEBUTTONDOWN are properly reported, however SDL_MOUSEMOTION events are not reported. Additionally gesture events (SDL_MULTIGESTURE) are not reported. Downgrading to 2.0.20 fixes these issues and SDL_MULTIGESTURE and SDL_MOUSEMOTION are then properly reported.

I've also noticed that setting the hint SDL_TOUCH_MOUSE_EVENTS to 0 restores the functionality of SDL_MULTIGESTURE events (but doesn't effect motion events..).

If I had to guess the root cause of this issue is: https://github.com/libsdl-org/SDL/commit/8f8b14cbb684603e71e5ee5ccf6e07f460efbb4c .. however I haven't tested beyond just downgrading to 2.0.20 and seeing things work.

I'm testing on X11/Alpine Linux edge (postmarketOS) on a Pinephone (aarch64). Two example applications packaged to test with are mepo and rue which both use touch events (and you can observe differences in application functionality between 2.0.22 and 2.0.20).

mil avatar May 11 '22 16:05 mil

https://github.com/koreader/koreader/issues/9091 ^ found this issue in researching as well, may be related

mil avatar May 11 '22 16:05 mil

Can you check that commit and see if that's the problem? It doesn't look like that would have the effect you're describing, offhand.

slouken avatar May 11 '22 17:05 slouken

Hmm, so I tested reverting both: https://github.com/libsdl-org/SDL/commit/8f8b14cbb684603e71e5ee5ccf6e07f460efbb4c and https://github.com/libsdl-org/SDL/commit/96be9cddcc433f4ceeb7fa2c4df6b65196839b80 neither are the issue.

Not entirely sure on the root cause / where to investigate to determine cause of this issue. 2.0.20 is working as expected for me. Was there some rework to touch/motion events from 2.0.20 -> 2.0.22 that could be the cause.

mil avatar May 11 '22 18:05 mil

Can you use git bisect to identify the breaking change?

slouken avatar May 11 '22 18:05 slouken

Offending commit is: 5ff42438e36e98c9d72ac70f5f5ce4599b96d3d2

Setting export SDL_MOUSE_AUTO_CAPTURE=0 fixes things on 2.0.22 for me; maybe auto capture should be disabled by default

mil avatar May 11 '22 19:05 mil

Why does auto capture affect touch events?

slouken avatar May 11 '22 19:05 slouken

That commit caused way too many issues

sezero avatar May 11 '22 20:05 sezero

Touch handling on X11 with auto capture enabled is broken in general, it's not just gestures or mouse emulation. SDL sends an FINGERUP event right after FINGERDOWN (sometimes there's a single FINGERMOTION in between in you move your finger fast), so the touches end as soon as they start.

dos1 avatar Jul 21 '22 22:07 dos1

@icculus, can you look into this?

slouken avatar Jul 21 '22 22:07 slouken

For what it's worth, here is a reproduction case for the single touch mouse motion emulation (with SDL_MOUSE_TOUCHID) that has some visualization: https://github.com/libsdl-org/SDL/issues/5924#issue-1306801715 Doesn't cover multi touch however.

ell1e avatar Jul 21 '22 22:07 ell1e

Yeah, I'll take a look.

icculus avatar Jul 22 '22 01:07 icculus

I can reproduce this here, I'm investigating.

slouken avatar Aug 11 '22 21:08 slouken

Fixed, thanks!

slouken avatar Aug 11 '22 23:08 slouken