The open source OpenXR runtime
0
fork

Configure Feed

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

xrt: Adds support for XR_EXT_hand_tracking_data_source

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

+207 -7
+2
CMakeLists.txt
··· 361 361 option(XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC "Enable XR_HTC_facial_tracking" OFF) 362 362 option(XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL "Enable XR_MNDX_force_feedback_curl" ON) 363 363 option(XRT_FEATURE_OPENXR_HAND_TRACKING_EXT "Enable XR_EXT_hand_tracking" ON) 364 + option_with_deps(XRT_FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT DEPENDS XRT_FEATURE_OPENXR_HAND_TRACKING_EXT) 364 365 option(XRT_FEATURE_OPENXR_HAPTIC_PCM "Enable XR_FB_haptic_pcm" OFF) 365 366 option(XRT_FEATURE_OPENXR_HEADLESS "Enable XR_MND_headless" ON) 366 367 option(XRT_FEATURE_OPENXR_OVERLAY "Enable XR_EXTX_overlay" ON) ··· 605 606 message(STATUS "# FEATURE_OPENXR_FACIAL_TRACKING_HTC: ${XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC}") 606 607 message(STATUS "# FEATURE_OPENXR_FORCE_FEEDBACK_CURL: ${XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL}") 607 608 message(STATUS "# FEATURE_OPENXR_HAND_TRACKING_EXT: ${XRT_FEATURE_OPENXR_HAND_TRACKING_EXT}") 609 + message(STATUS "# FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT: ${XRT_FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT}") 608 610 message(STATUS "# FEATURE_OPENXR_HAPTIC_PCM: ${XRT_FEATURE_OPENXR_HAPTIC_PCM}") 609 611 message(STATUS "# FEATURE_OPENXR_HEADLESS: ${XRT_FEATURE_OPENXR_HEADLESS}") 610 612 message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE}")
+1
scripts/generate_oxr_ext_support.py
··· 66 66 ['XR_EXT_eye_gaze_interaction', 'XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE'], 67 67 ['XR_EXT_hand_interaction', 'XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND'], 68 68 ['XR_EXT_hand_tracking', 'XRT_FEATURE_OPENXR_HAND_TRACKING_EXT'], 69 + ['XR_EXT_hand_tracking_data_source', 'XRT_FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT'], 69 70 ['XR_EXT_hp_mixed_reality_controller', 'XRT_FEATURE_OPENXR_INTERACTION_WINMR'], 70 71 ['XR_EXT_local_floor', 'XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR'], 71 72 ['XR_EXT_palm_pose', 'XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE'],
+5
scripts/mapping.imp
··· 29 29 { symbol: ["XRT_MODULE_MONADO_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 30 30 { symbol: ["XRT_MODULE_MONADO_CLI", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 31 31 { symbol: ["XRT_FEATURE_CLIENT_DEBUG_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 32 + { symbol: ["XRT_FEATURE_CLIENT_WITHOUT_SERVICE", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 32 33 { symbol: ["XRT_FEATURE_COLOR_LOG", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 33 34 { symbol: ["XRT_FEATURE_DEBUG_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 35 + { symbol: ["XRT_FEATURE_IPC_CLIENT", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 34 36 { symbol: ["XRT_FEATURE_OPENXR", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 35 37 { symbol: ["XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 36 38 { symbol: ["XRT_FEATURE_OPENXR_BODY_TRACKING_FB", "public", "\"xrt/xrt_config_build.h\"", "public"] }, ··· 41 43 { symbol: ["XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 42 44 { symbol: ["XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 43 45 { symbol: ["XRT_FEATURE_OPENXR_HAND_TRACKING_EXT", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 46 + { symbol: ["XRT_FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 47 + { symbol: ["XRT_FEATURE_OPENXR_HAPTIC_PCM", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 44 48 { symbol: ["XRT_FEATURE_OPENXR_HEADLESS", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 45 49 { symbol: ["XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 46 50 { symbol: ["XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE", "public", "\"xrt/xrt_config_build.h\"", "public"] }, ··· 68 72 { symbol: ["XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 69 73 { symbol: ["XRT_FEATURE_OPENXR_LAYER_FB_PASSTHROUGH", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 70 74 { symbol: ["XRT_FEATURE_OPENXR_OVERLAY", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 75 + { symbol: ["XRT_FEATURE_OPENXR_PLANE_DETECTION", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 71 76 { symbol: ["XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 72 77 { symbol: ["XRT_FEATURE_OPENXR_SPACE_UNBOUNDED", "public", "\"xrt/xrt_config_build.h\"", "public"] }, 73 78 { symbol: ["XRT_FEATURE_OPENXR_VISIBILITY_MASK", "public", "\"xrt/xrt_config_build.h\"", "public"] },
+1
src/xrt/compositor/multi/comp_multi_system.c
··· 414 414 const struct xrt_begin_session_info begin_session_info = { 415 415 .view_type = XRT_VIEW_TYPE_STEREO, 416 416 .ext_hand_tracking_enabled = false, 417 + .ext_hand_tracking_data_source_enabled = false, 417 418 .ext_eye_gaze_interaction_enabled = false, 418 419 .ext_hand_interaction_enabled = false, 419 420 .htc_facial_tracking_enabled = false,
+1
src/xrt/include/xrt/xrt_compositor.h
··· 965 965 { 966 966 enum xrt_view_type view_type; 967 967 bool ext_hand_tracking_enabled; 968 + bool ext_hand_tracking_data_source_enabled; 968 969 bool ext_eye_gaze_interaction_enabled; 969 970 bool ext_hand_interaction_enabled; 970 971 bool htc_facial_tracking_enabled;
+1
src/xrt/include/xrt/xrt_config_build.h.cmake_in
··· 40 40 #cmakedefine XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC 41 41 #cmakedefine XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL 42 42 #cmakedefine XRT_FEATURE_OPENXR_HAND_TRACKING_EXT 43 + #cmakedefine XRT_FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT 43 44 #cmakedefine XRT_FEATURE_OPENXR_HAPTIC_PCM 44 45 #cmakedefine XRT_FEATURE_OPENXR_HEADLESS 45 46 #cmakedefine XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE
+1
src/xrt/include/xrt/xrt_instance.h
··· 72 72 { 73 73 char application_name[XRT_MAX_APPLICATION_NAME_SIZE]; 74 74 bool ext_hand_tracking_enabled; 75 + bool ext_hand_tracking_data_source_enabled; 75 76 bool ext_eye_gaze_interaction_enabled; 76 77 bool ext_hand_interaction_enabled; 77 78 bool htc_facial_tracking_enabled;
+2
src/xrt/ipc/server/ipc_server_handler.c
··· 318 318 PNT("extensions:"); 319 319 320 320 EXT(ext_hand_tracking_enabled); 321 + EXT(ext_hand_tracking_data_source_enabled); 321 322 EXT(ext_eye_gaze_interaction_enabled); 322 323 EXT(ext_hand_interaction_enabled); 323 324 EXT(htc_facial_tracking_enabled); ··· 413 414 const struct xrt_begin_session_info begin_session_info = { 414 415 .view_type = XRT_VIEW_TYPE_STEREO, 415 416 .ext_hand_tracking_enabled = ics->client_state.info.ext_hand_tracking_enabled, 417 + .ext_hand_tracking_data_source_enabled = ics->client_state.info.ext_hand_tracking_data_source_enabled, 416 418 .ext_eye_gaze_interaction_enabled = ics->client_state.info.ext_eye_gaze_interaction_enabled, 417 419 .ext_hand_interaction_enabled = ics->client_state.info.ext_hand_interaction_enabled, 418 420 .htc_facial_tracking_enabled = ics->client_state.info.htc_facial_tracking_enabled,
+69
src/xrt/state_trackers/oxr/oxr_api_session.c
··· 463 463 OXR_SET_HT_DATA_SOURCE(conforming, CONFORMING) 464 464 #undef OXR_SET_HT_DATA_SOURCE 465 465 466 + hand_tracker->requested_sources_count = ARRAY_SIZE(hand_tracker->requested_sources); 467 + hand_tracker->requested_sources[0] = &hand_tracker->unobstructed; 468 + hand_tracker->requested_sources[1] = &hand_tracker->conforming; 469 + 470 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 471 + const XrHandTrackingDataSourceInfoEXT *data_source_info = NULL; 472 + if (sess->sys->inst->extensions.EXT_hand_tracking_data_source) { 473 + data_source_info = OXR_GET_INPUT_FROM_CHAIN(createInfo, XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT, 474 + XrHandTrackingDataSourceInfoEXT); 475 + } 476 + 477 + if (data_source_info != NULL) { 478 + 479 + const uint32_t source_count = 480 + MIN(data_source_info->requestedDataSourceCount, hand_tracker->requested_sources_count); 481 + hand_tracker->requested_sources_count = 0; 482 + memset(hand_tracker->requested_sources, 0, sizeof(hand_tracker->requested_sources)); 483 + 484 + for (uint32_t i = 0; i < source_count; ++i) { 485 + struct oxr_hand_tracking_data_source *requested_source = NULL; 486 + switch (data_source_info->requestedDataSources[i]) { 487 + case XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT: 488 + requested_source = &hand_tracker->unobstructed; 489 + break; 490 + case XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT: 491 + requested_source = &hand_tracker->conforming; 492 + break; 493 + default: break; 494 + } 495 + if (requested_source && requested_source->xdev != NULL) { 496 + hand_tracker->requested_sources[hand_tracker->requested_sources_count++] = 497 + requested_source; 498 + } 499 + } 500 + 501 + if (hand_tracker->requested_sources_count == 0) { 502 + return oxr_error( 503 + log, XR_ERROR_FEATURE_UNSUPPORTED, 504 + "None of the requested data sources are supported by the current hand-tracking device(s)."); 505 + } 506 + 507 + const size_t sort_size = hand_tracker->requested_sources_count; 508 + const size_t elem_size = sizeof(const struct oxr_hand_tracking_data_source *); 509 + qsort(hand_tracker->requested_sources, sort_size, elem_size, oxr_hand_tracking_data_source_cmp); 510 + } 511 + #endif 512 + 466 513 *out_hand_tracker = hand_tracker; 467 514 468 515 return XR_SUCCESS; ··· 489 536 if (createInfo->hand != XR_HAND_LEFT_EXT && createInfo->hand != XR_HAND_RIGHT_EXT) { 490 537 return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, "Invalid hand value %d\n", createInfo->hand); 491 538 } 539 + 540 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 541 + const XrHandTrackingDataSourceInfoEXT *data_source_info = NULL; 542 + if (sess->sys->inst->extensions.EXT_hand_tracking_data_source) { 543 + data_source_info = OXR_GET_INPUT_FROM_CHAIN(createInfo, XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT, 544 + XrHandTrackingDataSourceInfoEXT); 545 + } 546 + OXR_VERIFY_HAND_TRACKING_DATA_SOURCE_OR_NULL(&log, data_source_info); 547 + #endif 492 548 493 549 ret = oxr_hand_tracker_create(&log, sess, createInfo, &hand_tracker); 494 550 if (ret != XR_SUCCESS) { ··· 560 616 } 561 617 } 562 618 } 619 + 620 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 621 + const XrHandTrackingDataSourceStateEXT *data_source_state = NULL; 622 + if (hand_tracker->sess->sys->inst->extensions.EXT_hand_tracking_data_source) { 623 + data_source_state = OXR_GET_OUTPUT_FROM_CHAIN(locations, XR_TYPE_HAND_TRACKING_DATA_SOURCE_STATE_EXT, 624 + XrHandTrackingDataSourceStateEXT); 625 + } 626 + 627 + if (data_source_state != NULL) { 628 + OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, data_source_state, XR_TYPE_HAND_TRACKING_DATA_SOURCE_STATE_EXT); 629 + OXR_VERIFY_ARG_NOT_ZERO(&log, hand_tracker->requested_sources_count); 630 + } 631 + #endif 563 632 564 633 return oxr_session_hand_joints(&log, hand_tracker, locateInfo, locations); 565 634 }
+15
src/xrt/state_trackers/oxr/oxr_api_verify.h
··· 315 315 } \ 316 316 } while (false) 317 317 318 + #define OXR_VERIFY_HAND_TRACKING_DATA_SOURCE_OR_NULL(log, data_source_info) \ 319 + do { \ 320 + if (data_source_info != NULL) { \ 321 + XrResult verify_ret = oxr_verify_XrHandTrackingDataSourceInfoEXT(log, data_source_info); \ 322 + if (verify_ret != XR_SUCCESS) { \ 323 + return verify_ret; \ 324 + } \ 325 + } \ 326 + } while (false) 327 + 318 328 319 329 /* 320 330 * ··· 436 446 const XrInteractionProfileDpadBindingEXT *, 437 447 const char *error_prefix); 438 448 #endif // XR_EXT_dpad_binding 449 + 450 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 451 + XrResult 452 + oxr_verify_XrHandTrackingDataSourceInfoEXT(struct oxr_logger *, const XrHandTrackingDataSourceInfoEXT *); 453 + #endif // XR_EXT_hand_tracking_data_source 439 454 440 455 /*! 441 456 * @}
+24
src/xrt/state_trackers/oxr/oxr_conversions.h
··· 265 265 default: assert(false); return 0; 266 266 } 267 267 } 268 + 269 + static inline enum xrt_input_name 270 + xr_hand_tracking_data_source_to_xrt(XrHandTrackingDataSourceEXT data_source, enum XrHandEXT hand) 271 + { 272 + switch (data_source) { 273 + case XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT: 274 + return (hand == XR_HAND_LEFT_EXT) ? XRT_INPUT_HT_UNOBSTRUCTED_LEFT : XRT_INPUT_HT_UNOBSTRUCTED_RIGHT; 275 + case XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT: 276 + return (hand == XR_HAND_LEFT_EXT) ? XRT_INPUT_HT_CONFORMING_LEFT : XRT_INPUT_HT_CONFORMING_RIGHT; 277 + default: assert(false); return (enum xrt_input_name)(-1); 278 + } 279 + } 280 + 281 + static inline XrHandTrackingDataSourceEXT 282 + xrt_hand_tracking_data_source_to_xr(enum xrt_input_name ht_input_name) 283 + { 284 + switch (ht_input_name) { 285 + case XRT_INPUT_HT_UNOBSTRUCTED_LEFT: 286 + case XRT_INPUT_HT_UNOBSTRUCTED_RIGHT: return XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT; 287 + case XRT_INPUT_HT_CONFORMING_LEFT: 288 + case XRT_INPUT_HT_CONFORMING_RIGHT: return XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT; 289 + default: assert(false); return XR_HAND_TRACKING_DATA_SOURCE_MAX_ENUM_EXT; 290 + } 291 + }
+13
src/xrt/state_trackers/oxr/oxr_extension_support.h
··· 373 373 374 374 375 375 /* 376 + * XR_EXT_hand_tracking_data_source 377 + */ 378 + #if defined(XR_EXT_hand_tracking_data_source) && defined(XRT_FEATURE_OPENXR_HAND_TRACKING_DATA_SOURCE_EXT) 379 + #define OXR_HAVE_EXT_hand_tracking_data_source 380 + #define OXR_EXTENSION_SUPPORT_EXT_hand_tracking_data_source(_) \ 381 + _(EXT_hand_tracking_data_source, EXT_HAND_TRACKING_DATA_SOURCE) 382 + #else 383 + #define OXR_EXTENSION_SUPPORT_EXT_hand_tracking_data_source(_) 384 + #endif 385 + 386 + 387 + /* 376 388 * XR_EXT_hp_mixed_reality_controller 377 389 */ 378 390 #if defined(XR_EXT_hp_mixed_reality_controller) && defined(XRT_FEATURE_OPENXR_INTERACTION_WINMR) ··· 870 882 OXR_EXTENSION_SUPPORT_EXT_eye_gaze_interaction(_) \ 871 883 OXR_EXTENSION_SUPPORT_EXT_hand_interaction(_) \ 872 884 OXR_EXTENSION_SUPPORT_EXT_hand_tracking(_) \ 885 + OXR_EXTENSION_SUPPORT_EXT_hand_tracking_data_source(_) \ 873 886 OXR_EXTENSION_SUPPORT_EXT_hp_mixed_reality_controller(_) \ 874 887 OXR_EXTENSION_SUPPORT_EXT_local_floor(_) \ 875 888 OXR_EXTENSION_SUPPORT_EXT_palm_pose(_) \
+3
src/xrt/state_trackers/oxr/oxr_instance.c
··· 304 304 #ifdef OXR_HAVE_EXT_hand_tracking 305 305 .ext_hand_tracking_enabled = extensions->EXT_hand_tracking, 306 306 #endif 307 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 308 + .ext_hand_tracking_data_source_enabled = extensions->EXT_hand_tracking_data_source, 309 + #endif 307 310 #ifdef OXR_HAVE_EXT_eye_gaze_interaction 308 311 .ext_eye_gaze_interaction_enabled = extensions->EXT_eye_gaze_interaction, 309 312 #endif
+24
src/xrt/state_trackers/oxr/oxr_objects.h
··· 2654 2654 enum xrt_input_name input_name; 2655 2655 }; 2656 2656 2657 + static inline int 2658 + oxr_hand_tracking_data_source_cmp(const void *p1, const void *p2) 2659 + { 2660 + const struct oxr_hand_tracking_data_source *lhs = (const struct oxr_hand_tracking_data_source *)p1; 2661 + const struct oxr_hand_tracking_data_source *rhs = (const struct oxr_hand_tracking_data_source *)p2; 2662 + assert(lhs && rhs); 2663 + if (lhs->input_name < rhs->input_name) 2664 + return -1; 2665 + if (lhs->input_name > rhs->input_name) 2666 + return 1; 2667 + return 0; 2668 + } 2669 + 2657 2670 /*! 2658 2671 * A hand tracker. 2659 2672 * ··· 2673 2686 2674 2687 struct oxr_hand_tracking_data_source unobstructed; 2675 2688 struct oxr_hand_tracking_data_source conforming; 2689 + 2690 + /*! 2691 + * An ordered list of requested data-source from above options (@ref 2692 + * oxr_hand_tracker::[unobstructed|conforming]), ordered by 2693 + * @ref oxr_hand_tracker::input_name (see @ref oxr_hand_tracking_data_source_cmp) 2694 + * 2695 + * if OXR_HAVE_EXT_hand_tracking_data_source is not defined the list 2696 + * will contain refs to all the above options. 2697 + */ 2698 + const struct oxr_hand_tracking_data_source *requested_sources[2]; 2699 + uint32_t requested_sources_count; 2676 2700 2677 2701 XrHandEXT hand; 2678 2702 XrHandJointSetEXT hand_joint_set;
+23 -7
src/xrt/state_trackers/oxr/oxr_session.c
··· 236 236 #ifdef OXR_HAVE_EXT_hand_tracking 237 237 .ext_hand_tracking_enabled = extensions->EXT_hand_tracking, 238 238 #endif 239 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 240 + .ext_hand_tracking_data_source_enabled = extensions->EXT_hand_tracking_data_source, 241 + #endif 239 242 #ifdef OXR_HAVE_EXT_eye_gaze_interaction 240 243 .ext_eye_gaze_interaction_enabled = extensions->EXT_eye_gaze_interaction, 241 244 #endif ··· 1320 1323 //! Convert at_time to monotonic and give to device. 1321 1324 const int64_t at_timestamp_ns = time_state_ts_to_monotonic_ns(inst->timekeeping, at_time); 1322 1325 1323 - const struct oxr_hand_tracking_data_source *data_sources[2] = { 1324 - &hand_tracker->unobstructed, 1325 - &hand_tracker->conforming, 1326 - }; 1327 - if (debug_get_bool_option_hand_tracking_prioritize_conforming()) { 1326 + const struct oxr_hand_tracking_data_source *data_sources[ARRAY_SIZE(hand_tracker->requested_sources)] = {0}; 1327 + memcpy(data_sources, hand_tracker->requested_sources, sizeof(data_sources)); 1328 + 1329 + if (debug_get_bool_option_hand_tracking_prioritize_conforming() && // 1330 + hand_tracker->requested_sources_count > 1) { 1328 1331 const struct oxr_hand_tracking_data_source *tmp = data_sources[0]; 1329 1332 data_sources[0] = data_sources[1]; 1330 1333 data_sources[1] = tmp; ··· 1332 1335 1333 1336 struct xrt_hand_joint_set value; 1334 1337 const struct oxr_hand_tracking_data_source *data_source = NULL; 1335 - for (uint32_t i = 0; i < ARRAY_SIZE(data_sources); ++i) { 1338 + for (uint32_t i = 0; i < hand_tracker->requested_sources_count; ++i) { 1336 1339 data_source = data_sources[i]; 1337 - if (data_source->xdev == NULL) 1340 + if (data_source == NULL || data_source->xdev == NULL) 1338 1341 continue; 1339 1342 int64_t ignored; 1340 1343 value = (struct xrt_hand_joint_set){0}; ··· 1350 1353 locations->isActive = false; 1351 1354 return XR_SUCCESS; 1352 1355 } 1356 + 1357 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 1358 + XrHandTrackingDataSourceStateEXT *data_source_state = NULL; 1359 + if (hand_tracker->sess->sys->inst->extensions.EXT_hand_tracking_data_source) { 1360 + data_source_state = OXR_GET_OUTPUT_FROM_CHAIN(locations, XR_TYPE_HAND_TRACKING_DATA_SOURCE_STATE_EXT, 1361 + XrHandTrackingDataSourceStateEXT); 1362 + } 1363 + 1364 + if (data_source_state != NULL) { 1365 + data_source_state->isActive = XR_TRUE; 1366 + data_source_state->dataSource = xrt_hand_tracking_data_source_to_xr(data_source->input_name); 1367 + } 1368 + #endif 1353 1369 1354 1370 // The hand pose is returned in the xdev's space. 1355 1371 struct xrt_space_relation T_xdev_hand = value.hand_pose;
+22
src/xrt/state_trackers/oxr/oxr_verify.c
··· 747 747 return XR_SUCCESS; 748 748 } 749 749 #endif // XR_EXT_dpad_binding 750 + 751 + #ifdef OXR_HAVE_EXT_hand_tracking_data_source 752 + XrResult 753 + oxr_verify_XrHandTrackingDataSourceInfoEXT(struct oxr_logger *log, 754 + const XrHandTrackingDataSourceInfoEXT *data_source_info) 755 + { 756 + OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(log, data_source_info, XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT); 757 + OXR_VERIFY_ARG_NOT_ZERO(log, data_source_info->requestedDataSourceCount); 758 + OXR_VERIFY_ARG_NOT_NULL(log, data_source_info->requestedDataSources); 759 + // verify unique / no duplicate entries in requestedDataSources 760 + for (uint32_t i = 0; i < data_source_info->requestedDataSourceCount; ++i) { 761 + for (uint32_t j = i + 1; j < data_source_info->requestedDataSourceCount; ++j) { 762 + if (data_source_info->requestedDataSources[j] != data_source_info->requestedDataSources[i]) { 763 + continue; 764 + } 765 + return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, 766 + "Duplicate value in requestedDataSources at indices: %u, %u\n", i, j); 767 + } 768 + } 769 + return XR_SUCCESS; 770 + } 771 + #endif // XR_EXT_hand_tracking_data_source