Skip to content

sdl: fix touchscreen input on hosts without native touch support - #938

Open
xiaodoudou wants to merge 1 commit into
moonlight-stream:masterfrom
xiaodoudou:fix/touch-fallback-no-native-touch
Open

sdl: fix touchscreen input on hosts without native touch support#938
xiaodoudou wants to merge 1 commit into
moonlight-stream:masterfrom
xiaodoudou:fix/touch-fallback-no-native-touch

Conversation

@xiaodoudou

Copy link
Copy Markdown

Description

LiSendTouchEvent() is called for every finger event but its return value is thrown away. On a host with no touch support it returns LI_ERR_UNSUPPORTED and nothing gets sent, which is the case Limelight.h already tells us to handle:

If unsupported by the host, this will return LI_ERR_UNSUPPORTED and the caller should consider falling back to mouse emulation

We never did. Touch only seems to work because SDL is separately turning it into mouse events, and that brings its own problem: SDL drags its internal cursor along with your finger, so when you lift it the compositor re-reports the real pointer as one large motion event. In relative mode that goes out as a delta and throws the pointer across the screen. With SDL's synthesis off the same event still arrives, but with a zero delta, so it stops mattering.

This adds the documented fallback and turns the synthesis off, so touch has one path instead of two fighting each other.

I treat touch as absolute rather than following the mouse capture mode, since a touchscreen reports where your finger is, not how far it moved. SDL_FINGERUP deliberately sends no movement, because a release has no new position to report, and that was the jump.

Hosts that do support native touch are untouched by this, LiSendTouchEvent() succeeds and the fallback never runs.

Purpose

Touchscreens are unusable against hosts without native touch support. The pointer follows your finger while you drag, jumps somewhere else the moment you let go, and a tap does not move it at all.

Tested on an Ayn Odin 2 running ROCKNIX, streaming to Sunshine on the SDL platform under Wayland. That host returned LI_ERR_UNSUPPORTED for every touch event in a logged session, so this is the path being used. Taps now land where you touch, drags track properly, and letting go leaves the pointer alone. I checked it against an unpatched build of the same commit so I could be sure it was this change and not something else in master.

I do not have a host with native touch support to try, so that side is reasoned from the early return rather than actually tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant