mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-25 07:46:01 +03:00
[PR #3442] [MERGED] Libraries: Improved libSceHmd stubs #3468
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#3468
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/3442
Author: @StevenMiller123
Created: 8/21/2025
Status: ✅ Merged
Merged: 8/21/2025
Merged by: @georgemoralis
Base:
main← Head:hmd-stubs📝 Commits (10+)
275fd02Initial work7e046fdMore work6271067More stufffae85f9Update hmd.cppf038236Separate Reprojection and Distortion functions9aa8d6fFix weird Git issue4be916dImprove error documentation2fc3a79Fix sceHmdGet2DEyeOffset86e6150Merge remote-tracking branch 'upstream/main' into hmd-stubsb3962acUpdate hmd.cpp📊 Changes
8 files changed (+725 additions, -443 deletions)
View changed files
📝
CMakeLists.txt(+2 -0)📝
src/common/elf_info.h(+1 -0)📝
src/core/libraries/hmd/hmd.cpp(+232 -391)📝
src/core/libraries/hmd/hmd.h(+116 -52)➕
src/core/libraries/hmd/hmd_distortion.cpp(+107 -0)➕
src/core/libraries/hmd/hmd_error.h(+27 -0)➕
src/core/libraries/hmd/hmd_reprojection.cpp(+238 -0)📝
src/emulator.cpp(+2 -0)📄 Description
Like my previous PRs, this PR focuses on emulating libSceHmd functions as if the PSVR headset is not connected. This library is much more of a mess, due to a variety of bugs in the firmware library, which I show later in this PR description.
libSceHmd has three main components, the base library, the sceHmdDistortion sublibrary, and the sceHmdReprojection sublibrary. Both distortion and reprojection functions are fairly independant from the main library, with separate initialization functions, separate global variables, a separate shared memory allocation, and much more. As such, I've separated functions related to distortion and reprojection into separate files, though most of my focus was on the primary libSceHmd functions.
Along with the libSceHmd functions I've implemented, I also added a check during emulator startup to log if the game's param.sfo specifies PSVR support or PSVR requirements. While specifying these in a game's param.sfo doesn't seem to affect library behavior, it's safe to assume games that require PSVR won't properly check if a PSVR is connected, since the PS4 doesn't let you boot PSVR-required games without connecting a PSVR headset.
Throughout this PR, you'll see many functions returning
ORBIS_HMD_ERROR_HANDLE_INVALID. This was a large point of confusion for me while testing, but the core issue is in how the actual library checks for a connected PSVR headset. Much of the library reads straight from device memory, and working functions check an field within this memory space that seems to be intended for checking if a headset is connected. There are several internal functions that just check for the presence of this device mapping, which exists so long as the library is loaded.Attached are images from my library decompilation demonstrating the most common form of this bug.


As is visible here, the library does have an error check for
ORBIS_HMD_ERROR_DEVICE_DISCONNECTED, but it relies on thisGetUserIdfunction returning an error. SinceGetUserIdsucceeds so long as the library is initialized, this error check is never actually hit on real hardware. I haven't been able to figure out what user_id is outputted byGetUserId, but as far as I've been able to test, it's not what the library expects.Here's an example of an internal function with a working error check.


TLDR: All the seemingly random
ORBIS_HMD_ERROR_HANDLE_INVALIDerror returns are intentional, and are the result of me replicating bugs within the actual library.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.