Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server_openvr): ✨ Defer TrackedDevices initialization #2754

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zmerp
Copy link
Member

@zmerp zmerp commented Mar 14, 2025

In this PR I make the following changes:

  • Move TrackedDevices initialization and registration from DriverProvider::Init() to InitializeStreaming()
  • Don't wait for the HMD activation to start the alvr_server_openvr event loop
  • Because of this, to avoid race conditions, TrackedDevice::registrer_device() now waits for the ITrackedDeviceServerDriver::Activate() call.
  • Don't store tracked devices in g_driver_provider until they are successfully activated. This requires changing the signature of SetOpenvrProps() and RegisterButtons() to reference the devices by pointer instead of ID. Allow controllers and trackers to fail registration (we are already handling the absence of any of these devices)

Notably, In this PR i'm not implementing the skip of the first SteamVR restart when the client first connects, this will be done in the next PRs.

@zmerp zmerp force-pushed the deferred-steamvr-init branch from c581a03 to 45477fb Compare March 14, 2025 02:56
@zmerp zmerp force-pushed the deferred-steamvr-init branch from 45477fb to e06ab43 Compare March 14, 2025 03:25
@zmerp zmerp force-pushed the deferred-steamvr-init branch from bd3855a to 511a005 Compare March 14, 2025 04:01
this->device_class,
(vr::ITrackedDeviceServerDriver*)this
)) {
Error("Failed to register device");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could maybe use some additional information like the serial number, to aid in debugging

ptr,
};

pub fn set_openvr_prop(device_id: u64, prop: OpenvrProperty) {
pub fn set_openvr_prop(instance_ptr: Option<*mut c_void>, device_id: u64, prop: OpenvrProperty) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the biggest fan of this api, since it behaves like an enum but isn't one, but it's fine if need be

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean enum? Do you think we should just check for null pointer? (maybe we should)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use either a device id or a instance ptr, so an enum DeviceHandle { DeviceId, Pts }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that won't work because I use the device_id always, and only optionally instance_ptr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants