feat(libScePad): script timed pad input with APS5_PAD_SCRIPT and APS5_PAD_SCRIPT_LIVE #22064

Merged
nicolasabosch merged 3 commits from upstream-pr/22064 into main 2026-11-17 17:56:20 +00:00
nicolasabosch commented 2026-11-17 03:54:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-11-17T03:54:27Z.


What

Adds timed pad input for reproducible unattended runs, such as performance traces and regression runs of a scene behind menus, with no controller and no window focus. APS5_PAD_SCRIPT reads a text file of events (buttons with a start time and hold time, repeated presses, stick positions) that are OR-ed with real input for user 0, timed from the first pad read; APS5_PAD_SCRIPT_LIVE schedules lines appended to a file while the title runs; APS5_PAD_SCRIPT_LOOP_MS restarts the script after its last event. Port 0 stays connected while a script is configured, each fired event is logged to stderr, and a malformed line stops the title with an error naming the file and line. APS5_PAD_INPUT_FILE, APS5_PAD_RECORD and APS5_PAD_REPLAY are unchanged; the script is a hand-written, human-readable schedule rather than a recording of states.

Overlap: #18783 adds ENVIRONMENT.md rows next to the ones added here (APS5_PAD_*); the conflict is textual, and whichever PR merges second will be rebased.

Tested

Windows 11, MinGW (GCC, Release), no title. ctest -R '^(pad_input_script|pad_command_file|pad_recording|guest_pad)' passed (20/20): pad_input_script parses and samples scripts (holds, repeats, sticks, loop, live appends and malformed lines); the other pad tests cover the shared input path. After review (a4cd6e6ddc): a stick event overrides only the stick it names (the injected input carries a per-stick mask, and the other stick keeps the controller's position); a live poll that cannot read the file is retried at the next poll; live errors name the line in the whole file, counting the lines present at startup; and the live list refuses lines that would leave more than 20000 events pending. pad_input_script checks the stick mask, the line numbers across polls and from startup, and the cap. The per-stick merge into the controller state in PadState.cpp has no test of its own.

Also used in a title: a seven-line APS5_PAD_SCRIPT took EA SPORTS UFC 6 (PPSA23566, 01.004.000) from boot through its menus to the same gameplay scene (the first practice fight of the tutorial) in every unattended run of the performance captures attached to the perf(agc), perf(shader) and perf(libkernel) PRs opened with this one.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5350284466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22064). Originally posted by [nicolasabosch](https://github.com/nicolasabosch) on 2026-11-17T03:54:27Z. --- ### What Adds timed pad input for reproducible unattended runs, such as performance traces and regression runs of a scene behind menus, with no controller and no window focus. `APS5_PAD_SCRIPT` reads a text file of events (buttons with a start time and hold time, repeated presses, stick positions) that are OR-ed with real input for user 0, timed from the first pad read; `APS5_PAD_SCRIPT_LIVE` schedules lines appended to a file while the title runs; `APS5_PAD_SCRIPT_LOOP_MS` restarts the script after its last event. Port 0 stays connected while a script is configured, each fired event is logged to stderr, and a malformed line stops the title with an error naming the file and line. `APS5_PAD_INPUT_FILE`, `APS5_PAD_RECORD` and `APS5_PAD_REPLAY` are unchanged; the script is a hand-written, human-readable schedule rather than a recording of states. Overlap: #18783 adds `ENVIRONMENT.md` rows next to the ones added here (`APS5_PAD_*`); the conflict is textual, and whichever PR merges second will be rebased. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW (GCC, Release), no title. `ctest -R '^(pad_input_script|pad_command_file|pad_recording|guest_pad)'` passed (20/20): `pad_input_script` parses and samples scripts (holds, repeats, sticks, loop, live appends and malformed lines); the other pad tests cover the shared input path. After review (a4cd6e6ddc6): a `stick` event overrides only the stick it names (the injected input carries a per-stick mask, and the other stick keeps the controller's position); a live poll that cannot read the file is retried at the next poll; live errors name the line in the whole file, counting the lines present at startup; and the live list refuses lines that would leave more than 20000 events pending. `pad_input_script` checks the stick mask, the line numbers across polls and from startup, and the cap. The per-stick merge into the controller state in `PadState.cpp` has no test of its own. Also used in a title: a seven-line `APS5_PAD_SCRIPT` took EA SPORTS UFC 6 (PPSA23566, 01.004.000) from boot through its menus to the same gameplay scene (the first practice fight of the tutorial) in every unattended run of the performance captures attached to the `perf(agc)`, `perf(shader)` and `perf(libkernel)` PRs opened with this one. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-17 12:27:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T12:27:35Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head: 84e86118e4, base main. No merged-preview check.
  • Read-only review of the diff and of the head through the repository reader. No build and no tests were run.
  • Files read: the diff hunks of all seven reviewed files (CMakeLists.txt, InputScript.hpp, PadState.hpp, PadState.cpp, tests/InputScript.cpp, PadInput.cpp, ENVIRONMENT.md). None were excluded by rule.
  • Commands:
repo_read.py search PadState core/libs/prx/libSceVideoOut/src/PadInput.cpp
repo_read.py search PadScriptActive_nid_postfix
repo_read.py search Port0Presence core/libs/prx/libSceVideoOut
repo_read.py search InjectedInput core/libs/prx/libScePad/src/PadState.cpp
repo_read.py cat core/libs/prx/libSceVideoOut/include/Port0Presence.hpp 1 60

Results

Check Result Note
Build and ctest not run No build in this review
New export and its include passed Declared, defined, called
Port 0 stays connected passed Mode::Default commits connected
Live and script parser passed Read in full in the diff; not run
Author's ctest 20/20 not run Author-reported, not reproduced
Unedited reader output
84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libSceVideoOut/src/PadInput.cpp:26:#include "prx/libScePad/include/PadState.hpp"
1 matching lines at 84e86118e4b7.

84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libScePad/include/PadState.hpp:95:extern "C" bool PadScriptActive_nid_postfix();
84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libScePad/src/PadState.cpp:834:extern "C" bool PadScriptActive_nid_postfix() {
84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libSceVideoOut/src/PadInput.cpp:93:PadInput::PadInput(...) : ... port0Mode(PadScriptActive_nid_postfix() ? Port0Presence::Mode::Default : Port0Presence::ConfiguredMode()), ...
3 matching lines at 84e86118e4b7.

Lines 12–15 and 35–40 of Port0Presence.hpp were read with cat. Mode::Default makes committed true in Presence.

Findings

Blocking

None.

Non-blocking

  1. Live parse errors name the wrong line. core/libs/prx/libScePad/include/InputScript.hpp:301 starts line at 0 on every poll, and :308 reports it. An error on the 40th appended line is reported as "line 1" of that chunk. Keep a running line count on the live state.
  2. The live list has no cap. core/libs/prx/libScePad/include/InputScript.hpp:316 pushes without the kMaxEntries check that the file path applies. Entries are removed only a second after they end. A fast appender can grow the list without bound.
  3. Port 0 override is silent. core/libs/prx/libSceVideoOut/src/PadInput.cpp:93 never reads ANYPS5_PAD_PORT0_STATE while a script is set, so controller is ignored and an invalid value is not reported. Say so in ENVIRONMENT.md, or report the variable as well.
  4. Unrelated wording changes. docs/dev/ENVIRONMENT.md:631 and :704 change "stops the game" to "stops the title" in rows this PR does not touch. The checklist asks for one topic per PR. Drop these lines here, or move them to their own PR.

Sources

Not verified

  • No build and no ctest run here. The pad_input_script results (20/20, Windows 11, MinGW Release) are the author's report.
  • The retail-title claim and the performance captures in the linked PRs are the author's report. I did not check them.
  • The overlap with #18783 in ENVIRONMENT.md was not checked.
  • Only the diff hunks were read, not the full head text of the changed files. Compilation details are not verified: the Script() declaration and definition in the same namespace, C++20 std::erase_if, and the add_test_executable target.
  • No runtime check of the title path, the live file on a real title, or the loop timing.

To get this to a good state

Nothing is required. The optional points are findings 1 to 4 above. No commands need rerunning on the new head unless those changes are made.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5938363191 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22064#pullrequestreview-5938363191). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T12:27:35Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. ## What I ran - Head: 84e86118e4b7c176ad1b29ffa8cbafc9c0374d68, base main. No merged-preview check. - Read-only review of the diff and of the head through the repository reader. No build and no tests were run. - Files read: the diff hunks of all seven reviewed files (CMakeLists.txt, InputScript.hpp, PadState.hpp, PadState.cpp, tests/InputScript.cpp, PadInput.cpp, ENVIRONMENT.md). None were excluded by rule. - Commands: ``` repo_read.py search PadState core/libs/prx/libSceVideoOut/src/PadInput.cpp repo_read.py search PadScriptActive_nid_postfix repo_read.py search Port0Presence core/libs/prx/libSceVideoOut repo_read.py search InjectedInput core/libs/prx/libScePad/src/PadState.cpp repo_read.py cat core/libs/prx/libSceVideoOut/include/Port0Presence.hpp 1 60 ``` ## Results | Check | Result | Note | |---|---|---| | Build and ctest | not run | No build in this review | | New export and its include | passed | Declared, defined, called | | Port 0 stays connected | passed | Mode::Default commits connected | | Live and script parser | passed | Read in full in the diff; not run | | Author's ctest 20/20 | not run | Author-reported, not reproduced | <details> <summary>Unedited reader output</summary> ``` 84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libSceVideoOut/src/PadInput.cpp:26:#include "prx/libScePad/include/PadState.hpp" 1 matching lines at 84e86118e4b7. 84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libScePad/include/PadState.hpp:95:extern "C" bool PadScriptActive_nid_postfix(); 84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libScePad/src/PadState.cpp:834:extern "C" bool PadScriptActive_nid_postfix() { 84e86118e4b7c176ad1b29ffa8cbafc9c0374d68:core/libs/prx/libSceVideoOut/src/PadInput.cpp:93:PadInput::PadInput(...) : ... port0Mode(PadScriptActive_nid_postfix() ? Port0Presence::Mode::Default : Port0Presence::ConfiguredMode()), ... 3 matching lines at 84e86118e4b7. ``` Lines 12–15 and 35–40 of Port0Presence.hpp were read with `cat`. `Mode::Default` makes `committed` true in `Presence`. </details> ## Findings ### Blocking None. ### Non-blocking 1. **Live parse errors name the wrong line.** `core/libs/prx/libScePad/include/InputScript.hpp:301` starts `line` at 0 on every poll, and `:308` reports it. An error on the 40th appended line is reported as "line 1" of that chunk. Keep a running line count on the live state. 2. **The live list has no cap.** `core/libs/prx/libScePad/include/InputScript.hpp:316` pushes without the `kMaxEntries` check that the file path applies. Entries are removed only a second after they end. A fast appender can grow the list without bound. 3. **Port 0 override is silent.** `core/libs/prx/libSceVideoOut/src/PadInput.cpp:93` never reads `ANYPS5_PAD_PORT0_STATE` while a script is set, so `controller` is ignored and an invalid value is not reported. Say so in ENVIRONMENT.md, or report the variable as well. 4. **Unrelated wording changes.** `docs/dev/ENVIRONMENT.md:631` and `:704` change "stops the game" to "stops the title" in rows this PR does not touch. The checklist asks for one topic per PR. Drop these lines here, or move them to their own PR. ## Sources - [PadInput.cpp line 93](https://github.com/boykopovar/AnyPS5/blob/84e86118e4b7c176ad1b29ffa8cbafc9c0374d68/core/libs/prx/libSceVideoOut/src/PadInput.cpp#L93): the scripted pad is active and port 0 uses Default mode. - [Port0Presence.hpp lines 35–40](https://github.com/boykopovar/AnyPS5/blob/84e86118e4b7c176ad1b29ffa8cbafc9c0374d68/core/libs/prx/libSceVideoOut/include/Port0Presence.hpp#L35-L40): Default mode commits connected. ## Not verified - No build and no ctest run here. The `pad_input_script` results (20/20, Windows 11, MinGW Release) are the author's report. - The retail-title claim and the performance captures in the linked PRs are the author's report. I did not check them. - The overlap with #18783 in ENVIRONMENT.md was not checked. - Only the diff hunks were read, not the full head text of the changed files. Compilation details are not verified: the `Script()` declaration and definition in the same namespace, C++20 `std::erase_if`, and the `add_test_executable` target. - No runtime check of the title path, the live file on a real title, or the loop timing. ## To get this to a good state Nothing is required. The optional points are findings 1 to 4 above. No commands need rerunning on the new head unless those changes are made.
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!22064
No description provided.