feat(libSceHmd2): report a console without a PS VR2 headset #7323

Merged
MontyMcK merged 2 commits from upstream-pr/7323 into main 2026-10-18 00:56:40 +00:00
MontyMcK commented 2026-10-17 23:34:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MontyMcK on 2026-10-17T23:34:22Z.


What

libSceHmd2 now acts like a PS5 with no PS VR2 plugged in. before this sceHmd2Initialize failed with libSceHmd's 0x81110016, which a real console never gives a game.

implemented sceHmd2Initialize, Terminate, Open, Close, GetDeviceInformation, GetDeviceInformationByHandle, GetFieldOfView, GetFieldOfViewWithoutHandle and SetVibration (1/31 -> 9/31). reprojection, gaze and all of libSceVrTracker2 still throw

where the behaviour comes from:

  • firmware 13.20 libSceHmd2.sprx pulled off my PS5 and disassembled: the error codes (0x8a72xxxx), check order, the 28 byte device info layout and its fixed values (4000x2040 panel, 5555/4160 latency, 2.0 image distance), the default FOV tangents and the SDK 7.00 checks
  • a payload on the same PS5 with no headset connected: the /dev/hmd2_cmd page the library reads says not connected, status 2, user -1, and the /dev/hmd2_imu open ioctl succeeds, so Open hands back a handle even with no headset. every call made before init matched the disassembly. Initialize itself crashes inside a payload (it's not an app), so results after init are the firmware code run against that measured state
  • the SDK version comes from the title's process params (+0x10). below 7.00 device info fills in the user id, from 7.00 Open rejects other users

what i couldn't settle is in the debt file (Initialize's app info checks and sceMbusInit aren't modelled, Open for a non initial user below SDK 7.00 throws)

heads up: PPSA01317, PPSA07411, PPSA09030, PPSA15878 and PPSA29866 used to skip VR because init failed. now they get further, so anything that then calls a reprojection/gaze/VrTracker2 export throws instead of skipping VR. i don't own any of them so they're not tested

ProcessParametersFixture.hpp sets up process params for the test. it keeps the page executable while patching the program headers. the copy in ApplicationHeap.cpp doesn't, which is why application_heap_lazy segfaults on my build (the PLT is on that page). left that one alone, separate thing

probe output, no headset connected
open /dev/hmd2_cmd = 8 errno 0
hmd2_cmd page:
  0000: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00
  0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0020: 00 00 00 00 02 00 00 00 ff ff ff ff 00 00 00 00
  (rest zero apart from the handle slots at 0x144, all -1)
open /dev/hmd2_imu = 8 errno 0
ioctl open-device(user 0xffffffff) = 234946560 (0xe010000) errno 0
ioctl close-device(234946560) = 0 errno 0
before init: GetDeviceInformation = 0x8a720002 (output cleared to 0)
before init: GetDeviceInformation(NULL) = 0x8a720008
before init: GetFieldOfViewWithoutHandle = 0x8a720002
before init: Close(0) = 0x8a720002
before init: Terminate = 0x8a720002
before init: SetVibration(0, 0) = 0x0
Initialize(NULL) = 0x8a720008

Tested

Fedora 44, GCC 16.2, full build. guest_hmd2 passes, select_tests.py ctest 186/186 on this branch, check_conventions.py passes. a wider run before rebasing (1382 tests) only failed agc_driver_tessellation, which segfaults on my RX 9070 XT and has nothing from this PR in it. not built on windows, no title run

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: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4904858728 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7323). Originally posted by [MontyMcK](https://github.com/MontyMcK) on 2026-10-17T23:34:22Z. --- ### What libSceHmd2 now acts like a PS5 with no PS VR2 plugged in. before this `sceHmd2Initialize` failed with libSceHmd's `0x81110016`, which a real console never gives a game. implemented `sceHmd2Initialize`, `Terminate`, `Open`, `Close`, `GetDeviceInformation`, `GetDeviceInformationByHandle`, `GetFieldOfView`, `GetFieldOfViewWithoutHandle` and `SetVibration` (1/31 -> 9/31). reprojection, gaze and all of libSceVrTracker2 still throw where the behaviour comes from: - firmware 13.20 `libSceHmd2.sprx` pulled off my PS5 and disassembled: the error codes (`0x8a72xxxx`), check order, the 28 byte device info layout and its fixed values (4000x2040 panel, 5555/4160 latency, 2.0 image distance), the default FOV tangents and the SDK 7.00 checks - a payload on the same PS5 with no headset connected: the `/dev/hmd2_cmd` page the library reads says not connected, status 2, user -1, and the `/dev/hmd2_imu` open ioctl succeeds, so `Open` hands back a handle even with no headset. every call made before init matched the disassembly. `Initialize` itself crashes inside a payload (it's not an app), so results after init are the firmware code run against that measured state - the SDK version comes from the title's process params (+0x10). below 7.00 device info fills in the user id, from 7.00 `Open` rejects other users what i couldn't settle is in the debt file (`Initialize`'s app info checks and `sceMbusInit` aren't modelled, `Open` for a non initial user below SDK 7.00 throws) heads up: PPSA01317, PPSA07411, PPSA09030, PPSA15878 and PPSA29866 used to skip VR because init failed. now they get further, so anything that then calls a reprojection/gaze/VrTracker2 export throws instead of skipping VR. i don't own any of them so they're not tested `ProcessParametersFixture.hpp` sets up process params for the test. it keeps the page executable while patching the program headers. the copy in `ApplicationHeap.cpp` doesn't, which is why `application_heap_lazy` segfaults on my build (the PLT is on that page). left that one alone, separate thing <details><summary>probe output, no headset connected</summary> ``` open /dev/hmd2_cmd = 8 errno 0 hmd2_cmd page: 0000: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0020: 00 00 00 00 02 00 00 00 ff ff ff ff 00 00 00 00 (rest zero apart from the handle slots at 0x144, all -1) open /dev/hmd2_imu = 8 errno 0 ioctl open-device(user 0xffffffff) = 234946560 (0xe010000) errno 0 ioctl close-device(234946560) = 0 errno 0 before init: GetDeviceInformation = 0x8a720002 (output cleared to 0) before init: GetDeviceInformation(NULL) = 0x8a720008 before init: GetFieldOfViewWithoutHandle = 0x8a720002 before init: Close(0) = 0x8a720002 before init: Terminate = 0x8a720002 before init: SetVibration(0, 0) = 0x0 Initialize(NULL) = 0x8a720008 ``` </details> ### Tested Fedora 44, GCC 16.2, full build. `guest_hmd2` passes, `select_tests.py ctest` 186/186 on this branch, `check_conventions.py` passes. a wider run before rebasing (1382 tests) only failed `agc_driver_tessellation`, which segfaults on my RX 9070 XT and has nothing from this PR in it. not built on windows, no title run ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.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
github-actions[bot] commented 2026-10-18 00:05:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T00:05:47Z.


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 6844 core/libs/tests/GuestHmd2.cpp L8-12, L34

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 5038 docs/dev/debt/libScePad.md
PR 6044 core/libs/prx/libSceHmd2/CMakeLists.txt
core/libs/tests/GuestHmd2.cpp
PR 6447 docs/dev/debt/libSceHmd2.md
docs/dev/debt/libScePad.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243514496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7323#issuecomment-6243514496). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T00:05:47Z. --- <!-- 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 6844](https://www.github.com/boykopovar/AnyPS5/pull/6844) | `core/libs/tests/GuestHmd2.cpp` [L8-12](https://github.com/boykopovar/AnyPS5/blob/f1af6c591588b257437f51e5ac1740fb788b231d/core/libs/tests/GuestHmd2.cpp#L8-L12), [L34](https://github.com/boykopovar/AnyPS5/blob/f1af6c591588b257437f51e5ac1740fb788b231d/core/libs/tests/GuestHmd2.cpp#L34) | | | 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 5038](https://www.github.com/boykopovar/AnyPS5/pull/5038) | `docs/dev/debt/libScePad.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceHmd2/CMakeLists.txt`<br>`core/libs/tests/GuestHmd2.cpp` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `docs/dev/debt/libSceHmd2.md`<br>`docs/dev/debt/libScePad.md` |
MarcZX10 commented 2026-10-18 00:40:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T00:40:53Z.


I manually checked the #6844 overlap reported by the bot. main already contains sceHmd2ReprojectionGetStatus() in Export.cpp; #6844 adds a second copy of that same stub, so I asked its author to remove the duplicate. Your PR leaves the existing main definition in place and implements other HMD2 functions; I did not find a duplicate implementation between your changes and the rest of #6844. The shared Export.cpp/test edits may still need a rebase after either PR lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243830965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7323#issuecomment-6243830965). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T00:40:53Z. --- I manually checked the #6844 overlap reported by the bot. `main` already contains `sceHmd2ReprojectionGetStatus()` in `Export.cpp`; #6844 adds a second copy of that same stub, so I asked its author to remove the duplicate. Your PR leaves the existing main definition in place and implements other HMD2 functions; I did not find a duplicate implementation between your changes and the rest of #6844. The shared Export.cpp/test edits may still need a rebase after either PR lands.
KernelPanicNT commented 2026-10-18 15:11:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-18T15:11:26Z.


@MontyMcK @T3cm0 a follow-up from the GT7 thread: frankea reports in #4697 that Gran Turismo 7 (PPSA01317) on current main now aborts 5 to 8 s in on sceHmd2ReprojectionQueryBufferSizeAlign not implemented (libSceHmd2.prx+0x1b70, called from module initialisation). Since this PR, sceHmd2Initialize and sceHmd2Open succeed, so the title's PS VR2 probe goes on to the reprojection size queries. Horizon Call of the Mountain follows the same chain.

I'd rather not guess sizes (#6272 was closed for that). Do your firmware 13.20 disassembly or a no-headset payload run cover sceHmd2ReprojectionQueryBufferSizeAlign, sceHmd2ReprojectionQueryDisplayBufferSizeAlign and sceHmd2ReprojectionQuerySeeThroughBufferSizeAlign? If you're already on it, I'll stay out of the way. If not, and you can share what the console returns, I'm happy to write the change with a test and a debt entry and credit the measurement.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251511628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7323#issuecomment-6251511628). Originally posted by [KernelPanicNT](https://github.com/KernelPanicNT) on 2026-10-18T15:11:26Z. --- @MontyMcK @T3cm0 a follow-up from the GT7 thread: frankea reports in [#4697](https://github.com/boykopovar/AnyPS5/discussions/4697) that Gran Turismo 7 (PPSA01317) on current `main` now aborts 5 to 8 s in on `sceHmd2ReprojectionQueryBufferSizeAlign not implemented` (`libSceHmd2.prx+0x1b70`, called from module initialisation). Since this PR, `sceHmd2Initialize` and `sceHmd2Open` succeed, so the title's PS VR2 probe goes on to the reprojection size queries. Horizon Call of the Mountain follows the same chain. I'd rather not guess sizes (#6272 was closed for that). Do your firmware 13.20 disassembly or a no-headset payload run cover `sceHmd2ReprojectionQueryBufferSizeAlign`, `sceHmd2ReprojectionQueryDisplayBufferSizeAlign` and `sceHmd2ReprojectionQuerySeeThroughBufferSizeAlign`? If you're already on it, I'll stay out of the way. If not, and you can share what the console returns, I'm happy to write the change with a test and a debt entry and credit the measurement.
MontyMcK commented 2026-10-18 20:09:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MontyMcK on 2026-10-18T20:09:31Z.


Thanks for tracing this. I don't have measurements for the ReprojectionQuery*SizeAlign functions, my work only covered Initialize and Open. That said, this is a regression from my PR, so I'll take it. I'm at work now but will write a fix when I get home in about 6 hours. My first step will be checking what Open should return with no headset connected, since reporting no device should stop GT7 and CotM before they reach the reprojection queries.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254570759 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7323#issuecomment-6254570759). Originally posted by [MontyMcK](https://github.com/MontyMcK) on 2026-10-18T20:09:31Z. --- Thanks for tracing this. I don't have measurements for the ReprojectionQuery*SizeAlign functions, my work only covered Initialize and Open. That said, this is a regression from my PR, so I'll take it. I'm at work now but will write a fix when I get home in about 6 hours. My first step will be checking what Open should return with no headset connected, since reporting no device should stop GT7 and CotM before they reach the reprojection queries.
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!7323
No description provided.