mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 13:18:32 +00:00
xrt: Split hand tracking input name into left/right
oxr_hand_tracker now stores which xdev and input name it tracks.
This commit is contained in:
parent
fba01f656a
commit
f7a8e8810b
|
@ -127,7 +127,8 @@ r_device_get_hand_tracking(struct xrt_device *xdev,
|
||||||
struct r_hub *r = rd->r;
|
struct r_hub *r = rd->r;
|
||||||
|
|
||||||
|
|
||||||
if (name != XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET) {
|
if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT &&
|
||||||
|
name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) {
|
||||||
U_LOG_E("Unknown input name for hand tracker");
|
U_LOG_E("Unknown input name for hand tracker");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +187,7 @@ r_device_create(struct r_hub *r, bool is_left)
|
||||||
{
|
{
|
||||||
// Allocate.
|
// Allocate.
|
||||||
const enum u_device_alloc_flags flags = 0;
|
const enum u_device_alloc_flags flags = 0;
|
||||||
const uint32_t num_inputs = 4;
|
const uint32_t num_inputs = 5;
|
||||||
const uint32_t num_outputs = 1;
|
const uint32_t num_outputs = 1;
|
||||||
struct r_device *rd = U_DEVICE_ALLOCATE( //
|
struct r_device *rd = U_DEVICE_ALLOCATE( //
|
||||||
struct r_device, flags, num_inputs, num_outputs);
|
struct r_device, flags, num_inputs, num_outputs);
|
||||||
|
@ -215,6 +216,11 @@ r_device_create(struct r_hub *r, bool is_left)
|
||||||
rd->base.inputs[1].name = XRT_INPUT_SIMPLE_MENU_CLICK;
|
rd->base.inputs[1].name = XRT_INPUT_SIMPLE_MENU_CLICK;
|
||||||
rd->base.inputs[2].name = XRT_INPUT_SIMPLE_GRIP_POSE;
|
rd->base.inputs[2].name = XRT_INPUT_SIMPLE_GRIP_POSE;
|
||||||
rd->base.inputs[3].name = XRT_INPUT_SIMPLE_AIM_POSE;
|
rd->base.inputs[3].name = XRT_INPUT_SIMPLE_AIM_POSE;
|
||||||
|
if (is_left) {
|
||||||
|
rd->base.inputs[4].name = XRT_INPUT_GENERIC_HAND_TRACKING_LEFT;
|
||||||
|
} else {
|
||||||
|
rd->base.inputs[4].name = XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT;
|
||||||
|
}
|
||||||
rd->base.outputs[0].name = XRT_OUTPUT_NAME_SIMPLE_VIBRATION;
|
rd->base.outputs[0].name = XRT_OUTPUT_NAME_SIMPLE_VIBRATION;
|
||||||
|
|
||||||
if (is_left) {
|
if (is_left) {
|
||||||
|
|
|
@ -75,10 +75,8 @@ struct survive_system;
|
||||||
|
|
||||||
enum input_index
|
enum input_index
|
||||||
{
|
{
|
||||||
GENERIC_HEAD_POSE = 0,
|
|
||||||
|
|
||||||
// common inputs
|
// common inputs
|
||||||
VIVE_CONTROLLER_AIM_POSE,
|
VIVE_CONTROLLER_AIM_POSE = 0,
|
||||||
VIVE_CONTROLLER_GRIP_POSE,
|
VIVE_CONTROLLER_GRIP_POSE,
|
||||||
VIVE_CONTROLLER_SYSTEM_CLICK,
|
VIVE_CONTROLLER_SYSTEM_CLICK,
|
||||||
VIVE_CONTROLLER_TRIGGER_CLICK,
|
VIVE_CONTROLLER_TRIGGER_CLICK,
|
||||||
|
@ -105,8 +103,7 @@ enum input_index
|
||||||
VIVE_CONTROLLER_TRIGGER_TOUCH,
|
VIVE_CONTROLLER_TRIGGER_TOUCH,
|
||||||
VIVE_CONTROLLER_TRACKPAD_FORCE,
|
VIVE_CONTROLLER_TRACKPAD_FORCE,
|
||||||
|
|
||||||
VIVE_CONTROLLER_FINGERTRACKING,
|
VIVE_CONTROLLER_HAND_TRACKING,
|
||||||
VIVE_CONTROLLER_HAND_BASE,
|
|
||||||
|
|
||||||
VIVE_CONTROLLER_MAX_INDEX,
|
VIVE_CONTROLLER_MAX_INDEX,
|
||||||
};
|
};
|
||||||
|
@ -458,7 +455,8 @@ survive_controller_get_hand_tracking(struct xrt_device *xdev,
|
||||||
{
|
{
|
||||||
struct survive_device *survive = (struct survive_device *)xdev;
|
struct survive_device *survive = (struct survive_device *)xdev;
|
||||||
|
|
||||||
if (name != XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET) {
|
if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT &&
|
||||||
|
name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) {
|
||||||
SURVIVE_ERROR(survive, "unknown input name for hand tracker");
|
SURVIVE_ERROR(survive, "unknown input name for hand tracker");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1297,6 +1295,7 @@ _create_controller_device(struct survive_system *sys,
|
||||||
{
|
{
|
||||||
|
|
||||||
enum u_device_alloc_flags flags = 0;
|
enum u_device_alloc_flags flags = 0;
|
||||||
|
|
||||||
int inputs = VIVE_CONTROLLER_MAX_INDEX;
|
int inputs = VIVE_CONTROLLER_MAX_INDEX;
|
||||||
int outputs = 1;
|
int outputs = 1;
|
||||||
struct survive_device *survive =
|
struct survive_device *survive =
|
||||||
|
@ -1375,10 +1374,14 @@ _create_controller_device(struct survive_system *sys,
|
||||||
if (variant == VIVE_VARIANT_VALVE_INDEX_LEFT_CONTROLLER) {
|
if (variant == VIVE_VARIANT_VALVE_INDEX_LEFT_CONTROLLER) {
|
||||||
survive->base.device_type =
|
survive->base.device_type =
|
||||||
XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER;
|
XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER;
|
||||||
|
survive->base.inputs[VIVE_CONTROLLER_HAND_TRACKING]
|
||||||
|
.name = XRT_INPUT_GENERIC_HAND_TRACKING_LEFT;
|
||||||
} else if (variant ==
|
} else if (variant ==
|
||||||
VIVE_VARIANT_VALVE_INDEX_RIGHT_CONTROLLER) {
|
VIVE_VARIANT_VALVE_INDEX_RIGHT_CONTROLLER) {
|
||||||
survive->base.device_type =
|
survive->base.device_type =
|
||||||
XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER;
|
XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER;
|
||||||
|
survive->base.inputs[VIVE_CONTROLLER_HAND_TRACKING]
|
||||||
|
.name = XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT;
|
||||||
} else {
|
} else {
|
||||||
survive->base.device_type =
|
survive->base.device_type =
|
||||||
XRT_DEVICE_TYPE_ANY_HAND_CONTROLLER;
|
XRT_DEVICE_TYPE_ANY_HAND_CONTROLLER;
|
||||||
|
|
|
@ -79,6 +79,8 @@ enum vive_controller_input_index
|
||||||
VIVE_CONTROLLER_INDEX_TRIGGER_TOUCH,
|
VIVE_CONTROLLER_INDEX_TRIGGER_TOUCH,
|
||||||
VIVE_CONTROLLER_INDEX_TRACKPAD_FORCE,
|
VIVE_CONTROLLER_INDEX_TRACKPAD_FORCE,
|
||||||
|
|
||||||
|
VIVE_CONTROLLER_HAND_TRACKING,
|
||||||
|
|
||||||
VIVE_CONTROLLER_MAX_INDEX,
|
VIVE_CONTROLLER_MAX_INDEX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -328,7 +330,8 @@ vive_controller_get_hand_tracking(struct xrt_device *xdev,
|
||||||
{
|
{
|
||||||
struct vive_controller_device *d = vive_controller_device(xdev);
|
struct vive_controller_device *d = vive_controller_device(xdev);
|
||||||
|
|
||||||
if (name != XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET) {
|
if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT &&
|
||||||
|
name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) {
|
||||||
VIVE_ERROR(d, "unknown input name for hand tracker");
|
VIVE_ERROR(d, "unknown input name for hand tracker");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1270,9 +1273,13 @@ vive_controller_create(struct os_hid_device *controller_hid,
|
||||||
if (d->variant == CONTROLLER_INDEX_LEFT) {
|
if (d->variant == CONTROLLER_INDEX_LEFT) {
|
||||||
d->base.device_type =
|
d->base.device_type =
|
||||||
XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER;
|
XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER;
|
||||||
|
d->base.inputs[VIVE_CONTROLLER_HAND_TRACKING].name =
|
||||||
|
XRT_INPUT_GENERIC_HAND_TRACKING_LEFT;
|
||||||
} else if (d->variant == CONTROLLER_INDEX_RIGHT) {
|
} else if (d->variant == CONTROLLER_INDEX_RIGHT) {
|
||||||
d->base.device_type =
|
d->base.device_type =
|
||||||
XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER;
|
XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER;
|
||||||
|
d->base.inputs[VIVE_CONTROLLER_HAND_TRACKING].name =
|
||||||
|
XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT;
|
||||||
}
|
}
|
||||||
} else if (d->variant == CONTROLLER_TRACKER_GEN1) {
|
} else if (d->variant == CONTROLLER_TRACKER_GEN1) {
|
||||||
d->base.name = XRT_DEVICE_VIVE_TRACKER_GEN1;
|
d->base.name = XRT_DEVICE_VIVE_TRACKER_GEN1;
|
||||||
|
|
|
@ -496,7 +496,8 @@ enum xrt_input_name
|
||||||
// clang-format off
|
// clang-format off
|
||||||
XRT_INPUT_GENERIC_HEAD_POSE = XRT_INPUT_NAME(0x0000, POSE),
|
XRT_INPUT_GENERIC_HEAD_POSE = XRT_INPUT_NAME(0x0000, POSE),
|
||||||
XRT_INPUT_GENERIC_HEAD_DETECT = XRT_INPUT_NAME(0x0001, BOOLEAN),
|
XRT_INPUT_GENERIC_HEAD_DETECT = XRT_INPUT_NAME(0x0001, BOOLEAN),
|
||||||
XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET = XRT_INPUT_NAME(0x0002, HAND_TRACKING),
|
XRT_INPUT_GENERIC_HAND_TRACKING_LEFT = XRT_INPUT_NAME(0x0002, HAND_TRACKING),
|
||||||
|
XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT = XRT_INPUT_NAME(0x0003, HAND_TRACKING),
|
||||||
|
|
||||||
XRT_INPUT_SIMPLE_SELECT_CLICK = XRT_INPUT_NAME(0x0010, BOOLEAN),
|
XRT_INPUT_SIMPLE_SELECT_CLICK = XRT_INPUT_NAME(0x0010, BOOLEAN),
|
||||||
XRT_INPUT_SIMPLE_MENU_CLICK = XRT_INPUT_NAME(0x0011, BOOLEAN),
|
XRT_INPUT_SIMPLE_MENU_CLICK = XRT_INPUT_NAME(0x0011, BOOLEAN),
|
||||||
|
|
|
@ -293,6 +293,34 @@ oxr_hand_tracker_create(struct oxr_logger *log,
|
||||||
hand_tracker->hand = createInfo->hand;
|
hand_tracker->hand = createInfo->hand;
|
||||||
hand_tracker->hand_joint_set = createInfo->handJointSet;
|
hand_tracker->hand_joint_set = createInfo->handJointSet;
|
||||||
|
|
||||||
|
//! @todo: Implement choice when more than one device has hand tracking
|
||||||
|
for (uint32_t i = 0; i < sess->sys->num_xdevs; i++) {
|
||||||
|
struct xrt_device *xdev = sess->sys->xdevs[i];
|
||||||
|
|
||||||
|
if (!xdev->hand_tracking_supported) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t j = 0; j < xdev->num_inputs; j++) {
|
||||||
|
struct xrt_input *input = &xdev->inputs[j];
|
||||||
|
|
||||||
|
if ((input->name ==
|
||||||
|
XRT_INPUT_GENERIC_HAND_TRACKING_LEFT &&
|
||||||
|
createInfo->hand == XR_HAND_LEFT_EXT) ||
|
||||||
|
(input->name ==
|
||||||
|
XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT &&
|
||||||
|
createInfo->hand == XR_HAND_RIGHT_EXT)) {
|
||||||
|
hand_tracker->xdev = xdev;
|
||||||
|
hand_tracker->input_name = input->name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hand_tracker->xdev != NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*out_hand_tracker = hand_tracker;
|
*out_hand_tracker = hand_tracker;
|
||||||
|
|
||||||
return XR_SUCCESS;
|
return XR_SUCCESS;
|
||||||
|
|
|
@ -1964,6 +1964,12 @@ struct oxr_hand_tracker
|
||||||
//! Owner of this hand tracker.
|
//! Owner of this hand tracker.
|
||||||
struct oxr_session *sess;
|
struct oxr_session *sess;
|
||||||
|
|
||||||
|
//! xrt_device backing this hand tracker
|
||||||
|
struct xrt_device *xdev;
|
||||||
|
|
||||||
|
//! the input name associated with this hand tracker
|
||||||
|
enum xrt_input_name input_name;
|
||||||
|
|
||||||
XrHandEXT hand;
|
XrHandEXT hand;
|
||||||
XrHandJointSetEXT hand_joint_set;
|
XrHandJointSetEXT hand_joint_set;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2334,22 +2334,8 @@ oxr_session_hand_joints(struct oxr_logger *log,
|
||||||
locations, XR_TYPE_HAND_JOINT_VELOCITIES_EXT,
|
locations, XR_TYPE_HAND_JOINT_VELOCITIES_EXT,
|
||||||
XrHandJointVelocitiesEXT);
|
XrHandJointVelocitiesEXT);
|
||||||
|
|
||||||
struct xrt_device *xdev = NULL;
|
struct xrt_device *xdev = hand_tracker->xdev;
|
||||||
if (hand_tracker->hand == XR_HAND_LEFT_EXT) {
|
enum xrt_input_name name = hand_tracker->input_name;
|
||||||
xdev = GET_XDEV_BY_ROLE(sess->sys, left);
|
|
||||||
} else if (hand_tracker->hand == XR_HAND_RIGHT_EXT) {
|
|
||||||
xdev = GET_XDEV_BY_ROLE(sess->sys, right);
|
|
||||||
} else {
|
|
||||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
|
||||||
"invalid hand value");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xdev == NULL) {
|
|
||||||
//! @todo spec is not clear on whether we could have failed
|
|
||||||
//! creating a hand tracker if we don't have a device for it
|
|
||||||
locations->isActive = false;
|
|
||||||
return XR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct xrt_pose *tracking_origin_offset =
|
struct xrt_pose *tracking_origin_offset =
|
||||||
&xdev->tracking_origin->offset;
|
&xdev->tracking_origin->offset;
|
||||||
|
@ -2357,14 +2343,6 @@ oxr_session_hand_joints(struct oxr_logger *log,
|
||||||
XrTime at_time = locateInfo->time;
|
XrTime at_time = locateInfo->time;
|
||||||
struct xrt_hand_joint_set value;
|
struct xrt_hand_joint_set value;
|
||||||
|
|
||||||
enum xrt_input_name name;
|
|
||||||
if (hand_tracker->hand_joint_set == XR_HAND_JOINT_SET_DEFAULT_EXT) {
|
|
||||||
name = XRT_INPUT_GENERIC_HAND_TRACKING_DEFAULT_SET;
|
|
||||||
} else {
|
|
||||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
|
||||||
"invalid hand joint set");
|
|
||||||
}
|
|
||||||
|
|
||||||
oxr_xdev_get_hand_tracking_at(log, sess->sys->inst, xdev, name, at_time,
|
oxr_xdev_get_hand_tracking_at(log, sess->sys->inst, xdev, name, at_time,
|
||||||
&value);
|
&value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue