feat(libSceVideoOut): capture the host cursor for guest mice and scale their deltas #4217
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4217"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-12T01:39:38Z.
What
The console's mouse reports relative motion only, so a host cursor can never coincide with the cursor a title draws, and on a scaled desktop or a letterboxed window the title's cursor moved a different distance than the pointer. Minecraft (PPSA17221) draws its own cursor from
sceMouseReaddeltas: the host pointer drifted away from it and left the window.MouseInputscalesxrel/yrelfrom the presented image's size in window units to the title's display resolution, with sub-pixel carry so slow motion is not lost (SetPresentation); the presentation loop inVideoOutDriverfeeds it the window size and the letterboxed size it already computes.UpdateCaptureputs SDL in relative mouse mode while the window is focused, a title has a mouse open (sceMouseOpen, exported asMouseIsOpen_nid_postfixfrom libSceMouse) and the pad's mouse-to-stick toggle is off, and releases it otherwise;PadInput::MouseModeEnabled()exposes the toggle.video_out_mouse_tests(video_out_mouse): deltas sum unchanged at 1:1, double at half size, and an empty presentation is ignored.docs/user/INPUT_MAPPING.mddescribes the capture; TechnicalDebt records that the console's deltas are counts, so a title applying its own sensitivity still moves faster than the host pointer would.Tested
Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, Intel Arc Meteor Lake, Mesa 26.2.3), worktree onmain2cf23fcc5(rebased 2026-10-13: the entry moved to docs/dev/debt/libSceVideoOut.md;video_out_mouseandmouse_inputpass; the latter now links SDL, which the shared mouse source needs for the capture calls;video_out_mousealso covers the capture decision (CaptureWanted: focus lost and regained, another window's focus, mouse closed and reopened, window closed, the pad's mouse-to-stick toggle) and applies the capture under SDL's dummy video driver, whereSDL_GetRelativeMouseModefollows it and is released again):video_out_mousepasses;tools/check_conventions.py --base origin/mainandgit diff --checkpass. Minecraft (PPSA17221) on a 125 % scaled Wayland desktop (SDL on XWayland): the host cursor is hidden while the game has the mouse and returns when another window takes focus, and the in-game cursor now travels as far as the hand does; before, it fell short and the host pointer left the window (Linux). Not tested on Windows.The delta scale takes SDL's relative motion in logical window units, the units of
SDL_GetWindowSize; under Windows DPI scaling SDL may report physical pixels, which no Windows run has checked yet; the debt entry says so.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-12T09:09:32Z.
Request for a Windows check: this PR is only tested on Linux (SDL on XWayland, 125 % desktop scaling), and Windows DPI scaling is where the delta scaling can go wrong. SDL reports the window size in logical units there, while relative motion may arrive in physical pixels depending on the DPI-awareness SDL ends up with, so the scale factor the PR computes could be off by the display scale.
What to test, with a title that opens the mouse (Minecraft PPSA17221 does, drawing its own cursor from
sceMouseReaddeltas):ToggleMouse, middle button by default) is on.The log prints one line at startup that shows what the PR computed, for example:
On Windows the driver should read
windows, and the presented size should match the window's client area in the units SDL uses forxrel/yrel. If the cursor travel is off by the display scale, that line plus the Windows scaling percentage is all I need to fix it. A[mouse] relative mouse mode unavailableline would mean the capture itself failed.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:33:56Z.
Review: CHANGES_REQUESTED
Thanks for the PR. Blocking points:
mouse_inputtest (core/libs/prx/libSceMouse/CMakeLists.txt:12) compileslibSceVideoOut/src/MouseInput.cppintomouse_testsdirectly.UpdateCapturenow callsSDL_SetRelativeMouseMode,SDL_GetRelativeMouseMode,SDL_GetRelativeMouseStateandSDL_GetError, and that target doesn't link SDL, so it fails with undefined references on the PR head. Link SDL there (or split the capture code out of the file that test compiles) and run the existinglibSceMousetests as well as the new one.maininVideoOutDriver.cppanddocs/dev/TechnicalDebt.md; please rebase.SDL_GetWindowSizeratio (logical units), while relative-mode motion can be reported in physical pixels under DPI scaling. This is unverified and the body says it isn't tested on Windows. Please attach the[mouse]log line and the cursor-travel check at 125 %/150 % from a Windows run, or a test that pins the scale for a window whose size and drawable size differ, or make the scale independent of that assumption.UpdateCapture(mouse open + focus + toggle) has no test.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:57:22Z.
Review: CHANGES_REQUESTED
Thanks for the rebase and the SDL link fix;
mouse_inputandvideo_out_mousepass on the merged head, andvideo_out_mousefails to build without the change. Two points from the previous review are still open:SetPresentationis fedSDL_GetWindowSize(logical units) while the relative-modexrel/yrelunits under DPI scaling are unverified, and nobody has run it on Windows. Either attach the[mouse]log line and the cursor-travel check at 125 %/150 % from a Windows run, or add a test that pins the scale when window size and drawable size differ.MouseInput::UpdateCapture(mouse open + focus +MouseModeEnabled()) has no test; the new test only covers the delta arithmetic. A test for the capture decision (e.g.SDL_GetRelativeMouseMode()with the dummy/offscreen video driver) would cover it.Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-13T14:06:23Z.
Both open points addressed in
94087d08b:MouseInput::CaptureWanted(allowed)now holds the decision (allowed && focused && mouse open) andUpdateCaptureapplies it.video_out_mousechecks the decision through synthetic window events (focus lost and regained, another window's focus loss ignored, the mouse closed and reopened, the window closed, the pad's mouse-to-stick toggle), then applies the capture under SDL's dummy video driver:SDL_GetRelativeMouseMode()followsUpdateCapture(true)and is released byUpdateCapture(false). On a driver that refuses relative mode the test says so and only checks the release.SDL_GetWindowSize); the debt entry now states that and that Windows DPI scaling is unverified. @xXPBSXx, if your Windows batch can include this head: the[mouse]line at launch and whether a 125 % or 150 % desktop makes the title's cursor travel farther or shorter than the host cursor would settle it, and I'd switch the scale to the drawable size if it does.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:09:35Z.
Review: APPROVED
Checked on the PR merged onto current main: build and the libSceMouse/libSceVideoOut ctest scope pass (
mouse_input,video_out_mouse), andvideo_out_mousefails to build without the change. The Windows DPI behaviour of the delta scale stays unverified and is recorded in the technical debt entry; merging.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T21:01:58Z.
A follow-up from High on Life (PPSA15388), on Linux, after this PR: while the title reads the mouse,
PadInputstill turns mouse motion into the right stick, and mouse buttons still fire their pad bindings. So the camera gets the mouse twice, once throughlibSceMouseand once through the pad. In-game it feels like the mouse turned into a stick again.Locally I added two guards in
PadInput.cpp, keyed onMouseIsOpen_nid_postfix(), which this PR already provides:With them, the mouse behaves like the PC version, and the
pad/mousetests pass. I can open this as a PR with a test if that's the intended behaviour, @Mouad-Scriptz-0.Tested and written by Claude (AI assistant) on a contributor's machine.