Keep keyboard-pad mouse deltas in range (RT-KEYBOARD-PAD-MOUSE-DELTA) #2082

Merged
alexandersato0830 merged 1 commit from upstream-pr/2082 into main 2026-11-28 08:05:40 +00:00
alexandersato0830 commented 2026-11-25 19:46:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by alexandersato0830 on 2026-11-25T19:46:13Z.


Claimed in the coordination issue as: RT-KEYBOARD-PAD-MOUSE-DELTA

What and why

A very large mouse delta can exceed the 32-bit Windows long range before the right-stick value is clamped. That can send the stick in the opposite direction. Round into a 64-bit result before clamping. Subtract the wrapping input counters in unsigned arithmetic so a small move across the 32-bit boundary keeps its magnitude and direction.

Tested

  • Windows 11, MSVC 19.51, pinned SDL 3.4.20. On main 5da72d1, the new fake-cursor cases failed for both a positive and a negative three-million-count jump.
  • The patched gameinput and gameinput_script CTests passed with 377 checks, zero failures. Coverage includes the large deltas and a four-count move across the raw counter boundary.
  • Verified git diff --check and the source-only check.

GPUs tested: n/a. The tests use virtual pads and a synthetic cursor source.

AI-assisted: yes.

  • Based on current main.
  • One topic.
  • Uses source and synthetic fixtures.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5498028535 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2082). Originally posted by [alexandersato0830](https://github.com/alexandersato0830) on 2026-11-25T19:46:13Z. --- Claimed in the coordination issue as: [RT-KEYBOARD-PAD-MOUSE-DELTA](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172630557) ### What and why A very large mouse delta can exceed the 32-bit Windows `long` range before the right-stick value is clamped. That can send the stick in the opposite direction. Round into a 64-bit result before clamping. Subtract the wrapping input counters in unsigned arithmetic so a small move across the 32-bit boundary keeps its magnitude and direction. ### Tested - Windows 11, MSVC 19.51, pinned SDL 3.4.20. On main `5da72d1`, the new fake-cursor cases failed for both a positive and a negative three-million-count jump. - The patched `gameinput` and `gameinput_script` CTests passed with **377 checks, zero failures**. Coverage includes the large deltas and a four-count move across the raw counter boundary. - Verified `git diff --check` and the source-only check. GPUs tested: n/a. The tests use virtual pads and a synthetic cursor source. AI-assisted: yes. - [x] Based on current `main`. - [x] One topic. - [x] Uses source and synthetic fixtures.
DadaCap commented 2026-11-28 08:05:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T08:05:43Z.


Merged into main (merge commit c91254631), approved by DadaCap (maintainer). Thanks!

Checked before merging: Its test fails on main (2 of 367 checks: a cursor jump past LONG_MAX/LONG_MIN overflowed lround) and passes with this PR (RTX 5080, Windows 11). The merge was pinned to the head commit that was tested (8b3db052e).

AI-assisted (Claude Code), posted for DadaCap.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7236359095 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2082#issuecomment-7236359095). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T08:05:43Z. --- Merged into `main` (merge commit c91254631), approved by DadaCap (maintainer). Thanks! Checked before merging: Its test fails on main (2 of 367 checks: a cursor jump past LONG_MAX/LONG_MIN overflowed `lround`) and passes with this PR (RTX 5080, Windows 11). The merge was pinned to the head commit that was tested (8b3db052e). _AI-assisted (Claude Code), posted for DadaCap._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2082
No description provided.