fix(pad): report a press that ends before the next pad read #7059
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7059"
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 Aryansh1520 on 2026-10-17T09:32:15Z.
What
Report a press that starts and ends between two
scePadReadStatecalls. The pad state is sampled only on read, so a tap shorter than the read interval was never seen by the guest, which made menus miss a press. The press is latched when input is published and folded into the next read. AddsCheckTapBetweenReadstoGuestPad.Tested
Linux (x86-64, gcc, Release):
ctest -R guest_padpasses. Hardware: AMD Ryzen 7 260 host, NVIDIA GeForce RTX 5060 Laptop GPU (Wayland). Game check: not run separately for this change alone.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T09:46:15Z.
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.
main)core/libs/prx/libScePad/src/PadState.cppL232Some 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.
core/libs/tests/GuestPad.cppcore/libs/prx/libScePad/src/PadState.cppcore/libs/prx/libScePad/src/PadState.cppcore/libs/tests/GuestPad.cppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T10:23:16Z.
Thanks for this. The locking is fine (every access is under
stateMutex), andCheckTapBetweenReadscovers the cases it names. One fix is needed before merge:The latch is only cleared by a
ReadState, so a stale press can replay later as a phantom press.Initializeclears the queue but notpressedSinceRead(PadState.cpp:105-113), andPadPublishInputdoesn't checkinitialized. A press made before the title initializes the pad is reported on its first read.scePadReadState: during a load, while it only reads throughscePadRead, or while paused. When it does read, the old press arrives as a fresh one and can confirm a dialog. Main never does this.Fix: clear the latch in
Initializeand when the title reads throughscePadRead, and drop latched presses older than about one read interval (or keep a timestamp with the latched bits).Minor: a latched L2/R2 tap sets the button bit, but
analog_buttons_l2/r2comes from the current state (0), so the bit and the analog value disagree for one read.Question: do you have hardware evidence that
scePadReadStatelatches short taps on a PS5? Real taps usually last 50-100 ms, longer than a 16 ms read interval, so a missed tap may come from the host publishing press and release in the same input poll. If so, the fix might belong in the publisher instead.Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-17T10:38:23Z.
Thanks for the review. Pushed a follow-up (
baf107a58, rebased onto current main):Initializeand when the title reads throughscePadRead, and a latched press is dropped ifReadStatedoesn't pick it up within 100 ms (pressedAttimestamp).Question: we don't have hardware evidence that a PS5 pad latches short taps, so I can't confirm this from a console. Your point stands that a short press within one host poll may be better fixed in the publisher. I'd like to keep the reader-side fix (it's what a title can observe) unless you think the publisher fix is needed too. I'm open to changing the approach if you'd rather move it.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T14:58:56Z.
Thanks @Aryansh1520. We re-reviewed
baf107a58: the earlier points are fixed.InitializeandscePadReadnow clear the latch,ReadStateexpires it afterkLatchExpiry, and a latched L2/R2 press keeps its analog value.There's one small issue left from the same phantom-press class.
PadPublishInputkeeps a singlepressedAtfor every latched bit and refreshes it on each new press. If a title doesn't callscePadReadStatefor a while (a load screen, say) and the player presses X at t=0 and O at t=900 ms, a read at t=950 ms reports both X and O, although X is 950 ms old. The expiry only holds when no other press follows, and mashing through a load screen is exactly that pattern.A one-line fix in
PadPublishInput, before OR-ing in the new bits:(Per-bit timestamps would work too.)
Could you also add tests for the new behaviour to
GuestPad.cpp? They're all CPU-only and short:scePadRead, thenscePadReadStatedoesn't report it;scePadReadStatedoesn't report it;Once that's on a new head we'll run full CI and re-review.
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-17T15:00:34Z.
Thanks for the detailed review. Pushed
baf107a58on top of current main:Initializeand whenever the title reads throughscePadRead. A latched press is also dropped ifReadStatedoesn't pick it up within 100 ms, so it can't show up later as a fresh press.On the publisher question: we don't have hardware evidence that a PS5 latches short taps, so I'd rather keep the fix on the reader side, where a title can observe it, and not change the publisher without that evidence. If you think the publisher fix is needed anyway, tell me what you'd expect to see and I'll look at it. Otherwise, is this ready to approve?
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-17T15:05:25Z.
Thanks for the re-review, and sorry for the delay: my previous reply went up before I had read your 14:58 note.
Pushed
f3e05559don top ofbaf107a58:PadPublishInputnow drops the latch before OR-ing in the new bits when it has expired, using your one-line fix. X at t=0, O at t=900 ms, read at t=950 ms reports O only.core/libs/tests/GuestPad.cpp(CheckLatchedPressLifetime), covering your three cases:scePadRead, thenscePadReadStatedoes not report it;scePadReadStatedoes not report it;guest_pad_testsbuilds and passes locally in Release on Linux. I haven't run it against the unfixed commit to confirm the new cases fail there, so that check is still open.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T23:33:36Z.
Review: COMMENTED
The check the last comment leaves open: each new case run against the code without the fix it covers.
Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build.Head
f3e05559dmerged ontomain5de7a46e0(clean merge).RequireinGuestPad.cppaborts without a message, so for the runs below I made it print its line.guest_padpasses, as do the other pad tests (ctest -R pad, 9 tests).main: aborts at the first check ofCheckTapBetweenReads(the tap between two reads is not reported).PadState.cppfrom5786a9628(no clear or expiry): aborts inCheckLatchedPressLifetimeat the first case, the press is still reported byscePadReadStateafterscePadRead.PadState.cppfrombaf107a58(before the last fix): aborts at the last case, the older Cross is reported together with Circle.ctest -E "^agc|gpu|vulkan|video_out"): 697/697, same asmain.So each new case fails without the change it covers.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.