fix(pad): keep a latched press for one and a half read intervals #9919

Merged
zaidhawk merged 1 commit from upstream-pr/9919 into main 2026-10-26 11:48:10 +00:00
zaidhawk commented 2026-10-22 21:47:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaidhawk on 2026-10-22T21:47:53Z.


What

A press that starts and ends between two scePadReadState calls is latched (#7059), but dropped after a fixed 100 ms (kLatchExpiry). A title that reads the pad less often than every 100 ms loses most quick taps. Persona 3 Reload (PPSA10872, #9692) reads only through scePadReadState, about every 170 ms on its title screen and menus, and needed several presses per menu step.

The latch now lasts 1.5 × the interval between the title's two previous reads, clamped to 100–500 ms (LatchExpiry()), as the #7059 review suggested ("about one read interval"). The interval is the one from before the current read, so a pause in reading (a load screen) keeps the window of the cadence before it, and an older press is still dropped. A title reading at 60 FPS keeps the 100 ms window.

Tests:

  • CheckLatchedPressAtSlowReads reads 170 ms apart, then expects a tap made 150 ms before the next read to be reported, and one made 400 ms before to be dropped. Without the change it fails at the first of these.
  • CheckLatchedPressPerPort reads ports 0 and 1 back to back, 170 ms apart, then taps Cross on port 0 and expects it at a read 150 ms later. With one interval shared by all ports, the port 1 read right after port 0's sets it to about 0 and the window to 100 ms, so the tap is dropped.
  • CheckLatchedPressLifetime's third case (X, 150 ms, O) came right after a read 150 ms after the previous one, which now gives a 225 ms window. It reads once more right before X, so it still models a title that was reading every frame and then paused.

Limit: a single long frame after fast reads (80 ms, then 200 ms) still uses the fast cadence's window, so a tap early in that frame can be dropped.

Since #7881 the read interval is kept per controller (PadSlot::lastReadAt and readInterval), so a title that reads several ports in a row doesn't shrink any port's window.

Tested

  • Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, rebased on main 5357acd69 (after #7881; head 98e1c3765): ctest -R pad 15/15, 3 runs. guest_pad with the new tests and main's PadState.cpp fails at the slow-read "tap is reported" check; with one read interval shared by all ports it fails at the new per-port check (3 of 3 runs each). Earlier heads on main 001d132f4 and 0db47b263 passed the same way.
  • tools/check_conventions.py --base origin/main: passed.
  • Persona 3 Reload (PPSA10872), RTX 5090 (617.42), with #7048, #9068 and #8070 merged locally to reach the menus. On the difficulty menu (scePadReadState about every 170 ms), 30 Down key taps of 40 ms, one per second, sent with keybd_event to the focused window: main 10 of 30 lost, this PR 0 of 30.

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
  • Fixes: none
  • Unblocks: PPSA10872 #9692 (quick menu taps were lost; reaching the menus also needs the PRs listed there)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4974570813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9919). Originally posted by [zaidhawk](https://github.com/zaidhawk) on 2026-10-22T21:47:53Z. --- ### What A press that starts and ends between two `scePadReadState` calls is latched (#7059), but dropped after a fixed 100 ms (`kLatchExpiry`). A title that reads the pad less often than every 100 ms loses most quick taps. Persona 3 Reload (PPSA10872, #9692) reads only through `scePadReadState`, about every 170 ms on its title screen and menus, and needed several presses per menu step. The latch now lasts 1.5 × the interval between the title's two previous reads, clamped to 100–500 ms (`LatchExpiry()`), as the #7059 review suggested ("about one read interval"). The interval is the one from before the current read, so a pause in reading (a load screen) keeps the window of the cadence before it, and an older press is still dropped. A title reading at 60 FPS keeps the 100 ms window. Tests: - `CheckLatchedPressAtSlowReads` reads 170 ms apart, then expects a tap made 150 ms before the next read to be reported, and one made 400 ms before to be dropped. Without the change it fails at the first of these. - `CheckLatchedPressPerPort` reads ports 0 and 1 back to back, 170 ms apart, then taps Cross on port 0 and expects it at a read 150 ms later. With one interval shared by all ports, the port 1 read right after port 0's sets it to about 0 and the window to 100 ms, so the tap is dropped. - `CheckLatchedPressLifetime`'s third case (X, 150 ms, O) came right after a read 150 ms after the previous one, which now gives a 225 ms window. It reads once more right before X, so it still models a title that was reading every frame and then paused. Limit: a single long frame after fast reads (80 ms, then 200 ms) still uses the fast cadence's window, so a tap early in that frame can be dropped. Since #7881 the read interval is kept per controller (`PadSlot::lastReadAt` and `readInterval`), so a title that reads several ports in a row doesn't shrink any port's window. ### Tested - Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, rebased on `main` 5357acd69 (after #7881; head 98e1c3765): `ctest -R pad` 15/15, 3 runs. `guest_pad` with the new tests and `main`'s `PadState.cpp` fails at the slow-read "tap is reported" check; with one read interval shared by all ports it fails at the new per-port check (3 of 3 runs each). Earlier heads on `main` 001d132f4 and 0db47b263 passed the same way. - `tools/check_conventions.py --base origin/main`: passed. - Persona 3 Reload (PPSA10872), RTX 5090 (617.42), with #7048, #9068 and #8070 merged locally to reach the menus. On the difficulty menu (`scePadReadState` about every 170 ms), 30 Down key taps of 40 ms, one per second, sent with keybd_event to the focused window: `main` 10 of 30 lost, this PR 0 of 30. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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] Fixes: none - [x] Unblocks: PPSA10872 #9692 (quick menu taps were lost; reaching the menus also needs the PRs listed there) - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 05:48:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:48:36Z.

Review: COMMENTED


The timing formula and regression cases match the observed ~170 ms menu-read cadence; the author reports 15/15 pad tests across three runs and a 30-tap P3 Reload A/B (10/30 lost on main, 0/30 on this change). Current-main whitespace and conventions pass. Current sync shows a clean merge but a shared GuestPad.cpp edit from merged #9664 adding tracker-device coverage. Please refresh the test file and rerun the focused pad suite on the integrated head, preserving those tests. The #7881 per-controller and #6337 timestamp coordination remains explicit and no dependency is needed if either can rebase independently.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624421314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9919#pullrequestreview-5624421314). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T05:48:36Z. **Review:** COMMENTED --- The timing formula and regression cases match the observed ~170 ms menu-read cadence; the author reports 15/15 pad tests across three runs and a 30-tap P3 Reload A/B (10/30 lost on main, 0/30 on this change). Current-main whitespace and conventions pass. Current sync shows a clean merge but a shared `GuestPad.cpp` edit from merged #9664 adding tracker-device coverage. Please refresh the test file and rerun the focused pad suite on the integrated head, preserving those tests. The #7881 per-controller and #6337 timestamp coordination remains explicit and no dependency is needed if either can rebase independently.
MarcZX10 commented 2026-10-23 05:48:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:48:37Z.

Review: DISMISSED


Please refresh onto current main and rerun the focused pad tests: the branch is 439 commits behind and current main has added tracker-device cases to the same GuestPad.cpp file (#9664). The merge is clean, but the submitted test run predates that integration. Keep the current latch interval/lifetime assertions and preserve the new tracker tests. The implementation and reported title A/B otherwise look well supported; current-main conventions and diff-check pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624421515 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9919#pullrequestreview-5624421515). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T05:48:37Z. **Review:** DISMISSED --- Please refresh onto current main and rerun the focused pad tests: the branch is 439 commits behind and current main has added tracker-device cases to the same `GuestPad.cpp` file (#9664). The merge is clean, but the submitted test run predates that integration. Keep the current latch interval/lifetime assertions and preserve the new tracker tests. The implementation and reported title A/B otherwise look well supported; current-main conventions and diff-check pass.
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!9919
No description provided.