From e7f82c297ab8583052ba3a4f970805c832c23eb4 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Thu, 8 Apr 2021 20:32:55 +0200 Subject: [PATCH] st/oxr: Fix running when only one hand suports hand tracking --- src/xrt/state_trackers/oxr/oxr_api_session.c | 5 +++-- src/xrt/state_trackers/oxr/oxr_session.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/xrt/state_trackers/oxr/oxr_api_session.c b/src/xrt/state_trackers/oxr/oxr_api_session.c index c76254c4c..a07b6995d 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_session.c +++ b/src/xrt/state_trackers/oxr/oxr_api_session.c @@ -298,11 +298,12 @@ oxr_hand_tracker_create(struct oxr_logger *log, hand_tracker->hand = createInfo->hand; hand_tracker->hand_joint_set = createInfo->handJointSet; - //! @todo: Implement choice when more than one device has hand tracking + //! @todo: move hand tracking device selection to oxr_system. + // if no xdev with hand tracking is found, create hand tracker without xdev. for (uint32_t i = 0; i < sess->sys->num_xdevs; i++) { struct xrt_device *xdev = sess->sys->xdevs[i]; - if (!xdev->hand_tracking_supported) { + if (!xdev || !xdev->hand_tracking_supported) { continue; } diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index 06c5ef83a..b1ae59065 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -2155,6 +2155,11 @@ oxr_session_hand_joints(struct oxr_logger *log, XrHandJointVelocitiesEXT *vel = OXR_GET_OUTPUT_FROM_CHAIN(locations, XR_TYPE_HAND_JOINT_VELOCITIES_EXT, XrHandJointVelocitiesEXT); + if (hand_tracker->xdev == NULL) { + locations->isActive = false; + return XR_SUCCESS; + } + struct xrt_device *xdev = hand_tracker->xdev; enum xrt_input_name name = hand_tracker->input_name;