Skip to content

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

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
AlxcBTW:feat/input-mouse-look
Oct 14, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
AlxcBTW:feat/input-mouse-look

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

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

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

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

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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).

AlxcBTW and others added 2 commits October 13, 2026 17:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the feat/input-mouse-look branch from d7ca998 to bc568a1 Compare October 13, 2026 15:05
@adriadam10

Copy link
Copy Markdown
Collaborator

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

AlxcBTW commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants