Skip to content

fix(libScePad): queue input states for scePadRead - #1076

Merged
adriadam10 merged 7 commits into
boykopovar:mainfrom
TideOPL:fix/pad-read-debt-note
Oct 11, 2026
Merged

adriadam10 merged 7 commits into
boykopovar:mainfrom
TideOPL:fix/pad-read-debt-note

Conversation

@TideOPL

@TideOPL TideOPL commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What

scePadRead reported only the current pad state and always returned 1, so input that changed and changed back between two reads (a quick tap) was lost.

  • libScePad: every state published by PadPublishInput is queued (up to 64, oldest dropped). scePadRead drains up to num entries oldest first, each with its own timestamp, and returns the count. With nothing queued it writes the current state and returns 1, as before. scePadReadState is unchanged. The scePadRead entry in TechnicalDebt added earlier in this PR is removed.

New test: CheckReadQueue in guest_pad (press and release between two reads must both be reported).

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 5070: full ctest, 386/387 pass. The one failure, agc_driver_scalar_sop1 (movrelsd_2_b32 s13 is 0x00007fff, expected 0xd4cbd76d), fails identically on main without these changes.
  • Ubuntu 24.04 (WSL), GCC 13.3: all non-GPU tests pass.
  • CI on 39463913 (merged into current main): linux and windows pass, including guest_pad, without the Time.cpp fix from fix(libkernel): read the process start before the clock in process time #1501.
  • No title or homebrew tested.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

TideOPL and others added 4 commits October 7, 2026 10:15
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sceKernelGetProcessTime and sceKernelGetProcessTimeCounter subtracted
GetStartNanos() from GetMonotonicNanos() in one expression. GCC reads the
clock first, so on the first call in a process the start was captured
after it and the result wrapped to about 2^64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scePadRead reported only the current state, so input that changed and
changed back between two reads was lost. Published states are now kept in
a queue of up to 64 and drained oldest first; with none queued the current
state is returned as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per CONVENTIONS, code comments only mark technical debt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TideOPL TideOPL changed the title docs(libScePad): record the scePadRead queue gap in technical debt fix(libScePad): queue input states for scePadRead Oct 7, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Could you split the Time.cpp fix into its own PR? It's a real bug with its own test and can go in on its own. The scePadRead queue changes library behaviour, so that part needs a title that loses input on main.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@TideOPL

TideOPL commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Done: the Time.cpp fix and its tests are now in #1501. #1076 is just the scePadRead queue and depends on #1501 since guest_pad needs the fix. I'll look for a title that loses input on main for the pad part.

Keeping lastFuseTime at its maximum never let it recover from a process time that wrapped on the first call (fixed separately in boykopovar#1501), so tilt correction stopped and guest_pad failed. Queued states keep their own timestamp; the orientation is fused once at the time of the read, as scePadReadState does.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked on Linux (merged onto current main): build clean, full ctest green, guest_pad passes, and fails with the library changes reverted (test kept). Behaviour matches KytyPS5 PadRead and shadPS4 scePadRead, which both return queued states (oldest first) and fall back to one current state when none are queued, so I consider Dean's request for a title satisfied by those references.

  • Blocked on #1501: the guest_pad test relies on the sceKernelGetProcessTime fix (you report it fails on Windows/GCC 15 without it). Please keep this PR as is and rebase once #1501 is merged; it can be merged right after.

@TideOPL

TideOPL commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking this, and for accepting the KytyPS5/shadPS4 references.

This PR no longer depends on #1501. Since 39463913, queued states keep their own timestamps, but orientation is fused once at read time, the same way scePadReadState does it. A wrapped first sceKernelGetProcessTime value then no longer stops tilt correction, which is what broke guest_pad.

CI on 39463913, merged into current main, is green on both linux and windows without the Time.cpp fix. Locally, merged onto main: Windows 479/479, Linux 485 pass (24 GPU tests skipped under WSL). I've updated the description to Depends on: none.

So this can go in on its own, before or after #1501. Could you take another look?

@spiicez21

Copy link
Copy Markdown

Checked on Windows 11 with WinLibs GCC 16.2.0 (UCRT, posix-seh), Release, 39463913 merged onto current main (c963432d):

  • Merge is clean; guest_pad_tests builds.
  • ctest -R '^guest_pad$': passed 3/3 runs (~0.33 s).
  • With the libScePad changes reverted (Export.cpp, PadState.hpp, PadState.cpp from main) and the new test kept, guest_pad fails (abort, 0xc0000409), so the test covers the change.

#1501 is now merged into main, so the blocker in the review no longer applies. Full ctest not run; GCC 16.2 instead of the documented 15.2.0.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rechecked on the current head (39463913) merged onto main: builds clean, guest_pad and the libs/libScePad ctests pass, and guest_pad fails with the library changes reverted (test kept). The Time.cpp dependency is gone (read-time orientation fusion) and #1501 is merged, so the earlier blocker no longer applies. Behaviour (oldest-first drain, one current state when the queue is empty) matches KytyPS5 PadRead and shadPS4 scePadRead. CI linux and windows are green; merging.

@adriadam10
adriadam10 merged commit 7feed27 into boykopovar:main Oct 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants