feat(input): turn mouse speed into a smooth right-stick tilt #4704

Merged
AlxcBTW merged 2 commits from upstream-pr/4704 into main 2026-10-14 02:55:09 +00:00
AlxcBTW commented 2026-10-12 19:18:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-12T19:18:34Z.


What

The captured mouse (ToggleMouse) polled SDL_GetRelativeMouseState every 33 ms and tilted the right stick by clamp(distance * sensitivity + 16, 64, 128): any movement tilted the stick at least halfway, the tilt depended on the poll interval, and nothing could be tuned except MouseSensitivity (#4009).

Mouse motion is now accumulated from SDL_MOUSEMOTION events and turned into a speed in counts per second, so the same hand speed gives the same tilt at any frame rate. The keyboard and mouse logic moves out of PadInput into Pad::KeyboardMouse (libScePad/include/KeyboardMouse.hpp), which takes its time as an argument and so can be tested offline; PadInput keeps the SDL calls.

  • Speed is smoothed with an exponential filter, capped at MouseMaxSpeed, shaped by MouseCurve and lifted by MouseDeadzoneOffset, so slow movement clears the game's own deadzone without the old half-tilt jump.
  • The stick is centered MouseDecayMs after the last movement.
  • Six new settings next to MouseSensitivity: MouseVerticalScale, MouseCurve, MouseDeadzoneOffset, MouseMaxSpeed, MouseSmoothingMs, MouseDecayMs. Invalid or repeated values stop initialization with file and line, like the existing settings.
  • MouseSensitivity keeps its range (above 0, at most 10) and name. At 1, 3000 counts per second is a full tilt. The old behaviour is approximated by MouseDeadzoneOffset = 0.5, MouseSmoothingMs = 0, MouseDecayMs = 33; the defaults change how the mouse feels, deliberately.
  • Capture sets SDL_HINT_MOUSE_RELATIVE_MODE_WARP=0 and SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE=0, so the pointer speed of the operating system does not apply.
  • Losing focus lets go of held keys and the wheel press and releases the capture.

docs/user/INPUT_MAPPING.md gains a "Mouse as the right stick" section and the settings table.

New test pad_keyboard_mouse (tests/KeyboardMouse.cpp, tests/PadSimulation.hpp) feeds timed events into Pad::KeyboardMouse and samples the pad state at 33, 8 and 1 ms polls: steady deflection follows the curve, the stick centers within the decay time, a flick above full speed does not extend the tail, integrated deflection agrees across poll rates, plus the key, wheel and focus-loss paths. pad_input_mapping gains parsing and rejection cases for the new settings.

Tested

Not tested in a title; no game was run. Windows 11 build node (WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON): full build and the non-GPU ctest set, including pad_input_mapping and the new pad_keyboard_mouse. tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions (#674 edits bindings through an ImGui editor, #3456 is a browser editor for the ini, #4217 captures the host cursor for guest mice; none changes the analog conversion)
  • 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 in TechnicalDebt (none added)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4833965021 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4704). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-12T19:18:34Z. --- ### What The captured mouse (`ToggleMouse`) polled `SDL_GetRelativeMouseState` every 33 ms and tilted the right stick by `clamp(distance * sensitivity + 16, 64, 128)`: any movement tilted the stick at least halfway, the tilt depended on the poll interval, and nothing could be tuned except `MouseSensitivity` (#4009). Mouse motion is now accumulated from `SDL_MOUSEMOTION` events and turned into a speed in counts per second, so the same hand speed gives the same tilt at any frame rate. The keyboard and mouse logic moves out of `PadInput` into `Pad::KeyboardMouse` (`libScePad/include/KeyboardMouse.hpp`), which takes its time as an argument and so can be tested offline; `PadInput` keeps the SDL calls. - Speed is smoothed with an exponential filter, capped at `MouseMaxSpeed`, shaped by `MouseCurve` and lifted by `MouseDeadzoneOffset`, so slow movement clears the game's own deadzone without the old half-tilt jump. - The stick is centered `MouseDecayMs` after the last movement. - Six new settings next to `MouseSensitivity`: `MouseVerticalScale`, `MouseCurve`, `MouseDeadzoneOffset`, `MouseMaxSpeed`, `MouseSmoothingMs`, `MouseDecayMs`. Invalid or repeated values stop initialization with file and line, like the existing settings. - `MouseSensitivity` keeps its range (above 0, at most 10) and name. At 1, 3000 counts per second is a full tilt. The old behaviour is approximated by `MouseDeadzoneOffset = 0.5`, `MouseSmoothingMs = 0`, `MouseDecayMs = 33`; the defaults change how the mouse feels, deliberately. - Capture sets `SDL_HINT_MOUSE_RELATIVE_MODE_WARP=0` and `SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE=0`, so the pointer speed of the operating system does not apply. - Losing focus lets go of held keys and the wheel press and releases the capture. `docs/user/INPUT_MAPPING.md` gains a "Mouse as the right stick" section and the settings table. New test `pad_keyboard_mouse` (`tests/KeyboardMouse.cpp`, `tests/PadSimulation.hpp`) feeds timed events into `Pad::KeyboardMouse` and samples the pad state at 33, 8 and 1 ms polls: steady deflection follows the curve, the stick centers within the decay time, a flick above full speed does not extend the tail, integrated deflection agrees across poll rates, plus the key, wheel and focus-loss paths. `pad_input_mapping` gains parsing and rejection cases for the new settings. ### Tested Not tested in a title; no game was run. Windows 11 build node (WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`): full build and the non-GPU ctest set, including `pad_input_mapping` and the new `pad_keyboard_mouse`. `tools/check_conventions.py --base origin/main` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#674 edits bindings through an ImGui editor, #3456 is a browser editor for the ini, #4217 captures the host cursor for guest mice; none changes the analog conversion) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt (none added) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-12 21:00:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T21:00:58Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4756 core/libs/prx/libSceVideoOut/src/PadInput.cpp L226-260
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132531352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4704#issuecomment-6132531352). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T21:00:58Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4756 | `core/libs/prx/libSceVideoOut/src/PadInput.cpp` [L226-260](https://github.com/boykopovar/AnyPS5/blob/0a56aaaf47c6e99633c710a524e7834eed4b450e/core/libs/prx/libSceVideoOut/src/PadInput.cpp#L226-L260) | | |
xXPBSXx commented 2026-10-13 12:27:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T12:27:18Z.


Windows test: head d7ca998dd merged onto current main ff8fe4dbc, together with 6 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest for the tests this change adds or touches: pad_input_mapping passed, pad_keyboard_mouse passed; python tools/check_conventions.py --base upstream/main passed for the combined tree. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6145524439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4704#issuecomment-6145524439). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T12:27:18Z. --- Windows test: head `d7ca998dd` merged onto current `main` `ff8fe4dbc`, together with 6 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest for the tests this change adds or touches: pad_input_mapping passed, pad_keyboard_mouse passed; `python tools/check_conventions.py --base upstream/main` passed for the combined tree. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
adriadam10 commented 2026-10-13 15:05:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:05:54Z.


Checked on current main: merged as is, the build failed because PadInput::MouseModeEnabled() (added by #4217) still returned the removed mouseEnabled. I pushed one commit that makes it return keyboardMouse.MouseMode(), rebased on main.

  • pad_input_mapping and pad_keyboard_mouse pass; the new test does not build without the change.
  • Thanks @xXPBSXx for the Windows run.

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148623029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4704#issuecomment-6148623029). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:05:54Z. --- Checked on current `main`: merged as is, the build failed because `PadInput::MouseModeEnabled()` (added by #4217) still returned the removed `mouseEnabled`. I pushed one commit that makes it return `keyboardMouse.MouseMode()`, rebased on `main`. - `pad_input_mapping` and `pad_keyboard_mouse` pass; the new test does not build without the change. - Thanks @xXPBSXx for the Windows run. Merging once CI is green.
AlxcBTW commented 2026-10-13 15:06:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-13T15:06:57Z.


Thanks @adriadam10. That's the right fix: MouseModeEnabled() came in with #4217 after my last rebase, and keyboardMouse.MouseMode() is the state it should report now.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148644197 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4704#issuecomment-6148644197). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-13T15:06:57Z. --- Thanks @adriadam10. That's the right fix: `MouseModeEnabled()` came in with #4217 after my last rebase, and `keyboardMouse.MouseMode()` is the state it should report now.
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!4704
No description provided.