fix(libScePad): check scePadSetVibrationMode's arguments in the console's order #5264

Merged
hugodearaujo merged 1 commit from upstream-pr/5264 into main 2026-10-14 20:56:29 +00:00
hugodearaujo commented 2026-10-13 16:00:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-13T16:00:15Z.


What

scePadSetVibrationMode checked the handle first and accepted modes 0 to 3, before or after scePadInit. I called the console's export from a homebrew payload on a PS5 (firmware 13.60):

Call Console main
any handle and mode, before scePadInit 0x80920005 checks the handle and mode
handle -1, 0 or 12345, mode -1 or 0 INVALID_ARG (0x80920001) INVALID_HANDLE
handle -1, 0 or 12345, mode 1 to 5 INVALID_HANDLE (0x80920003) INVALID_HANDLE
open handle, mode 0 INVALID_ARG (mode checked before the handle) 0

So the console rejects a mode of 0 or below before it looks at the handle, and the call fails with NOT_INITIALIZED (0x80920005, named PAD_ERROR_NOT_INITIALIZED here) until scePadInit. Modes above 3 on an open handle could not be measured, because scePadOpen does not open a pad in the payload (0x809b0001). They keep returning INVALID_ARG after the handle check, and the TechnicalDebt entry says so.

Evidence from titles is weak, and this PR is only for matching the console. Hollow Knight: Silksong (PPSA12544) calls scePadSetVibrationMode with handle -1 and mode 1 three times, and Hades (PPSA03355) with its open handle and mode 1. Both already got the console's answer on main. The calls that change here (mode 0 or below, or a call before scePadInit) were not seen in a title. The change keeps the answers correct for a title that passes them.

Overlap: #5038 rewrites the libScePad TechnicalDebt section, including the line before scePadSetVibrationMode's entry, so the two conflict on that one line of docs/dev/debt/libScePad.md. Whichever lands second resolves it.

Tested

  • PS5 firmware 13.60: the table above.
  • Linux: full CTest 1065/1066. The new guest_pad_vibration_mode checks every row; it aborts on main. guest_pad passes unchanged. agc_driver_tessellation segfaults the same way on current main.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1092 tests with no failures (the GPU tests skip in this VM); guest_pad and guest_pad_vibration_mode pass.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4845959355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5264). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-13T16:00:15Z. --- ### What `scePadSetVibrationMode` checked the handle first and accepted modes 0 to 3, before or after `scePadInit`. I called the console's export from a homebrew payload on a PS5 (firmware 13.60): | Call | Console | `main` | |---|---|---| | any handle and mode, before `scePadInit` | **`0x80920005`** | checks the handle and mode | | handle -1, 0 or 12345, mode -1 or 0 | **`INVALID_ARG`** (`0x80920001`) | `INVALID_HANDLE` | | handle -1, 0 or 12345, mode 1 to 5 | `INVALID_HANDLE` (`0x80920003`) | `INVALID_HANDLE` | | open handle, mode 0 | **`INVALID_ARG`** (mode checked before the handle) | 0 | So the console rejects a mode of 0 or below before it looks at the handle, and the call fails with NOT_INITIALIZED (`0x80920005`, named `PAD_ERROR_NOT_INITIALIZED` here) until `scePadInit`. Modes above 3 on an open handle could not be measured, because `scePadOpen` does not open a pad in the payload (`0x809b0001`). They keep returning `INVALID_ARG` after the handle check, and the TechnicalDebt entry says so. **Evidence from titles is weak, and this PR is only for matching the console.** Hollow Knight: Silksong (PPSA12544) calls `scePadSetVibrationMode` with handle -1 and mode 1 three times, and Hades (PPSA03355) with its open handle and mode 1. Both already got the console's answer on `main`. The calls that change here (mode 0 or below, or a call before `scePadInit`) were not seen in a title. The change keeps the answers correct for a title that passes them. Overlap: #5038 rewrites the libScePad TechnicalDebt section, including the line before `scePadSetVibrationMode`'s entry, so the two conflict on that one line of `docs/dev/debt/libScePad.md`. Whichever lands second resolves it. ### Tested - PS5 firmware 13.60: the table above. - Linux: full CTest 1065/1066. The new `guest_pad_vibration_mode` checks every row; it aborts on `main`. `guest_pad` passes unchanged. `agc_driver_tessellation` segfaults the same way on current `main`. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1092 tests with no failures (the GPU tests skip in this VM); `guest_pad` and `guest_pad_vibration_mode` pass. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 16:35:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T16:35:04Z.


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
#5523 core/libs/prx/libScePad/Export.cpp L255
docs/dev/debt/libScePad.md L8
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150349605 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5264#issuecomment-6150349605). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T16:35:04Z. --- <!-- 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 | |---|---|---|---| | #5523 | `core/libs/prx/libScePad/Export.cpp` [L255](https://github.com/boykopovar/AnyPS5/blob/7289938cecabc863a6dbcaf6026be861535def79/core/libs/prx/libScePad/Export.cpp#L255)<br>`docs/dev/debt/libScePad.md` [L8](https://github.com/boykopovar/AnyPS5/blob/7289938cecabc863a6dbcaf6026be861535def79/docs/dev/debt/libScePad.md#L8) | | |
milescoviello commented 2026-10-13 22:22:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-13T22:22:52Z.


A data point for the "modes above 3 on an open handle" case: Crimson Desert (PPSA25286) calls scePadSetVibrationMode(1, 5) on its open handle at start-up. I traced it under gdb on Linux, and on main it gets INVALID_ARG. I opened #5523, which accepts 5 next to 3, with that evidence. It changes the same line as this PR, so whichever of the two lands second gets a one-line rebase. On top of this PR it would be if (mode > 3 && mode != 5) after your mode <= 0 check.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156481871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5264#issuecomment-6156481871). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-13T22:22:52Z. --- A data point for the "modes above 3 on an open handle" case: Crimson Desert (PPSA25286) calls `scePadSetVibrationMode(1, 5)` on its open handle at start-up. I traced it under gdb on Linux, and on `main` it gets `INVALID_ARG`. I opened #5523, which accepts 5 next to 3, with that evidence. It changes the same line as this PR, so whichever of the two lands second gets a one-line rebase. On top of this PR it would be `if (mode > 3 && mode != 5)` after your `mode <= 0` check. AI-assisted: yes
adriadam10 commented 2026-10-14 18:11:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:11:13Z.


Checked the diff against the table in the description, ran the build and the scoped ctest (34/34, guest_pad_vibration_mode passes; it does not build without the change since it uses PAD_ERROR_NOT_INITIALIZED), and the TechnicalDebt entry replaces the old one. The console measurements are taken from the description. Merging once the full Build is green; #5523 will need its one-line rebase on top.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175101052 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5264#issuecomment-6175101052). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:11:13Z. --- Checked the diff against the table in the description, ran the build and the scoped ctest (34/34, `guest_pad_vibration_mode` passes; it does not build without the change since it uses `PAD_ERROR_NOT_INITIALIZED`), and the TechnicalDebt entry replaces the old one. The console measurements are taken from the description. Merging once the full Build is green; #5523 will need its one-line rebase on top.
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!5264
No description provided.