Skip to content

Instantly share code, notes, and snippets.

@perillamint
Last active September 8, 2024 20:33
Show Gist options
  • Save perillamint/6d454ea0bfeddd77952ecefe38a286b1 to your computer and use it in GitHub Desktop.
Save perillamint/6d454ea0bfeddd77952ecefe38a286b1 to your computer and use it in GitHub Desktop.
Dirty hack to let Monado initialize SteamVR and WMR (or any other HMD) together with MoToC.
diff --git a/src/xrt/drivers/steamvr_lh/steamvr_lh.cpp b/src/xrt/drivers/steamvr_lh/steamvr_lh.cpp
index 89d2f7aca..51aec6866 100644
--- a/src/xrt/drivers/steamvr_lh/steamvr_lh.cpp
+++ b/src/xrt/drivers/steamvr_lh/steamvr_lh.cpp
@@ -816,15 +816,15 @@ steamvr_lh_create_devices(struct xrt_system_devices **out_xsysd)
}
U_LOG_IFL_I(level, "Device search time complete.");
- if (out_xsysd == NULL || *out_xsysd != NULL) {
+ if (out_xsysd == NULL) { // || *out_xsysd != NULL) {
U_LOG_IFL_E(level, "Invalid output system pointer");
return xrt_result::XRT_ERROR_DEVICE_CREATION_FAILED;
}
- struct xrt_system_devices *xsysd = NULL;
- xsysd = &svrs->base;
+ struct xrt_system_devices *xsysd = *out_xsysd;
+ //xsysd = &svrs->base;
- xsysd->destroy = destroy;
+ //xsysd->destroy = destroy;
xsysd->get_roles = get_roles;
// Include the HMD
@@ -841,7 +841,7 @@ steamvr_lh_create_devices(struct xrt_system_devices **out_xsysd)
}
}
- *out_xsysd = xsysd;
+ //*out_xsysd = xsysd;
return xrt_result::XRT_SUCCESS;
}
diff --git a/src/xrt/state_trackers/prober/p_prober.c b/src/xrt/state_trackers/prober/p_prober.c
index ec16f3849..1b5b733f8 100644
--- a/src/xrt/state_trackers/prober/p_prober.c
+++ b/src/xrt/state_trackers/prober/p_prober.c
@@ -990,6 +990,7 @@ p_create_system(struct xrt_prober *xp,
struct prober *p = (struct prober *)xp;
struct xrt_builder *select = NULL;
+ struct xrt_builder *steamvr_builder = NULL;
enum u_config_json_active_config active;
xrt_result_t xret = XRT_SUCCESS;
struct u_pp_sink_stack_only sink; // Not inited, very large.
@@ -1026,6 +1027,15 @@ p_create_system(struct xrt_prober *xp,
u_pp(dg, "\n\tNo builder selected in config (or wasn't compiled in)");
}
+ // Find out SteamVR
+ for (size_t i = 0; i < p->builder_count; i++) {
+ struct xrt_builder *xb = p->builders[i];
+
+ if (strcmp(xb->identifier, "steamvr") == 0) {
+ steamvr_builder = xb;
+ break;
+ }
+ }
/*
* Estimate.
@@ -1093,6 +1103,22 @@ p_create_system(struct xrt_prober *xp,
if (xret == XRT_SUCCESS) {
print_system_devices(dg, *out_xsysd);
}
+ if (steamvr_builder != NULL) {
+ xret = xrt_builder_open_system( //
+ steamvr_builder, //
+ p->json.root, //
+ xp, //
+ broadcast, //
+ out_xsysd, //
+ out_xso); //
+
+ if (xret == XRT_SUCCESS) {
+ print_system_devices(dg, *out_xsysd);
+ } else {
+ u_pp(dg, "\n\tFailed to init SteamVR %s: %s", steamvr_builder->identifier, steamvr_builder->name);
+ print_system_devices(dg, *out_xsysd);
+ }
+ }
} else {
u_pp(dg, "\n\tNo builder can be used to create a head device");
xret = XRT_ERROR_DEVICE_CREATION_FAILED;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment