Skip to content

feat(padtracker): answer Init, Term, Calibrate and ReadState from the firmware checks - #22349

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
zaryabzip:feat/padtracker-lifecycle
Nov 26, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
zaryabzip:feat/padtracker-lifecycle

Conversation

@zaryabzip

@zaryabzip zaryabzip commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

scePadTrackerInit, Term, Calibrate and ReadState get their firmware 13.42 signatures and answers. scePadTrackerUpdate answers before Init. On main all five throw.

Source. @BunnyFl's reading and emulator runs of libScePadTracker.sprx (13.42) on #21753 (comment). Not measured on a console.

Export Firmware 13.42 This PR
Init(void* memA, void* memB, int32_t a, int32_t b) 0x80c40003 for memory that is null or not 16 KiB aligned, a outside 0–6 or b outside 0–7; then 0x80c40002 when initialized; then the tracker setup, whose result is ignored, and 0 the same, without a tracker
Term(void) 0x80c40001 before Init; otherwise it resets the light bars, tears down and returns 0 the same, without the light-bar reset
Calibrate(void) 0x80c40001 before Init; otherwise 0, ignoring the calibration call the same
ReadState(int32_t handle, void* state) 0x80c40001; 0x80c40003 for a null state; 0x80c40004 for a handle Update never recorded the same; handle 0 throws
Update 0x80c40001 before Init; then the tracker the same; throws after Init

The emulator runs confirmed the bad-argument rows, the second Init, Term before and after Init, Calibrate after Init, and ReadState(1, NULL) / ReadState(1, state) after Init.

Change (Export.cpp, Api.hpp). An initialized flag under a mutex carries the checks above. Notes on the remaining pieces:

  • Tracker setup: the console builds its camera tracker (with GPU compute) in Init, and nothing here tracks.
  • Light bars: Term doesn't reset the pads' light bars as the console does, since that would need libScePad.
  • ReadState handle 0: handle 0 throws, because the table's initial contents weren't read and 0 might match an empty slot.
  • Update: it keeps its parameterless declaration, since only its Init check is answered. Its 0x40-byte by-value record isn't implemented.

Debt. Following the fragment rule, this adds docs/dev/debt/changes/feat-padtracker-lifecycle.md. It splits the "no credible prototypes" entry into one for Init/Calibrate/Term and one for ReadState/Update. Each states the answers and what isn't modelled. The fragment folds cleanly in isolation.

Test (GuestPadTracker.cpp, ctest guest_pad_tracker). New rows:

  • before Init: Term, Calibrate, ReadState and Update give 0x80c40001;
  • Init refuses each null or misaligned memory block and each out-of-range a and b, and Term still gives 0x80c40001;
  • Init(…, 6, 7) returns 0; a second Init gives 0x80c40002, but bad memory is still refused first;
  • after Init: Calibrate returns 0; ReadState refuses a null state, gives 0x80c40004 for handle 1 and leaves the state untouched;
  • Term returns 0, then 0x80c40001, and a fresh Init/Term pair works.

The two 16 KiB-aligned memory blocks are carved at run time from one static 0xC000-byte array. MinGW can't align a static object past 8192 bytes, so alignas(0x4000) doesn't build on Windows.

Tested

  • Windows, by my test session. Windows 11 Home 25H2 (26200.9974), i7-11800H, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release, BUILD_TESTING=ON, on main cb28e72762.
    • The first head, 58eb2ce459, didn't build: "requested alignment '16384' exceeds object file maximum 8192" for the two alignas(0x4000) buffers. The test session wrote the run-time alignment above.
    • With it (b32a7012db, the same diff as this head 9350539044), it builds with no warnings in the test, and guest_pad_tracker passes.
    • Control: main's Export.cpp with the stubs given the branch's signatures, plus the branch's header and test. It aborts (0xc0000409) with scePadTrackerTerm not implemented.
  • macOS host (arm64): the library and the full test built natively. The head passes, and the control aborts.

git merge-tree finds no conflict with main or with any open PR that merges with main.

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: Fixes libScePadTracker: Init, Term, Calibrate, Update and ReadState need readings from the firmware module #21753
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

zaryabzip and others added 2 commits November 17, 2026 14:37
… firmware checks

Firmware 13.42 (issue boykopovar#21753): scePadTrackerInit(memA, memB, a, b)
refuses memory that is null or not 16 KiB aligned and a outside 0-6 or
b outside 0-7, then a second Init, and returns 0 after its tracker
setup, whose result it ignores. Calibrate and Term answer 0x80c40001
before Init and 0 after. ReadState refuses a null state and returns
0x80c40004 for a handle no Update recorded, as none does here. Update
answers 0x80c40001 before Init and otherwise still throws, since the
tracker isn't implemented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ilds on Windows

MinGW's PE/COFF objects cannot align a static object to more than 8192
bytes, so the two alignas(0x4000) buffers failed to compile on Windows
("requested alignment '16384' exceeds object file maximum 8192"). Take
both 0x4000-aligned blocks from one static array instead, rounding the
first up to 0x4000 at run time. Diagnosed and verified on Windows by my
test session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9350539044:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_pad_tracker_tests built cleanly.
  • CTest (guest_pad_tracker):
    1/1 Test #4767: guest_pad_tracker ................   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libScePadTracker/Export.cpp, core/libs/prx/libScePadTracker/include/Api.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified pointer validation and 16 KiB alignment checks in ValidMemory() using MemoryAlignment = 0x4000 across firstMemory and secondMemory in scePadTrackerInit.
    • Verified bounds checks for integer arguments first in [0, 6] and second in [0, 7] returning PAD_TRACKER_ERROR_INVALID_ARG (0x80c40003).
    • Verified mutex locking and state checks across scePadTrackerInit, scePadTrackerTerm, scePadTrackerCalibrate, scePadTrackerReadState, and scePadTrackerUpdate.
    • Verified error codes 0x80c40001 (not initialized), 0x80c40002 (already initialized), 0x80c40003 (invalid arg), and 0x80c40004 (handle not found) against PS5 firmware 13.42 specifications.
    • Verified debt documentation in docs/dev/debt/changes/feat-padtracker-lifecycle.md and verified full test lifecycle and cleanup in GuestPadTracker.cpp.

Looks Good To Me

@github-actions github-actions Bot added the fix error Closes an issue (Fixes #N) label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Progress report (098c734 → 57fff40)

📈 System libraries: 46.93% (+0.01%, +3 implemented functions)

✅ 3 implemented
Library Name
libScePadTracker scePadTrackerCalibrate
libScePadTracker scePadTrackerInit
libScePadTracker scePadTrackerTerm

Changed libraries (implemented exports)

Library Before After Change
libScePadTracker 1/6 (16.67%) 4/6 (66.67%) +50.00%

@malekaifa

Copy link
Copy Markdown
Contributor

The Windows run 44084032846 does not show a PadTracker failure. The focused guest_pad_tracker test passed (test #4880, 0.03 s). The job failed later with two unrelated LibreSSL3 tests:

  • guest_libressl3_ec_parameters — exit 0xc0000409
  • guest_libressl3_asn1 — exit 0xc0000409

The full run reports 5,087 tests, 2 failed. I have not rerun the 50-minute Windows job; the available evidence points to those unrelated LibreSSL3 failures rather than this PR's changed paths.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the reviewed code implements the documented firmware checks and explicitly records the unimplemented tracker behavior.

What I ran

Reviewed head 9350539044ff338aab473901da5e4ecc8efdbfd6. No build or test commands were run. The author reports Windows and macOS test runs in the PR description; those results were not independently verified.

Results

Check Result Note
Source review passed All four changed files read
Build and tests not run Author reports Windows and macOS runs

Findings

Blocking

None.

Non-blocking

None.

Not verified

No builds or tests were run. Firmware behavior is based on the author's cited emulator research, not independently confirmed or measured on a console. review/files.json was not available through the reader, so exclusions were not verified; the manifest lists four changed files, all included and read.

To get this to a good state

Nothing is required.

@zaryabzip

Copy link
Copy Markdown
Contributor Author

@malekaifa thanks for going through that run. guest_pad_tracker passing and the two guest_libressl3_* aborts matches what I see too: neither touches PadTracker. I merged current main (57fff40fba), so the windows check will run again on a fresh tree.

@MarcZX10 thanks for the review.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 821a1cd into boykopovar:main Nov 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs fix error Closes an issue (Fixes #N) prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libScePadTracker: Init, Term, Calibrate, Update and ReadState need readings from the firmware module

5 participants