The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrt: adapt driver to new get_hand_tracking api change

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2357>

+87 -80
+4 -3
src/xrt/auxiliary/util/u_device.c
··· 504 504 505 505 #define E(FN) U_LOG_E("Function " #FN " is not implemented for '%s'", xdev->str) 506 506 507 - void 507 + xrt_result_t 508 508 u_device_ni_get_hand_tracking(struct xrt_device *xdev, 509 509 enum xrt_input_name name, 510 - uint64_t desired_timestamp_ns, 510 + int64_t desired_timestamp_ns, 511 511 struct xrt_hand_joint_set *out_value, 512 - uint64_t *out_timestamp_ns) 512 + int64_t *out_timestamp_ns) 513 513 { 514 514 E(get_hand_tracking); 515 + return XRT_ERROR_NOT_IMPLEMENTED; 515 516 } 516 517 517 518 void
+3 -3
src/xrt/auxiliary/util/u_device.h
··· 213 213 * 214 214 * @ingroup aux_util 215 215 */ 216 - void 216 + xrt_result_t 217 217 u_device_ni_get_hand_tracking(struct xrt_device *xdev, 218 218 enum xrt_input_name name, 219 - uint64_t desired_timestamp_ns, 219 + int64_t desired_timestamp_ns, 220 220 struct xrt_hand_joint_set *out_value, 221 - uint64_t *out_timestamp_ns); 221 + int64_t *out_timestamp_ns); 222 222 223 223 /*! 224 224 * Not implemented function for @ref xrt_device::set_output.
+4 -3
src/xrt/drivers/ht/ht_driver.c
··· 145 145 * xrt_device function implementations 146 146 */ 147 147 148 - static void 148 + static xrt_result_t 149 149 ht_device_get_hand_tracking(struct xrt_device *xdev, 150 150 enum xrt_input_name name, 151 151 int64_t at_timestamp_ns, ··· 155 155 struct ht_device *htd = ht_device(xdev); 156 156 157 157 if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT && name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 158 - HT_ERROR(htd, "unknown input name for hand tracker"); 159 - return; 158 + U_LOG_XDEV_UNSUPPORTED_INPUT(&htd->base, htd->log_level, name); 159 + return XRT_ERROR_INPUT_UNSUPPORTED; 160 160 } 161 161 162 162 htd->async->get_hand(htd->async, name, at_timestamp_ns, out_value, out_timestamp_ns); 163 + return XRT_SUCCESS; 163 164 } 164 165 165 166 static void
+20 -15
src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp
··· 131 131 } 132 132 } 133 133 134 - static void 134 + static xrt_result_t 135 135 cemu_device_get_hand_tracking(struct xrt_device *xdev, 136 136 enum xrt_input_name name, 137 137 int64_t requested_timestamp_ns, ··· 144 144 struct cemu_system *system = dev->sys; 145 145 146 146 if (name != dev->ht_input_name) { 147 - // I should be using xrt_input_name_string here - couldn't figure out how to link to it. 148 - CEMU_ERROR(dev, "unexpected input name %d - expected %d", name, dev->ht_input_name); 149 - return; 147 + U_LOG_XDEV_UNSUPPORTED_INPUT(&dev->base, system->log_level, name); 148 + return XRT_ERROR_INPUT_UNSUPPORTED; 150 149 } 151 150 152 - xrt_device_get_hand_tracking(system->in_hand, dev->ht_input_name, requested_timestamp_ns, out_value, 153 - out_timestamp_ns); 151 + return xrt_device_get_hand_tracking(system->in_hand, dev->ht_input_name, requested_timestamp_ns, out_value, 152 + out_timestamp_ns); 154 153 } 155 154 156 155 static xrt_vec3 ··· 224 223 xrt_pose *out_head, 225 224 xrt_hand_joint_set *out_secondary) 226 225 { 226 + struct cemu_system *sys = dev->sys; 227 227 struct xrt_space_relation head_rel; 228 228 xrt_result_t xret = 229 - xrt_device_get_tracked_pose(dev->sys->in_head, XRT_INPUT_GENERIC_HEAD_POSE, head_timestamp_ns, &head_rel); 229 + xrt_device_get_tracked_pose(sys->in_head, XRT_INPUT_GENERIC_HEAD_POSE, head_timestamp_ns, &head_rel); 230 230 if (xret != XRT_SUCCESS) { 231 231 return xret; 232 232 } ··· 240 240 } 241 241 242 242 int64_t noop; 243 - xrt_device_get_hand_tracking(dev->sys->in_hand, dev->sys->out_hand[other]->ht_input_name, hand_timestamp_ns, 244 - out_secondary, &noop); 245 - 246 - return xret; 243 + return xrt_device_get_hand_tracking(sys->in_hand, sys->out_hand[other]->ht_input_name, hand_timestamp_ns, 244 + out_secondary, &noop); 247 245 } 248 246 249 247 // Mostly stolen from ··· 345 343 static int64_t hand_timestamp_ns; 346 344 347 345 struct xrt_hand_joint_set joint_set; 348 - sys->in_hand->get_hand_tracking(sys->in_hand, dev->ht_input_name, at_timestamp_ns, &joint_set, 349 - &hand_timestamp_ns); 346 + xrt_result_t xret = xrt_device_get_hand_tracking(sys->in_hand, dev->ht_input_name, at_timestamp_ns, &joint_set, 347 + &hand_timestamp_ns); 348 + if (xret != XRT_SUCCESS) { 349 + return xret; 350 + } 350 351 351 352 if (joint_set.is_active == false) { 352 353 out_relation->relation_flags = XRT_SPACE_RELATION_BITMASK_NONE; 353 354 return XRT_SUCCESS; 354 355 } 355 356 356 - xrt_result_t xret = XRT_SUCCESS; 357 + xret = XRT_SUCCESS; 357 358 switch (name) { 358 359 case XRT_INPUT_SIMPLE_GRIP_POSE: { 359 360 xret = do_grip_pose(&joint_set, out_relation, sys->grip_offset_from_palm, dev->hand_index); ··· 400 401 struct xrt_hand_joint_set joint_set; 401 402 int64_t noop; 402 403 403 - xrt_device_get_hand_tracking(dev->sys->in_hand, dev->ht_input_name, os_monotonic_get_ns(), &joint_set, &noop); 404 + xrt_result_t xret = xrt_device_get_hand_tracking(dev->sys->in_hand, dev->ht_input_name, os_monotonic_get_ns(), 405 + &joint_set, &noop); 406 + if (xret != XRT_SUCCESS) { 407 + return xret; 408 + } 404 409 405 410 if (!joint_set.is_active) { 406 411 xdev->inputs[CEMU_INDEX_SELECT].value.boolean = false;
+14 -5
src/xrt/drivers/multi_wrapper/multi.c
··· 139 139 free(d); 140 140 } 141 141 142 - static void 142 + static xrt_result_t 143 143 get_hand_tracking(struct xrt_device *xdev, 144 144 enum xrt_input_name name, 145 145 int64_t at_timestamp_ns, ··· 148 148 { 149 149 struct multi_device *d = (struct multi_device *)xdev; 150 150 struct xrt_device *target = d->tracking_override.target; 151 - xrt_device_get_hand_tracking(target, name, at_timestamp_ns, out_value, out_timestamp_ns); 151 + xrt_result_t ret = xrt_device_get_hand_tracking(target, name, at_timestamp_ns, out_value, out_timestamp_ns); 152 + if (ret != XRT_SUCCESS) { 153 + return ret; 154 + } 155 + 152 156 if (!out_value->is_active) { 153 - return; 157 + return XRT_SUCCESS; 154 158 } 155 159 156 160 struct xrt_device *tracker = d->tracking_override.tracker; 157 161 struct xrt_space_relation tracker_relation; 158 - xrt_device_get_tracked_pose(tracker, d->tracking_override.input_name, *out_timestamp_ns, &tracker_relation); 159 - 162 + ret = 163 + xrt_device_get_tracked_pose(tracker, d->tracking_override.input_name, *out_timestamp_ns, &tracker_relation); 164 + if (ret != XRT_SUCCESS) { 165 + return ret; 166 + } 160 167 161 168 switch (d->override_type) { 162 169 case XRT_TRACKING_OVERRIDE_DIRECT: direct_override(d, &tracker_relation, &out_value->hand_pose); break; ··· 178 185 &in_target_space, &out_value->hand_pose); 179 186 } break; 180 187 } 188 + 189 + return XRT_SUCCESS; 181 190 } 182 191 183 192 static void
+3 -1
src/xrt/drivers/opengloves/opengloves_device.c
··· 86 86 return (struct opengloves_device *)xdev; 87 87 } 88 88 89 - static void 89 + static xrt_result_t 90 90 opengloves_device_get_hand_tracking(struct xrt_device *xdev, 91 91 enum xrt_input_name name, 92 92 int64_t requested_timestamp_ns, ··· 134 134 135 135 *out_timestamp_ns = requested_timestamp_ns; 136 136 out_joint_set->is_active = true; 137 + 138 + return XRT_SUCCESS; 137 139 } 138 140 139 141 static xrt_result_t
+9 -5
src/xrt/drivers/remote/r_device.c
··· 137 137 return XRT_SUCCESS; 138 138 } 139 139 140 - static void 140 + static xrt_result_t 141 141 r_device_get_hand_tracking(struct xrt_device *xdev, 142 142 enum xrt_input_name name, 143 143 int64_t requested_timestamp_ns, ··· 147 147 struct r_device *rd = r_device(xdev); 148 148 struct r_hub *r = rd->r; 149 149 150 - 151 150 if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT && name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 152 - U_LOG_E("Unknown input name for hand tracker: 0x%0x", name); 153 - return; 151 + U_LOG_XDEV_UNSUPPORTED_INPUT(&rd->base, u_log_get_global_level(), name); 152 + return XRT_ERROR_INPUT_UNSUPPORTED; 154 153 } 155 154 156 155 struct r_remote_controller_data *latest = rd->is_left ? &r->latest.left : &r->latest.right; ··· 165 164 166 165 // Get the pose of the hand. 167 166 struct xrt_space_relation relation; 168 - xrt_device_get_tracked_pose(xdev, XRT_INPUT_INDEX_GRIP_POSE, requested_timestamp_ns, &relation); 167 + xrt_result_t ret = 168 + xrt_device_get_tracked_pose(xdev, XRT_INPUT_INDEX_GRIP_POSE, requested_timestamp_ns, &relation); 169 + if (ret != XRT_SUCCESS) { 170 + return ret; 171 + } 169 172 170 173 // Simulate the hand. 171 174 enum xrt_hand hand = rd->is_left ? XRT_HAND_LEFT : XRT_HAND_RIGHT; ··· 175 178 176 179 // This is a lie 177 180 *out_timestamp_ns = requested_timestamp_ns; 181 + return XRT_SUCCESS; 178 182 } 179 183 180 184 static void
+1 -12
src/xrt/drivers/remote/r_hmd.c
··· 75 75 } 76 76 77 77 static void 78 - r_hmd_get_hand_tracking(struct xrt_device *xdev, 79 - enum xrt_input_name name, 80 - int64_t at_timestamp_ns, 81 - struct xrt_hand_joint_set *out_value, 82 - int64_t *out_timestamp_ns) 83 - { 84 - struct r_hmd *rh = r_hmd(xdev); 85 - (void)rh; 86 - } 87 - 88 - static void 89 78 r_hmd_get_view_poses(struct xrt_device *xdev, 90 79 const struct xrt_vec3 *default_eye_relation, 91 80 int64_t at_timestamp_ns, ··· 145 134 // Setup the basics. 146 135 rh->base.update_inputs = u_device_noop_update_inputs; 147 136 rh->base.get_tracked_pose = r_hmd_get_tracked_pose; 148 - rh->base.get_hand_tracking = r_hmd_get_hand_tracking; 137 + rh->base.get_hand_tracking = u_device_ni_get_hand_tracking; 149 138 rh->base.get_view_poses = r_hmd_get_view_poses; 150 139 rh->base.set_output = r_hmd_set_output; 151 140 rh->base.destroy = r_hmd_destroy;
+1 -11
src/xrt/drivers/simulated/simulated_controller.c
··· 167 167 } 168 168 169 169 static void 170 - simulated_device_get_hand_tracking(struct xrt_device *xdev, 171 - enum xrt_input_name name, 172 - int64_t requested_timestamp_ns, 173 - struct xrt_hand_joint_set *out_value, 174 - int64_t *out_timestamp_ns) 175 - { 176 - assert(false); 177 - } 178 - 179 - static void 180 170 simulated_device_get_view_poses(struct xrt_device *xdev, 181 171 const struct xrt_vec3 *default_eye_relation, 182 172 int64_t at_timestamp_ns, ··· 378 368 struct simulated_device *sd = U_DEVICE_ALLOCATE(struct simulated_device, flags, input_count, output_count); 379 369 sd->base.update_inputs = simulated_device_update_inputs; 380 370 sd->base.get_tracked_pose = simulated_device_get_tracked_pose; 381 - sd->base.get_hand_tracking = simulated_device_get_hand_tracking; 371 + sd->base.get_hand_tracking = u_device_ni_get_hand_tracking; 382 372 sd->base.get_view_poses = simulated_device_get_view_poses; 383 373 sd->base.set_output = simulated_device_set_output; 384 374 sd->base.destroy = simulated_device_destroy;
+5 -3
src/xrt/drivers/steamvr_lh/device.cpp
··· 185 185 this->device_type = XRT_DEVICE_TYPE_UNKNOWN; 186 186 this->container_handle = handle; 187 187 188 + this->xrt_device::get_hand_tracking = 189 + &device_bouncer<ControllerDevice, &ControllerDevice::get_hand_tracking, xrt_result_t>; 188 190 #define SETUP_MEMBER_FUNC(name) this->xrt_device::name = &device_bouncer<ControllerDevice, &ControllerDevice::name> 189 191 SETUP_MEMBER_FUNC(set_output); 190 - SETUP_MEMBER_FUNC(get_hand_tracking); 191 192 #undef SETUP_MEMBER_FUNC 192 193 } 193 194 ··· 397 398 return finger->second; 398 399 } 399 400 400 - void 401 + xrt_result_t 401 402 ControllerDevice::get_hand_tracking(enum xrt_input_name name, 402 403 int64_t desired_timestamp_ns, 403 404 struct xrt_hand_joint_set *out_value, 404 405 int64_t *out_timestamp_ns) 405 406 { 406 407 if (!has_index_hand_tracking) 407 - return; 408 + return XRT_ERROR_NOT_IMPLEMENTED; 408 409 update_hand_tracking(desired_timestamp_ns, out_value); 409 410 out_value->is_active = true; 410 411 hand_tracking_timestamp = desired_timestamp_ns; 411 412 *out_timestamp_ns = hand_tracking_timestamp; 413 + return XRT_SUCCESS; 412 414 } 413 415 414 416 void
+1 -1
src/xrt/drivers/steamvr_lh/device.hpp
··· 174 174 IndexFingerInput * 175 175 get_finger_from_name(std::string_view name); 176 176 177 - void 177 + xrt_result_t 178 178 get_hand_tracking(enum xrt_input_name name, 179 179 int64_t desired_timestamp_ns, 180 180 struct xrt_hand_joint_set *out_value,
+5 -3
src/xrt/drivers/survive/survive_driver.c
··· 456 456 [SURVIVE_BUTTON_TRIGGER] = {.click = VIVE_CONTROLLER_TRIGGER_CLICK, .touch = VIVE_CONTROLLER_TRIGGER_TOUCH}, 457 457 }; 458 458 459 - static void 459 + static xrt_result_t 460 460 survive_controller_get_hand_tracking(struct xrt_device *xdev, 461 461 enum xrt_input_name name, 462 462 int64_t at_timestamp_ns, ··· 466 466 struct survive_device *survive = (struct survive_device *)xdev; 467 467 468 468 if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT && name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 469 - SURVIVE_ERROR(survive, "unknown input name for hand tracker"); 470 - return; 469 + U_LOG_XDEV_UNSUPPORTED_INPUT(&survive->base, survive->sys->log_level, name); 470 + return XRT_ERROR_INPUT_UNSUPPORTED; 471 471 } 472 472 473 473 ··· 519 519 // This is a lie - apparently libsurvive doesn't report controller tracked/untracked state, so just say that the 520 520 // hand is being tracked 521 521 out_value->is_active = true; 522 + 523 + return XRT_SUCCESS; 522 524 } 523 525 524 526 static void
+5 -3
src/xrt/drivers/ultraleap_v5/ulv5_driver.cpp
··· 87 87 return (struct ulv5_device *)xdev; 88 88 } 89 89 90 - static void 90 + static xrt_result_t 91 91 ulv5_device_get_hand_tracking(struct xrt_device *xdev, 92 92 enum xrt_input_name name, 93 93 int64_t at_timestamp_ns, ··· 97 97 struct ulv5_device *ulv5d = ulv5_device(xdev); 98 98 99 99 if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT && name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 100 - ULV5_ERROR(ulv5d, "unknown input name for hand tracker"); 101 - return; 100 + U_LOG_XDEV_UNSUPPORTED_INPUT(&ulv5d->base, ulv5d->log_level, name); 101 + return XRT_ERROR_INPUT_UNSUPPORTED; 102 102 } 103 103 104 104 bool hand_index = (name == XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT); // 0 if left, 1 if right. ··· 119 119 } 120 120 // still a lie... 121 121 *out_timestamp_ns = at_timestamp_ns; 122 + 123 + return XRT_SUCCESS; 122 124 } 123 125 124 126 // todo: cleanly shutdown the LEAP_CONNECTION
+4 -3
src/xrt/drivers/vive/vive_controller.c
··· 364 364 return XRT_SUCCESS; 365 365 } 366 366 367 - static void 367 + static xrt_result_t 368 368 vive_controller_get_hand_tracking(struct xrt_device *xdev, 369 369 enum xrt_input_name name, 370 370 int64_t requested_timestamp_ns, ··· 376 376 struct vive_controller_device *d = vive_controller_device(xdev); 377 377 378 378 if (name != XRT_INPUT_GENERIC_HAND_TRACKING_LEFT && name != XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 379 - VIVE_ERROR(d, "unknown input name for hand tracker"); 380 - return; 379 + U_LOG_XDEV_UNSUPPORTED_INPUT(&d->base, d->log_level, name); 380 + return XRT_ERROR_INPUT_UNSUPPORTED; 381 381 } 382 382 383 383 enum xrt_hand hand = d->config.variant == CONTROLLER_INDEX_LEFT ? XRT_HAND_LEFT : XRT_HAND_RIGHT; ··· 408 408 *out_timestamp_ns = requested_timestamp_ns; 409 409 410 410 out_value->is_active = true; 411 + return XRT_SUCCESS; 411 412 } 412 413 413 414 static xrt_result_t
+6 -7
src/xrt/include/xrt/xrt_device.h
··· 379 379 * 380 380 * @see xrt_input_name 381 381 */ 382 - void (*get_hand_tracking)(struct xrt_device *xdev, 383 - enum xrt_input_name name, 384 - int64_t desired_timestamp_ns, 385 - struct xrt_hand_joint_set *out_value, 386 - int64_t *out_timestamp_ns); 382 + xrt_result_t (*get_hand_tracking)(struct xrt_device *xdev, 383 + enum xrt_input_name name, 384 + int64_t desired_timestamp_ns, 385 + struct xrt_hand_joint_set *out_value, 386 + int64_t *out_timestamp_ns); 387 387 388 388 /*! 389 389 * @brief Get the requested blend shape properties & weights for a face tracker ··· 684 684 struct xrt_hand_joint_set *out_value, 685 685 int64_t *out_timestamp_ns) 686 686 { 687 - xdev->get_hand_tracking(xdev, name, desired_timestamp_ns, out_value, out_timestamp_ns); 688 - return XRT_SUCCESS; 687 + return xdev->get_hand_tracking(xdev, name, desired_timestamp_ns, out_value, out_timestamp_ns); 689 688 } 690 689 691 690 /*!
+2 -2
src/xrt/ipc/client/ipc_client_xdev.c
··· 59 59 IPC_CHK_ALWAYS_RET(icx->ipc_c, xret, "ipc_call_device_get_tracked_pose"); 60 60 } 61 61 62 - static void 62 + static xrt_result_t 63 63 ipc_client_xdev_get_hand_tracking(struct xrt_device *xdev, 64 64 enum xrt_input_name name, 65 65 int64_t at_timestamp_ns, ··· 75 75 at_timestamp_ns, // 76 76 out_value, // 77 77 out_timestamp_ns); // 78 - IPC_CHK_ONLY_PRINT(icx->ipc_c, xret, "ipc_call_device_get_hand_tracking"); 78 + IPC_CHK_ALWAYS_RET(icx->ipc_c, xret, "ipc_call_device_get_hand_tracking"); 79 79 } 80 80 81 81 static xrt_result_t