feat(libSceHmd2): answer the gaze results without an open headset as the console does #8907

Merged
hypermoist merged 2 commits from upstream-pr/8907 into main 2026-10-23 01:13:37 +00:00
hypermoist commented 2026-10-21 05:33:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-21T05:33:54Z.


What

sceHmd2GazeGetResult and sceHmd2GazeGetResultForFoveatedRendering were parameterless stubs that threw. Horizon Call of the Mountain (PPSA05666) imports both; discussion #6214 lists them among its throwing libSceHmd2 imports.

In the decrypted PS5 12.00 libSceHmd2.sprx (lAoFUedcfqA at 0x35510, retc+-uRMhk at 0x35FE0), both take (const param*, result*) and run these checks:

  1. A null parameter or result → 0x8A720008.
  2. A parameter size other than 0x10, or a result size other than 0x38 (or 0x18 for the foveated form) → 0x8A720009. Nothing is written.
  3. If the handle at param + 4 is not the module's open headset handle (or no headset is open), the result is filled with an invalid record and 0x8A720003 returned:
    • GazeGetResult: offset 4 = -1, offset 0x14 = -0.0f, offset 0x1C = -1.0f, everything else from offset 4 to 0x37 zero; offset 0 (size) is kept.
    • GazeGetResultForFoveatedRendering: offset 4 = -1, offset 8 = -0.0f, offset 0xC = 0.0f, offset 0x10 = -1.0f; offset 0x14 is not written.

Both return that code unchanged after the module's optional trace hook.

Upstream's sceHmd2Initialize reports no headset, so libSceHmd2 never has an open handle here, and step 3 always applies. This PR does exactly that, using upstream's existing openHandle state. If a headset handle is ever open, the calls still throw NotImplemented rather than invent gaze data. The firmware's SDK-version special case for a stale handle is not reachable without an open headset and is not modelled.

The bodies are written from this observed behaviour; nothing from the module is copied.

Tested

Linux (CachyOS, GCC, Release): full build. All 543 guest_*, kernel and Ampr tests pass. New guest_hmd2_gaze (a separate file, since #7658 and #8645 edit GuestHmd2.cpp) checks:

  • the null and size errors, with nothing written;
  • every word of both invalid records, including the sign of the -0.0f;
  • that offset 0x14 of the foveated result is left alone;
  • handle 0.

Writing 0.0f in place of -1.0f makes the test fail. The existing guest_hmd2 still passes.

tools/check_conventions.py is clean. No open PR implements these two calls. A three-way merge against every open PR touching these files, including #7658 and #8645, adds no conflicts: Hmd2.hpp is untouched, and the new types sit at the stubs they replace.

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 (Claude Code), reviewed by the contributor

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4946913244 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8907). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-21T05:33:54Z. --- ### What `sceHmd2GazeGetResult` and `sceHmd2GazeGetResultForFoveatedRendering` were parameterless stubs that threw. Horizon Call of the Mountain (PPSA05666) imports both; discussion #6214 lists them among its throwing `libSceHmd2` imports. In the decrypted PS5 12.00 `libSceHmd2.sprx` (`lAoFUedcfqA` at 0x35510, `retc+-uRMhk` at 0x35FE0), both take `(const param*, result*)` and run these checks: 1. A null parameter or result → `0x8A720008`. 2. A parameter `size` other than 0x10, or a result `size` other than 0x38 (or 0x18 for the foveated form) → `0x8A720009`. Nothing is written. 3. If the handle at `param + 4` is not the module's open headset handle (or no headset is open), the result is filled with an invalid record and `0x8A720003` returned: - `GazeGetResult`: offset 4 = -1, offset 0x14 = -0.0f, offset 0x1C = -1.0f, everything else from offset 4 to 0x37 zero; offset 0 (`size`) is kept. - `GazeGetResultForFoveatedRendering`: offset 4 = -1, offset 8 = -0.0f, offset 0xC = 0.0f, offset 0x10 = -1.0f; offset 0x14 is not written. Both return that code unchanged after the module's optional trace hook. Upstream's `sceHmd2Initialize` reports no headset, so `libSceHmd2` never has an open handle here, and step 3 always applies. This PR does exactly that, using upstream's existing `openHandle` state. If a headset handle is ever open, the calls still throw `NotImplemented` rather than invent gaze data. The firmware's SDK-version special case for a stale handle is not reachable without an open headset and is not modelled. The bodies are written from this observed behaviour; nothing from the module is copied. ### Tested Linux (CachyOS, GCC, Release): full build. All 543 `guest_*`, kernel and Ampr tests pass. New `guest_hmd2_gaze` (a separate file, since #7658 and #8645 edit `GuestHmd2.cpp`) checks: - the null and size errors, with nothing written; - every word of both invalid records, including the sign of the -0.0f; - that offset 0x14 of the foveated result is left alone; - handle 0. Writing 0.0f in place of -1.0f makes the test fail. The existing `guest_hmd2` still passes. `tools/check_conventions.py` is clean. No open PR implements these two calls. A three-way merge against every open PR touching these files, including #7658 and #8645, adds no conflicts: `Hmd2.hpp` is untouched, and the new types sit at the stubs they replace. ### 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 (Claude Code), reviewed by the contributor 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
MarcZX10 commented 2026-10-21 05:39:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:39:20Z.


I compiled the exact PR Export.cpp and GuestHmd2Gaze.cpp on Linux with GCC 12.2 under -Wall -Wextra -Werror; the focused executable passes. The standalone link used stubs for the unrelated NotImplemented and process-parameter helpers, which this no-headset test does not call. git diff --check against upstream/main also passes. This is focused host validation, not a full project build or independent console measurement.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308941548 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8907#issuecomment-6308941548). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T05:39:20Z. --- I compiled the exact PR `Export.cpp` and `GuestHmd2Gaze.cpp` on Linux with GCC 12.2 under `-Wall -Wextra -Werror`; the focused executable passes. The standalone link used stubs for the unrelated NotImplemented and process-parameter helpers, which this no-headset test does not call. `git diff --check` against upstream/main also passes. This is focused host validation, not a full project build or independent console measurement.
github-actions[bot] commented 2026-10-21 05:42:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T05:42:36Z.


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/prx/libSceHmd2/CMakeLists.txt
PR 8645 core/libs/prx/libSceHmd2/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308983662 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8907#issuecomment-6308983662). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T05:42:36Z. --- <!-- pr-overlap --> 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/prx/libSceHmd2/CMakeLists.txt` | | [PR 8645](https://www.github.com/boykopovar/AnyPS5/pull/8645) | `core/libs/prx/libSceHmd2/Export.cpp` |
hypermoist commented 2026-10-22 09:11:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-22T09:11:03Z.


@MarcZX10 thanks for compiling it with -Wall -Wextra -Werror. Since your run I merged main, and the exports now use the shared Hmd2::GazeResultParameter, GazeResult and FoveatedRenderingResult types from main instead of this PR's own copies. The behaviour hasn't changed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337099942 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8907#issuecomment-6337099942). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-22T09:11:03Z. --- @MarcZX10 thanks for compiling it with `-Wall -Wextra -Werror`. Since your run I merged `main`, and the exports now use the shared `Hmd2::GazeResultParameter`, `GazeResult` and `FoveatedRenderingResult` types from `main` instead of this PR's own copies. The behaviour hasn't changed.
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!8907
No description provided.