Skip to content

Improve/fix mouse scrolling support#6172

Merged
rom1v merged 4 commits intodevfrom
scroll
Jun 20, 2025
Merged

Improve/fix mouse scrolling support#6172
rom1v merged 4 commits intodevfrom
scroll

Conversation

@rom1v
Copy link
Collaborator

@rom1v rom1v commented Jun 20, 2025

Scrolling values reported by SDL can produce fractional values (like 0.05, when precise scrolling is enabled), and also values greater than 1 or less than -1.

Currently, the reported value was clamped to [-1, 1]. To support larger values, extend the range to [-16, 16] for SDK mouse (the default mode).

Over HID, only integral scroll values can be sent. When receiving fractional values from SDL, scrolling was broken (#6156). To fix the problem, use the integral scroll value reported by SDL, which internally accumulates fractional deltas.

While I was at it, I also added horizontal scrolling support for HID (it was only implemented for SDK mouse).

Fixes #6156.

rom1v added 4 commits June 20, 2025 18:30
Clamp scroll values to [-1, 1] only for the SDK mouse.

HID mouse implementations perform their own clamping to [-127, 127] (in
hid_mouse.c).

PR #6172 <#6172>
SDL precise scrolling can sometimes produce values greater than 1 or
less than -1.

On the wire, the value is encoded as a 16-bit fixed-point number.

Previously, the range was interpreted as [-1, 1], using 1 bit for the
integral part (the sign) and 15 bits for the fractional part.

To support larger values, interpret the range as [-16, 16] instead,
using 5 bits for the integral part and 11 bits for the fractional part
(which is more than enough).

PR #6172 <#6172>
Over HID, only integral scroll values can be sent. When SDL precise
scrolling is active, scroll events may include fractional values (e.g.,
0.05), which are truncated to 0 in the HID event.

To fix the problem, use the integral scroll value reported by SDL, which
internally accumulates fractional deltas.

Fixes #6156 <#6156>
PR #6172 <#6172>
@rom1v rom1v merged commit b81e0f9 into dev Jun 20, 2025
rom1v added a commit that referenced this pull request Jun 20, 2025
Over HID, only integral scroll values can be sent. When SDL precise
scrolling is active, scroll events may include fractional values (e.g.,
0.05), which are truncated to 0 in the HID event.

To fix the problem, use the integral scroll value reported by SDL, which
internally accumulates fractional deltas.

Fixes #6156 <#6156>
PR #6172 <#6172>
rom1v added a commit that referenced this pull request Jun 20, 2025
@rom1v
Copy link
Collaborator Author

rom1v commented Jun 20, 2025

(rebased/pushed-force to fix a unit test and edit a commit message)

rom1v added a commit that referenced this pull request Jun 20, 2025
SDL precise scrolling can sometimes produce values greater than 1 or
less than -1.

On the wire, the value is encoded as a 16-bit fixed-point number.

Previously, the range was interpreted as [-1, 1], using 1 bit for the
integral part (the sign) and 15 bits for the fractional part.

To support larger values, interpret the range as [-16, 16] instead,
using 5 bits for the integral part and 11 bits for the fractional part
(which is more than enough).

PR #6172 <#6172>
rom1v added a commit that referenced this pull request Jun 20, 2025
Over HID, only integral scroll values can be sent. When SDL precise
scrolling is active, scroll events may include fractional values (e.g.,
0.05), which are truncated to 0 in the HID event.

To fix the problem, use the integral scroll value reported by SDL, which
internally accumulates fractional deltas.

Fixes #6156 <#6156>
PR #6172 <#6172>
rom1v added a commit that referenced this pull request Jun 20, 2025
rom1v added a commit that referenced this pull request Jun 20, 2025
SDL precise scrolling can sometimes produce values greater than 1 or
less than -1.

On the wire, the value is encoded as a 16-bit fixed-point number.

Previously, the range was interpreted as [-1, 1], using 1 bit for the
integral part (the sign) and 15 bits for the fractional part.

To support larger values, interpret the range as [-16, 16] instead,
using 5 bits for the integral part and 11 bits for the fractional part
(which is more than enough).

PR #6172 <#6172>
rom1v added a commit that referenced this pull request Jun 20, 2025
Over HID, only integral scroll values can be sent. When SDL precise
scrolling is active, scroll events may include fractional values (e.g.,
0.05), which are truncated to 0 in the HID event.

To fix the problem, use the integral scroll value reported by SDL, which
internally accumulates fractional deltas.

Fixes #6156 <#6156>
PR #6172 <#6172>
rom1v added a commit that referenced this pull request Jun 20, 2025
Linux4 added a commit to Linux4/scrcpy that referenced this pull request Sep 5, 2025
scrcpy v3.3.1

Changes since v3.3:
 - Fix --power-off-on-close (Genymobile#6146)
 - Fix clipboard with --no-clipboard-autosync (Genymobile#6151)
 - Fix --list-apps and --list-cameras (Genymobile#6165, Genymobile#6167)
 - Fix HID mouse support with SDL precise scrolling (Genymobile#6156, Genymobile#6172)
 - Add horizontal scrolling support for HID mouse (Genymobile#6172)
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