d/remote,steamvr_lh,survive_driver: Add stage_supported implementation

This commit is contained in:
Christoph Haag 2024-01-16 03:10:20 +01:00
parent 05db9e9b99
commit a0f3fa2c4f
3 changed files with 28 additions and 7 deletions

View file

@ -64,12 +64,15 @@ r_hmd_get_tracked_pose(struct xrt_device *xdev,
{ {
struct r_hmd *rh = r_hmd(xdev); struct r_hmd *rh = r_hmd(xdev);
if (name != XRT_INPUT_GENERIC_HEAD_POSE) { switch (name) {
U_LOG_E("Unknown input name"); case XRT_INPUT_GENERIC_HEAD_POSE: copy_head_center_to_relation(rh, out_relation); break;
return; case XRT_INPUT_GENERIC_STAGE_SPACE_POSE:
// STAGE is implicitly defined as the space poses are returned in, therefore STAGE origin is (0, 0, 0).
*out_relation = (struct xrt_space_relation)XRT_SPACE_RELATION_ZERO;
out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_ALL;
break;
default: U_LOG_E("Unknown input name"); break;
} }
copy_head_center_to_relation(rh, out_relation);
} }
static void static void
@ -151,6 +154,7 @@ r_hmd_create(struct r_hub *r)
rh->base.orientation_tracking_supported = true; rh->base.orientation_tracking_supported = true;
rh->base.position_tracking_supported = true; rh->base.position_tracking_supported = true;
rh->base.hand_tracking_supported = false; rh->base.hand_tracking_supported = false;
rh->base.stage_supported = true;
rh->base.name = XRT_DEVICE_GENERIC_HMD; rh->base.name = XRT_DEVICE_GENERIC_HMD;
rh->base.device_type = XRT_DEVICE_TYPE_HMD; rh->base.device_type = XRT_DEVICE_TYPE_HMD;
rh->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE; rh->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;

View file

@ -184,6 +184,7 @@ HmdDevice::HmdDevice(const DeviceBuilder &builder) : Device(builder)
this->name = XRT_DEVICE_GENERIC_HMD; this->name = XRT_DEVICE_GENERIC_HMD;
this->device_type = XRT_DEVICE_TYPE_HMD; this->device_type = XRT_DEVICE_TYPE_HMD;
this->container_handle = 0; this->container_handle = 0;
this->stage_supported = true;
#define SETUP_MEMBER_FUNC(name) this->xrt_device::name = &device_bouncer<HmdDevice, &HmdDevice::name> #define SETUP_MEMBER_FUNC(name) this->xrt_device::name = &device_bouncer<HmdDevice, &HmdDevice::name>
SETUP_MEMBER_FUNC(get_view_poses); SETUP_MEMBER_FUNC(get_view_poses);
@ -433,7 +434,15 @@ Device::get_pose(uint64_t at_timestamp_ns, xrt_space_relation *out_relation)
void void
HmdDevice::get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation) HmdDevice::get_tracked_pose(xrt_input_name name, uint64_t at_timestamp_ns, xrt_space_relation *out_relation)
{ {
Device::get_pose(at_timestamp_ns, out_relation); switch (name) {
case XRT_INPUT_GENERIC_HEAD_POSE: Device::get_pose(at_timestamp_ns, out_relation); break;
case XRT_INPUT_GENERIC_STAGE_SPACE_POSE:
// STAGE is implicitly defined as the space poses are returned in, therefore STAGE origin is (0, 0, 0).
*out_relation = XRT_SPACE_RELATION_ZERO;
out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_ALL;
break;
default: U_LOG_W("steamvr_lh hmd: Requested pose for unknown name %u", name); break;
}
} }
void void

View file

@ -316,7 +316,7 @@ verify_device_name(struct survive_device *survive, enum xrt_input_name name)
{ {
switch (survive->device_type) { switch (survive->device_type) {
case DEVICE_TYPE_HMD: return name == XRT_INPUT_GENERIC_HEAD_POSE; case DEVICE_TYPE_HMD: return name == XRT_INPUT_GENERIC_HEAD_POSE || name == XRT_INPUT_GENERIC_STAGE_SPACE_POSE;
case DEVICE_TYPE_CONTROLLER: case DEVICE_TYPE_CONTROLLER:
return name == XRT_INPUT_INDEX_AIM_POSE || name == XRT_INPUT_INDEX_GRIP_POSE || return name == XRT_INPUT_INDEX_AIM_POSE || name == XRT_INPUT_INDEX_GRIP_POSE ||
name == XRT_INPUT_VIVE_AIM_POSE || name == XRT_INPUT_VIVE_GRIP_POSE || name == XRT_INPUT_VIVE_AIM_POSE || name == XRT_INPUT_VIVE_GRIP_POSE ||
@ -337,6 +337,13 @@ survive_device_get_tracked_pose(struct xrt_device *xdev,
return; return;
} }
if (name == XRT_INPUT_GENERIC_STAGE_SPACE_POSE) {
// STAGE is implicitly defined as the space poses are returned in, therefore STAGE origin is (0, 0, 0).
*out_relation = (struct xrt_space_relation)XRT_SPACE_RELATION_ZERO;
out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_ALL;
return;
}
if (!survive->survive_obj) { if (!survive->survive_obj) {
// U_LOG_D("Obj not set for %p", (void*)survive); // U_LOG_D("Obj not set for %p", (void*)survive);
return; return;
@ -970,6 +977,7 @@ _create_hmd_device(struct survive_system *sys, const struct SurviveSimpleObject
survive->base.orientation_tracking_supported = true; survive->base.orientation_tracking_supported = true;
survive->base.position_tracking_supported = true; survive->base.position_tracking_supported = true;
survive->base.device_type = XRT_DEVICE_TYPE_HMD; survive->base.device_type = XRT_DEVICE_TYPE_HMD;
survive->base.stage_supported = true;
survive->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE; survive->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;