Files
WiVRn/patches/monado/0008-st-oxr-bind-to-dynamic-role-s-profile.patch
T

92 lines
4.6 KiB
Diff

From a7fbfaf2407a805efa31b3e1a7f0565b46a9004e Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Wed, 19 Feb 2025 10:13:36 +0100
Subject: [PATCH 08/11] st/oxr: bind to dynamic role's profile
---
src/xrt/state_trackers/oxr/oxr_binding.c | 8 +++++---
src/xrt/state_trackers/oxr/oxr_input.c | 19 +++++++++++++------
src/xrt/state_trackers/oxr/oxr_objects.h | 2 +-
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/xrt/state_trackers/oxr/oxr_binding.c b/src/xrt/state_trackers/oxr/oxr_binding.c
index ce4c0cca1..9645a507a 100644
--- a/src/xrt/state_trackers/oxr/oxr_binding.c
+++ b/src/xrt/state_trackers/oxr/oxr_binding.c
@@ -453,7 +453,7 @@ get_identifier_str_in_profile(struct oxr_logger *log,
return str;
}
-void
+bool
oxr_get_profile_for_device_name(struct oxr_logger *log,
struct oxr_session *sess,
enum xrt_device_name name,
@@ -465,10 +465,12 @@ oxr_get_profile_for_device_name(struct oxr_logger *log,
*/
for (uint32_t i = 0; i < ARRAY_SIZE(profile_templates); i++) {
if (name == profile_templates[i].name) {
- interaction_profile_find_in_session(log, sess, profile_templates[i].path_cache, out_p);
- return;
+ if (interaction_profile_find_in_session(log, sess, profile_templates[i].path_cache, out_p)) {
+ return true;
+ }
}
}
+ return false;
}
diff --git a/src/xrt/state_trackers/oxr/oxr_input.c b/src/xrt/state_trackers/oxr/oxr_input.c
index 3d8da24a9..7bd3e7678 100644
--- a/src/xrt/state_trackers/oxr/oxr_input.c
+++ b/src/xrt/state_trackers/oxr/oxr_input.c
@@ -800,18 +800,25 @@ oxr_find_profiles_from_roles(struct oxr_logger *log,
{
#define FIND_PROFILE(X) \
{ \
- struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, X); \
- if (xdev != NULL) { \
- oxr_find_profile_for_device(log, sess, xdev, &out_profiles->X); \
- } else { \
- oxr_get_profile_for_device_name(log, sess, GET_PROFILE_NAME_BY_ROLE(sess->sys, X), \
- &out_profiles->X); \
+ bool profile_found = false; \
+ const enum xrt_device_name role_profile_name = GET_PROFILE_NAME_BY_ROLE(sess->sys, X); \
+ if (role_profile_name != XRT_DEVICE_INVALID) { \
+ profile_found = \
+ oxr_get_profile_for_device_name(log, sess, role_profile_name, &out_profiles->X); \
+ } \
+ \
+ if (!profile_found) { \
+ struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, X); \
+ if (xdev != NULL) { \
+ oxr_find_profile_for_device(log, sess, xdev, &out_profiles->X); \
+ } \
} \
}
OXR_FOR_EACH_VALID_SUBACTION_PATH(FIND_PROFILE)
#undef FIND_PROFILE
}
+
/*!
* @public @memberof oxr_action_attachment
*/
diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h
index c4d2bcbe3..f9f1ac5a8 100644
--- a/src/xrt/state_trackers/oxr/oxr_objects.h
+++ b/src/xrt/state_trackers/oxr/oxr_objects.h
@@ -651,7 +651,7 @@ oxr_find_profile_for_device(struct oxr_logger *log,
struct xrt_device *xdev,
struct oxr_interaction_profile **out_p);
-void
+bool
oxr_get_profile_for_device_name(struct oxr_logger *log,
struct oxr_session *sess,
enum xrt_device_name name,
--
2.50.1