feat(libScePad): record and replay the controller states a title reads #20310
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20310"
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 talha-devp on 2026-11-15T01:01:25Z.
What
Adds
APS5_PAD_RECORDandAPS5_PAD_REPLAYto libScePad.APS5_PAD_RECORD=<file>writes every change of the buttons, sticks and analog triggers the title reads from controller port 0, whatever device produced them, in milliseconds from the title's first controller read.APS5_PAD_REPLAY=<file>feeds those states back at the same times from that run's first read, without a device. It replaces port 0's buttons, sticks and analog triggers at everyscePadReadStateandscePadRead; after the last change it keeps the last state.The file is the line
APS5_PAD_RECORDING 1, then one line per change:<ms> <buttons hex> <lx> <ly> <rx> <ry> <l2> <r2>. A record path that cannot be written, or a replay file that cannot be read or is not in this format, stops the title at its first controller read with an error naming the variable.Why: a speed claim needs summaries of
mainand of the change "from the same machine and scene". A menu can be measured idle, but a gameplay scene needs the same input on every run, and nobody plays the same fight twice by hand.APS5_PAD_INPUT_FILEtimelines are written by hand and are limited to 4096 events and 5 s holds. A recording is played once and replayed on every arm; the Hades II session below is 218 changes over 137 s.Limitation: a replay follows the recorded times, not the title's frames. A run that loads more slowly, runs at another frame rate, or a title that draws different random numbers drifts from the recorded session. Two earlier replays of the same Hades II recording on different builds were about 20 s apart by the end. A state shorter than the title's read interval in the replay run can be skipped (3 of 218 below). Compare runs by scene, not by second.
docs/user/INPUT_MAPPING.mdsays so.Changes:
PadRecording.hpp(writer, player, parser), hooks inPad::ReadStateandPad::Readfor port 0, thepad_recordingandguest_pad_recordingtests,docs/user/INPUT_MAPPING.mdand two rows indocs/dev/ENVIRONMENT.md.Tested
Windows 10 22H2 (19045), RTX 4060 (NVIDIA 621.14), Ryzen 5 5600, MSYS2 UCRT64 GCC 16.2.0, Release. The Hades II runs below used
d675ca1458onmainee774087d2, the feature commit of this branch before it was squashed and rebased onto2f6d40f29b; none of the 20 newermaincommits touch its files. The tests were built on this branch's head.Tests.
ctest -R "^(guest_pad_recording|pad_recording|pad_command_file)$" -Von this branch's head: 3 of 3 pass.pad_recordingwrites and reads back a recording (one line per change, times from the first read, CRLF accepted), replays each state at its time and holds the last one, refuses a missing header, another version, a missing or extra field, a value past 255 and out-of-order times, and stops on a missing replay file and an unwritable record path. It fails when the missing-file error is removed.guest_pad_recordingreplays and records throughscePadReadStateandscePadRead: the replayed state replaces the live and latched input on port 0 only, the change recorded at 150 ms applies after it, the record file holds each read change once, and a missing replay file or an unwritable record path stops the read. With the threeApplyRecordingcalls inPadState.cppremoved it fails:guest_pad_recording: a missing APS5_PAD_REPLAY file did not stop the controller read.Hades II (PPSA36082 01.006.000). A session played by hand (main menu, then combat from about 40 s) replayed with
APS5_PAD_REPLAY,APS5_NO_PAD_INPUT=1and a freshAPS5_PAD_RECORDin the same run:tools/title_run.py --runs 1 --seconds 160, through a local wrapper that also relinks the title's own modules. It rendered with noFATALin stderr. Presents per second over 10 s windows:The menu and then the fight are reached, as in the session that was recorded.
Re-recording against the input:
Unusable files. Three 40 s Hades II runs, each stopping at the first controller read with the error on stderr:
APS5_PAD_REPLAYnaming a missing file:APS5_PAD_REPLAY: cannot read '<path>'APS5_PAD_REPLAYnaming a file without the header:APS5_PAD_REPLAY: '<path>' is not a recording: it needs the line 'APS5_PAD_RECORDING 1', then one line '<ms> <buttons hex> <lx> <ly> <rx> <ry> <l2> <r2>' per change in time orderAPS5_PAD_RECORDin a missing directory:APS5_PAD_RECORD: cannot write '<path>'python tools/check_conventions.py --base origin/main: all checks pass.python tools/pr_overlap.py --branch feat/pad-record-replay: no overlap found. It exits failed-closed because 62 open PRs that conflict withmainsharedocs/dev/ENVIRONMENT.md,CMakeLists.txtordocs/user/INPUT_MAPPING.mdand could not be compared. I checked their diffs by hand: none of them edits lines next to the ones this branch changes (the libScePad rows ofENVIRONMENT.md, thepad_command_filetest lines ofCMakeLists.txt, the new section ofINPUT_MAPPING.md). The pr-overlap bot later flagged #17420, which adds its test block where this branch'sguest_pad_recordingblock sat incore/libs/prx/libScePad/CMakeLists.txt.7953d4d145registers the recording test after the trigger effects test instead.mainwith both pull requests now merges in either order without a conflict, and all libScePad tests pass on that merge, includingguest_pad_recordingand #17420'sguest_pad_vibration.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 PrivacyOnion on 2026-11-15T01:06:13Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
98b780e0b9:tools/check_conventions.pypassed;git diff --checkclean.pad_recording_testsbuilt cleanly.pad_recording):Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T01:13:41Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code is internally consistent on static review, but I did not run the checks, so I cannot make a formal approval decision.
What I ran
Reviewed head
98b780e0b9095044c8fb020ae86c1f6be6e1f793usingrepo_read.pythrough the review reader. No commands or tests were run. No merged-preview check was performed. The author reports unit and Hades II runs in the PR description; I did not verify those results.Results
Negative control
Not run by me. The author reports that the missing-file test fails when its error is removed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I read all six changed files listed in the manifest:
CMakeLists.txt,core/libs/prx/libScePad/include/PadRecording.hpp,core/libs/prx/libScePad/src/PadState.cpp,core/libs/prx/libScePad/tests/PadRecording.cpp,docs/dev/ENVIRONMENT.md, anddocs/user/INPUT_MAPPING.md. The prepared file listing showed all six included and no excluded changed files. I did not run tests, inspect author-provided traces, or verify physical-console behavior.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T04:19:49Z.
Review: APPROVED
Reviewed — looks good
The recording and replay paths are implemented consistently with the documented port 0 behavior, and the inspected code supports merging.
What I ran
Reviewed head
fbad8a40d087170bd7e1c0597ddcdb8c26f3be12using the prepared diff and pinned repository reader (repo_read.py). No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported CTest, Hades II, conventions, and overlap checks were not run by this review. All changed files listed in the manifest were read; none were excluded.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T17:37:04Z.
Review: COMMENTED
Reviewed — no blocking findings
The PR contents could not be inspected because the repository reader and review-folder tools are unavailable in this session; no merge recommendation is justified.
What I ran
Not run. No reader command could be run in this session.
Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
Description, commits, diff, manifest, changed file contents, and repository context were not read. No tests or checks were run. Files read: none. Files reviewed: none.
To get this to a good state
Provide access to the prepared review data and pinned-head reader so the change can be reviewed.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T21:00:35Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7953d4d145:tools/check_conventions.pypassed;git diff --checkclean.guest_pad_recording_tests,pad_recording_testsbuilt cleanly.pad_recording,guest_pad_recording):core/libs/prx/libScePad/src/PadState.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T01:18:36Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; I reviewed all changed files included in the bundle, and no verified blocking defect was found.
What I ran
Reviewed head
3236022daa752fbffe79196e1b206b9e7cf545b5using the prepared diff and repository reader. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported test runs and Windows Hades II behavior were supplied in the PR description and were not independently run. The reviewed files were
CMakeLists.txt,core/libs/prx/libScePad/CMakeLists.txt,core/libs/prx/libScePad/include/PadRecording.hpp,core/libs/prx/libScePad/src/PadState.cpp,core/libs/prx/libScePad/tests/PadRecording.cpp,core/libs/tests/GuestPadRecording.cpp,docs/dev/ENVIRONMENT.md, anddocs/user/INPUT_MAPPING.md. No changed files were excluded by the bundle manifest.To get this to a good state
Nothing is required.