fix(pad): capture touch contact IDs with input samples #6485

Closed
Ondra97 wants to merge 1 commit from upstream-pr/6485 into main
Ondra97 commented 2026-10-15 17:06:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-15T17:06:43Z.


What

I reproduced touch contact IDs changing when a title drains older scePadRead samples after reading the current state. IDs were assigned while serializing samples, so reading an older release could change the identity of a still-held contact. A release and a new contact between reads could also reuse the old ID.

Assign IDs when input is published under the existing mutex and capture them with queued samples. The regression covers partial history reads, contact replacement, two-finger contacts, queue rollover and movement of a held contact. Timestamp behavior is unchanged.

Tested

Exact committed head: 75d4c11b343a61d9dfa8b3ce30839cefeb31026f. Tested upstream main snapshot: 0029e62f974c453a5f6c7333f3bdb13e770e3903.

During publication main advanced to fa9365ca74acae7c594618b0a857365774cc6f45. I compared its changes and checked a clean merge for this branch; none changes this fix's source or regression. The local results below belong to the exact tested head above, not to an untested synthetic merge with the newer main. Full merged-head CI remains for collaborator dispatch.

This branch is stacked on the unchanged original commit 4fe92c9c23c7bd861d63664d4efde3033b6226f6 from #6452, with its original author retained. That prerequisite fixes the current main's unrelated Windows fixture build failure (alignas(65536) exceeds the COFF maximum 8192). Merge #6452 first; this PR's own commit changes only its two runtime/regression files. The passing builds below include the prerequisite, with no test exclusions or private dependency changes.

  • Windows: Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja Release, BUILD_TESTING=ON. AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER. Full default application build including patched libraries passed with cmake --build build-team-worker-3-runtime --parallel. All 5/5 selected CPU/library tests passed without skips: patched_libraries, guest_pad, guest_pad_vibration_mode, pad_input_mapping, pad_keyboard_mouse. Conventions, committed whitespace, strict main synchronization and test-registration checks passed.
  • Windows GPU prerequisite check: agc_driver_gpu_indirect_arguments_misaligned_writer_ahead passed on the exact head above, on NVIDIA GeForce RTX 4070 Ti SUPER, Windows driver 32.0.16.1714, Windows 11 Pro 10.0.26300. ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1; the log confirms the selected physical device. One executed test, no skip. This checks the inherited fixture from #6452, not a rendering-performance or game result.
  • Linux: Ubuntu 24.04.5 LTS x86-64, GCC 13.3.0, CMake 3.28.3, Ninja Release, isolated VirtualBox source/build with 8 GB guest RAM. Full-runtime configuration; only the listed CPU targets and their native runtime dependencies were built. All 4/4 tests passed without skips: guest_pad, guest_pad_vibration_mode, pad_input_mapping, pad_keyboard_mouse. Source content was verified against the final committed Git blobs and common dependency revisions.

Real-runtime negative controls failed at reading an older sample changed the current held contact ID on Windows main f633042dfdf0d51f4af58fafbade3fa9d47fd169 and Linux main 92e50418f33b8950ceea950cb37331a941f5be0e; applying the production correction passed. The Pad source and regression are unchanged by the rebases. On the final committed Linux head, guest_pad also passed three consecutive repetitions.

Registered Linux touch-history regression main 92e50418 this fix
Failed guest_pad tests 1 0

I manually compared the related implementations and tests. #6337 changes fresh-sample timestamps independently. A separate Linux composition of the identical Pad sources from pre-rebase 68c8a853 with #6337 at 279fee87a077f413daa950deb73c2940232f0a3b passed 4/4 input tests; its timestamp regression failed when its two-line correction was omitted. Restoring the standalone touch-ID sources passed 4/4 again. This is Linux source-composition evidence, not a combined Windows result. I propose this PR first, then #6337 rebased retaining both now and touchIds; author agreement is pending. #6044 moves the shared test file and needs the regression preserved after relocation.

No full Linux application/all-libraries build, complete CTest suite, physical controller, console or retail-title run is claimed. Full hosted Windows/Linux CI requires collaborator dispatch under CONTRIBUTING.md.

Checklist

  • Based on the verified main snapshot above; newer main merges cleanly; no duplicate fix found; prerequisite #6452 is declared unchanged
  • 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); no silent stubs added
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source; none added
  • Generic behaviour, not specific to one title
  • Depends on: #6452
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, Windows driver 32.0.16.1714, Windows 11 Pro 10.0.26300 (inherited #6452 fixture)
  • AI-assisted: yes (Codex). I am responsible for the change.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4877016480 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6485). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-15T17:06:43Z. --- ### What I reproduced touch contact IDs changing when a title drains older `scePadRead` samples after reading the current state. IDs were assigned while serializing samples, so reading an older release could change the identity of a still-held contact. A release and a new contact between reads could also reuse the old ID. Assign IDs when input is published under the existing mutex and capture them with queued samples. The regression covers partial history reads, contact replacement, two-finger contacts, queue rollover and movement of a held contact. Timestamp behavior is unchanged. ### Tested Exact committed head: `75d4c11b343a61d9dfa8b3ce30839cefeb31026f`. Tested upstream main snapshot: `0029e62f974c453a5f6c7333f3bdb13e770e3903`. During publication main advanced to `fa9365ca74acae7c594618b0a857365774cc6f45`. I compared its changes and checked a clean merge for this branch; none changes this fix's source or regression. The local results below belong to the exact tested head above, not to an untested synthetic merge with the newer main. Full merged-head CI remains for collaborator dispatch. This branch is stacked on the **unchanged** original commit `4fe92c9c23c7bd861d63664d4efde3033b6226f6` from #6452, with its original author retained. That prerequisite fixes the current main's unrelated Windows fixture build failure (`alignas(65536)` exceeds the COFF maximum 8192). Merge #6452 first; this PR's own commit changes only its two runtime/regression files. The passing builds below include the prerequisite, with no test exclusions or private dependency changes. - **Windows:** Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja Release, BUILD_TESTING=ON. AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER. Full default application build including patched libraries passed with `cmake --build build-team-worker-3-runtime --parallel`. All **5/5** selected CPU/library tests passed without skips: `patched_libraries`, `guest_pad`, `guest_pad_vibration_mode`, `pad_input_mapping`, `pad_keyboard_mouse`. Conventions, committed whitespace, strict main synchronization and test-registration checks passed. - **Windows GPU prerequisite check:** `agc_driver_gpu_indirect_arguments_misaligned_writer_ahead` passed on the exact head above, on NVIDIA GeForce RTX 4070 Ti SUPER, Windows driver 32.0.16.1714, Windows 11 Pro 10.0.26300. `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`; the log confirms the selected physical device. One executed test, no skip. This checks the inherited fixture from #6452, not a rendering-performance or game result. - **Linux:** Ubuntu 24.04.5 LTS x86-64, GCC 13.3.0, CMake 3.28.3, Ninja Release, isolated VirtualBox source/build with 8 GB guest RAM. Full-runtime configuration; only the listed CPU targets and their native runtime dependencies were built. All **4/4** tests passed without skips: `guest_pad`, `guest_pad_vibration_mode`, `pad_input_mapping`, `pad_keyboard_mouse`. Source content was verified against the final committed Git blobs and common dependency revisions. Real-runtime negative controls failed at `reading an older sample changed the current held contact ID` on Windows main `f633042dfdf0d51f4af58fafbade3fa9d47fd169` and Linux main `92e50418f33b8950ceea950cb37331a941f5be0e`; applying the production correction passed. The Pad source and regression are unchanged by the rebases. On the final committed Linux head, `guest_pad` also passed three consecutive repetitions. | Registered Linux touch-history regression | main `92e50418` | this fix | |---|---:|---:| | Failed `guest_pad` tests | 1 | 0 | I manually compared the related implementations and tests. #6337 changes fresh-sample timestamps independently. A separate Linux composition of the identical Pad sources from pre-rebase `68c8a853` with #6337 at `279fee87a077f413daa950deb73c2940232f0a3b` passed 4/4 input tests; its timestamp regression failed when its two-line correction was omitted. Restoring the standalone touch-ID sources passed 4/4 again. This is Linux source-composition evidence, not a combined Windows result. I propose this PR first, then #6337 rebased retaining both `now` and `touchIds`; author agreement is pending. #6044 moves the shared test file and needs the regression preserved after relocation. No full Linux application/all-libraries build, complete CTest suite, physical controller, console or retail-title run is claimed. Full hosted Windows/Linux CI requires collaborator dispatch under CONTRIBUTING.md. ### Checklist - [x] Based on the verified `main` snapshot above; newer main merges cleanly; no duplicate fix found; prerequisite #6452 is declared unchanged - [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) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); no silent stubs added - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source; none added - [x] Generic behaviour, not specific to one title - [x] Depends on: #6452 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, Windows driver 32.0.16.1714, Windows 11 Pro 10.0.26300 (inherited #6452 fixture) - [x] AI-assisted: yes (Codex). I am responsible for the change.
github-actions[bot] commented 2026-10-15 17:29:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T17:29:20Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6337 core/libs/prx/libScePad/src/PadState.cpp L211, L222
PR 6478 core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp L25

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestPad.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6198201883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6485#issuecomment-6198201883). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T17:29:20Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6337](https://www.github.com/boykopovar/AnyPS5/pull/6337) | `core/libs/prx/libScePad/src/PadState.cpp` [L211](https://github.com/boykopovar/AnyPS5/blob/fa9365ca74acae7c594618b0a857365774cc6f45/core/libs/prx/libScePad/src/PadState.cpp#L211), [L222](https://github.com/boykopovar/AnyPS5/blob/fa9365ca74acae7c594618b0a857365774cc6f45/core/libs/prx/libScePad/src/PadState.cpp#L222) | | | | [PR 6478](https://www.github.com/boykopovar/AnyPS5/pull/6478) | `core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp` [L25](https://github.com/boykopovar/AnyPS5/blob/fa9365ca74acae7c594618b0a857365774cc6f45/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp#L25) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestPad.cpp` |

Pull request closed

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!6485
No description provided.