diff --git a/src/xrt/auxiliary/util/u_device.c b/src/xrt/auxiliary/util/u_device.c index 5cde069e7..b1e426db7 100644 --- a/src/xrt/auxiliary/util/u_device.c +++ b/src/xrt/auxiliary/util/u_device.c @@ -352,10 +352,19 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs, } } +static void +apply_offset(struct xrt_vec3 *position, struct xrt_vec3 *offset) +{ + position->x += offset->x; + position->y += offset->y; + position->z += offset->z; +} + void u_device_setup_tracking_origins(struct xrt_device *head, struct xrt_device *left, - struct xrt_device *right) + struct xrt_device *right, + struct xrt_vec3 *global_tracking_origin_offset) { if (head->tracking_origin->type == XRT_TRACKING_TYPE_NONE) { // "nominal height" 1.6m @@ -377,4 +386,25 @@ u_device_setup_tracking_origins(struct xrt_device *head, right->tracking_origin->offset.position.y = 1.3f; right->tracking_origin->offset.position.z = -0.5f; } + + struct xrt_tracking_origin *head_origin = + head ? head->tracking_origin : NULL; + struct xrt_tracking_origin *left_origin = + left ? left->tracking_origin : NULL; + struct xrt_tracking_origin *right_origin = + right ? right->tracking_origin : NULL; + + if (head_origin) { + apply_offset(&head_origin->offset.position, + global_tracking_origin_offset); + } + if (left_origin && left_origin != head_origin) { + apply_offset(&left->tracking_origin->offset.position, + global_tracking_origin_offset); + } + if (right_origin && right_origin != head_origin && + right_origin != left_origin) { + apply_offset(&right->tracking_origin->offset.position, + global_tracking_origin_offset); + } } diff --git a/src/xrt/auxiliary/util/u_device.h b/src/xrt/auxiliary/util/u_device.h index dc5ebcc10..27f3b1022 100644 --- a/src/xrt/auxiliary/util/u_device.h +++ b/src/xrt/auxiliary/util/u_device.h @@ -120,7 +120,8 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs, void u_device_setup_tracking_origins(struct xrt_device *head, struct xrt_device *left, - struct xrt_device *right); + struct xrt_device *right, + struct xrt_vec3 *global_tracking_origin_offset); #ifdef __cplusplus } diff --git a/src/xrt/state_trackers/oxr/oxr_instance.c b/src/xrt/state_trackers/oxr/oxr_instance.c index 7f9db7a54..69560a45e 100644 --- a/src/xrt/state_trackers/oxr/oxr_instance.c +++ b/src/xrt/state_trackers/oxr/oxr_instance.c @@ -48,6 +48,16 @@ DEBUG_GET_ONCE_FLOAT_OPTION(lfov_right, "OXR_OVERRIDE_LFOV_RIGHT", 0.0f) DEBUG_GET_ONCE_FLOAT_OPTION(lfov_up, "OXR_OVERRIDE_LFOV_UP", 0.0f) DEBUG_GET_ONCE_FLOAT_OPTION(lfov_down, "OXR_OVERRIDE_LFOV_DOWN", 0.0f) +DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_x, + "OXR_TRACKING_ORIGIN_OFFSET_X", + 0.0f) +DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_y, + "OXR_TRACKING_ORIGIN_OFFSET_Y", + 0.0f) +DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_z, + "OXR_TRACKING_ORIGIN_OFFSET_Z", + 0.0f) + /* ---- HACK ---- */ extern int oxr_sdl2_hack_create(void **out_hack); @@ -255,8 +265,14 @@ oxr_instance_create(struct oxr_logger *log, return ret; } + struct xrt_vec3 global_tracking_origin_offset = { + debug_get_float_option_tracking_origin_offset_x(), + debug_get_float_option_tracking_origin_offset_y(), + debug_get_float_option_tracking_origin_offset_z()}; + u_device_setup_tracking_origins(dev, GET_XDEV_BY_ROLE(sys, left), - GET_XDEV_BY_ROLE(sys, right)); + GET_XDEV_BY_ROLE(sys, right), + &global_tracking_origin_offset); const float left_override = debug_get_float_option_lfov_left(); if (left_override != 0.0f) { diff --git a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp index 4e6adf0e8..5ff9dcf9e 100644 --- a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp +++ b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp @@ -1294,7 +1294,9 @@ CServerDriver_Monado::Init(vr::IVRDriverContext *pDriverContext) ovrd_log("Left Controller: %s\n", left_xdev ? left_xdev->str : ""); ovrd_log("Right Controller: %s\n", right_xdev ? right_xdev->str : ""); - u_device_setup_tracking_origins(m_xhmd, left_xdev, right_xdev); + // use steamvr room setup instead + struct xrt_vec3 offset = {0, 0, 0}; + u_device_setup_tracking_origins(m_xhmd, left_xdev, right_xdev, &offset); if (left != XRT_DEVICE_ROLE_UNASSIGNED) { m_left = new CDeviceDriver_Monado_Controller(m_xinst, left_xdev, @@ -1347,7 +1349,6 @@ CServerDriver_Monado::HandleHapticEvent(vr::VREvent_t *event) float amp = event->data.hapticVibration.fAmplitude; float duration = event->data.hapticVibration.fDurationSeconds; - ovrd_log("Haptic vibration %fs %fHz %famp\n", duration, freq, amp); struct xrt_device *xdev = NULL;