fix(libScePad): smooth a slow-reporting mouse over its measured report interval #7498

Merged
AlxcBTW merged 1 commit from upstream-pr/7498 into main 2026-10-18 20:22:20 +00:00
AlxcBTW commented 2026-10-18 09:35:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-18T09:35:49Z.


What

The mouse-to-stick filter (Pad::MouseStick) smooths with a fixed 10 ms time constant (MouseSmoothingMs). A 125 Hz mouse reports every 8 ms and a 250 Hz mouse every 4 ms; the window loop runs at a different rate, so one update sees one report, the next two, and the stick wavers at constant hand speed. SDL2 cannot supply better timing: SDL_PushEvent stamps events with SDL_GetTicks() when they are queued, and WM_INPUT is handled inside SDL_PumpEvents, so a whole update shares one millisecond. The event count, however, does carry the report rate.

Pad::MouseStick now counts the motion events and the time they span (gaps over 50 ms are cut to 50 ms) over windows of 0.25 s. Windows with at least 10 reports whose mean size is at least 2 counts set a measured report rate. The smoothing time constant is then max(MouseSmoothingMs, min(3 / rate, 30 ms)), that is, at least three report intervals up to 30 ms. A mouse at 300 reports per second or more, and a setting of MouseSmoothingMs = 0, behave exactly as before. Single-count reports (a mouse moving at its sensor's smallest step) are not taken for a slow mouse.

The behaviour is documented on the MouseSmoothingMs row of docs/user/INPUT_MAPPING.md.

Tested

  • Linux (Ubuntu 24.04, GCC 13, Mesa lavapipe runner), fork CI at ed2f4c878e (the PR head 06ca6a066 plus the CI scaffolding commit; run 39113861695, ctest -R '^(pad_|guest_pad|video_out_mouse|mouse_input|keyboard_input)'): 9 of 9 passed, among them pad_keyboard_mouse. Not run on Windows.
  • New checks in pad_keyboard_mouse:
    • slow reporting mouse: 125, 250 and 1000 Hz mice at a steady half-tilt speed, polled every 16.7, 8.3, 6.9 and 1 ms. The stick's spread between its lowest and highest value over a second stays under 0.125 and its mid-point within 0.05 of the expected tilt.
    • report rate smoothing: the measured rate is within 10 % of 125, 250 and 1000 Hz, the smoothing is max(10 ms, 3 / rate), very slow reports (40 Hz) stop at 30 ms, MouseSmoothingMs = 0 stays 0, and single-count reports are not taken for a slow mouse.
  • The bounds come from the same simulation measured on a Windows machine before this PR (waver of a 125 Hz mouse 0.16 to 0.23 without the change, 0.09 to 0.12 with it); CI here only shows the new bounds hold, it did not run the old code against them. Not tested with a real 125 Hz mouse in a game.
  • python3 tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py lists #6353 (KeyboardMouse.hpp, the constants at the top; no shared function) and could not compare #674 and #4891 (docs/user/INPUT_MAPPING.md). Based on cdb7ed035.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4908010680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7498). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-18T09:35:49Z. --- ### What The mouse-to-stick filter (`Pad::MouseStick`) smooths with a fixed 10 ms time constant (`MouseSmoothingMs`). A 125 Hz mouse reports every 8 ms and a 250 Hz mouse every 4 ms; the window loop runs at a different rate, so one update sees one report, the next two, and the stick wavers at constant hand speed. SDL2 cannot supply better timing: `SDL_PushEvent` stamps events with `SDL_GetTicks()` when they are queued, and WM_INPUT is handled inside `SDL_PumpEvents`, so a whole update shares one millisecond. The event count, however, does carry the report rate. `Pad::MouseStick` now counts the motion events and the time they span (gaps over 50 ms are cut to 50 ms) over windows of 0.25 s. Windows with at least 10 reports whose mean size is at least 2 counts set a measured report rate. The smoothing time constant is then `max(MouseSmoothingMs, min(3 / rate, 30 ms))`, that is, at least three report intervals up to 30 ms. A mouse at 300 reports per second or more, and a setting of `MouseSmoothingMs = 0`, behave exactly as before. Single-count reports (a mouse moving at its sensor's smallest step) are not taken for a slow mouse. The behaviour is documented on the `MouseSmoothingMs` row of `docs/user/INPUT_MAPPING.md`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Linux (Ubuntu 24.04, GCC 13, Mesa lavapipe runner), fork CI at ed2f4c878e (the PR head 06ca6a066 plus the CI scaffolding commit; run 39113861695, ctest `-R '^(pad_|guest_pad|video_out_mouse|mouse_input|keyboard_input)'`): 9 of 9 passed, among them `pad_keyboard_mouse`. Not run on Windows. - New checks in `pad_keyboard_mouse`: - `slow reporting mouse`: 125, 250 and 1000 Hz mice at a steady half-tilt speed, polled every 16.7, 8.3, 6.9 and 1 ms. The stick's spread between its lowest and highest value over a second stays under 0.125 and its mid-point within 0.05 of the expected tilt. - `report rate smoothing`: the measured rate is within 10 % of 125, 250 and 1000 Hz, the smoothing is `max(10 ms, 3 / rate)`, very slow reports (40 Hz) stop at 30 ms, `MouseSmoothingMs = 0` stays 0, and single-count reports are not taken for a slow mouse. - The bounds come from the same simulation measured on a Windows machine before this PR (waver of a 125 Hz mouse 0.16 to 0.23 without the change, 0.09 to 0.12 with it); CI here only shows the new bounds hold, it did not run the old code against them. Not tested with a real 125 Hz mouse in a game. - `python3 tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` lists #6353 (`KeyboardMouse.hpp`, the constants at the top; no shared function) and could not compare #674 and #4891 (`docs/user/INPUT_MAPPING.md`). Based on cdb7ed035. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-18 10:31:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T10:31:38Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 docs/user/INPUT_MAPPING.md
PR 4891 docs/user/INPUT_MAPPING.md
PR 6353 core/libs/prx/libScePad/include/KeyboardMouse.hpp
core/libs/prx/libSceVideoOut/src/KeyboardMouse.cpp
core/libs/prx/libSceVideoOut/tests/KeyboardMouse.cpp
docs/user/INPUT_MAPPING.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6248784751 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7498#issuecomment-6248784751). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T10:31:38Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 674](https://www.github.com/boykopovar/AnyPS5/pull/674) | `docs/user/INPUT_MAPPING.md` | | [PR 4891](https://www.github.com/boykopovar/AnyPS5/pull/4891) | `docs/user/INPUT_MAPPING.md` | | [PR 6353](https://www.github.com/boykopovar/AnyPS5/pull/6353) | `core/libs/prx/libScePad/include/KeyboardMouse.hpp`<br>`core/libs/prx/libSceVideoOut/src/KeyboardMouse.cpp`<br>`core/libs/prx/libSceVideoOut/tests/KeyboardMouse.cpp`<br>`docs/user/INPUT_MAPPING.md` |
LeandroLP23 commented 2026-10-18 16:44:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:44:35Z.


Windows run, since the description lists Windows as not run. Windows 11 26300, Ryzen AI 7 350, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. Build: main 6efb7261b with #6648, #7559, #7496, #7497 and #7498 merged together (each merge clean, built once).

pad_keyboard_mouse and pad_input_mapping pass 3 runs of 3. The output includes this PR's slow reporting mouse and report rate smoothing line, so the new checks ran on Windows.

AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252462127 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7498#issuecomment-6252462127). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-18T16:44:35Z. --- Windows run, since the description lists Windows as not run. Windows 11 26300, Ryzen AI 7 350, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. Build: `main` `6efb7261b` with #6648, #7559, #7496, #7497 and #7498 merged together (each merge clean, built once). `pad_keyboard_mouse` and `pad_input_mapping` pass 3 runs of 3. The output includes this PR's `slow reporting mouse` and `report rate smoothing` line, so the new checks ran on Windows. AI-assisted
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
boykopovar/AnyPS5!7498
No description provided.