The open source OpenXR runtime

st/oxr: Check all profiles for matching device name

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

authored by

Rafal Karp and committed by
Marge Bot
619af45a 85aeeeec

+23 -2
+23 -2
src/xrt/state_trackers/oxr/oxr_binding.c
··· 1 1 // Copyright 2018-2020,2023 Collabora, Ltd. 2 + // Copyright 2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 462 463 if (name == XRT_DEVICE_INVALID) { 463 464 return false; 464 465 } 466 + 465 467 /* 466 468 * Map xrt_device_name to an interaction profile XrPath. 467 - * Set *out_p to an oxr_interaction_profile if bindings for that interaction profile XrPath have been suggested. 469 + * 470 + * There might be multiple OpenXR interaction profiles that maps to a 471 + * a single @ref xrt_device_name, so we can't just grab the first one 472 + * that we find and assume that wasn't bound then there isn't an OpenXR 473 + * interaction profile bound for that device name. So we will need to 474 + * keep looping until we find an OpenXR interaction profile, or we run 475 + * out of interaction profiles that the app has suggested. 476 + * 477 + * For XRT_DEVICE_HAND_INTERACTION both the OpenXR hand-interaction 478 + * profiles maps to it, but the app might only provide binding for one. 479 + * 480 + * Set *out_p to an oxr_interaction_profile if bindings for that 481 + * interaction profile XrPath have been suggested. 468 482 */ 469 483 for (uint32_t i = 0; i < ARRAY_SIZE(profile_templates); i++) { 470 484 if (name == profile_templates[i].name) { 471 - if (interaction_profile_find_in_session(log, sess, profile_templates[i].path_cache, out_p)) { 485 + interaction_profile_find_in_session(log, sess, profile_templates[i].path_cache, out_p); 486 + 487 + /* 488 + * Keep looping even if the current matching OpenXR 489 + * interaction profile wasn't suggested by the app. 490 + * See comment above. 491 + */ 492 + if (*out_p != NULL) { 472 493 return true; 473 494 } 474 495 }