-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle high-precision scrolling when using notebook touchpads #3363
Comments
Thank you for the report 👍 A PR is welcome 😉 Some first remarks on your branch. The The |
OK. Should I also clamp the value to -1~1 and/or shorten the fields to 16 bits (short) each like pressure? The documentation of |
I think so.
I would say yes, I guess 16 bits is sufficient (and for consistency with pressure). |
Since SDL 2.0.18, the amount scrolled horizontally or vertically is exposed as a float (between 0 and 1). XX DO NOT MERGE (YET) XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Remaining problem (?) before merging: the x and y value are clamped to [0; 1], so if on some platforms a scroll event could be triggered with a value greater than 1 or lower than -1, it is not forwarded correctly anymore (this is the case both for the int or float versions). XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Refs <https://wiki.libsdl.org/SDL_MouseWheelEvent> Fixes #3363 <#3363> PR #3369 <#3369> Signed-off-by: Romain Vimont <[email protected]>
Since SDL 2.0.18, the amount scrolled horizontally or vertically is exposed as a float (between 0 and 1). Forward a precise value to the Android device when possible. Refs <https://wiki.libsdl.org/SDL_MouseWheelEvent> Fixes #3363 <#3363> PR #3369 <#3369> Signed-off-by: Romain Vimont <[email protected]>
Since SDL 2.0.18, the amount scrolled horizontally or vertically is exposed as a float (between 0 and 1). Forward a precise value to the Android device when possible. Refs <https://wiki.libsdl.org/SDL_MouseWheelEvent> Fixes #3363 <#3363> PR #3369 <#3369> Signed-off-by: Romain Vimont <[email protected]>
Since SDL 2.0.18, the amount scrolled horizontally or vertically is exposed as a float (between 0 and 1). Forward a precise value to the Android device when possible. Refs <https://wiki.libsdl.org/SDL_MouseWheelEvent> Fixes #3363 <#3363> PR #3369 <#3369> Signed-off-by: Romain Vimont <[email protected]>
Fixed by #3369. |
Is your feature request related to a problem? Please describe.
I'm investigating yume-chan/ya-webadb#396, a user reported that the scrolling speed of my client implementation, when using notebook touchpads, is super fast.
It turns out that Scrcpy is using the integer scrolling distances (
x
,y
) from SDL, but mouse wheel events from browsers only contains high-resolution distances (and the event is firing very frequently). It's pretty hard to emulate integer scrolling distances from fractional ones,In my testing using the native Scrcpy client with a notebook touchpad, the two-fingering scrolling works, but feels clunky.
1.mp4
Describe the solution you'd like
Since SDL also provides high-resolution scrolling distances (
preciseX
andpreciseY
in SDL_MouseWheelEvent), and Android accepts float values in MotionEvent.PointerCoords.setAxisValue, switch Scrcpy to use the high-precision ones. This will make scrolling on notebook touchpad super smooth.Additional context
I tested the idea on master...yume-chan:scrcpy:float-scroll. The result on Windows laptops is good.
2.mp4
Logged SDL mouse wheel events:
The value can exceed 1/-1 when scrolling fast, but looks like Android only accepts value between -1 and 1
The text was updated successfully, but these errors were encountered: