Properly handle switching interaction profiles on controller disconnection
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
From 6f7304dee78dcbf0b485177465d10b4878668ede Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Fri, 7 Nov 2025 20:41:16 -0600
|
||||
Subject: [PATCH] st/oxr: push XrEventDataInteractionProfileChanged when
|
||||
profile changes to NULL
|
||||
|
||||
---
|
||||
src/xrt/state_trackers/oxr/oxr_input.c | 15 +++++++++++----
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/state_trackers/oxr/oxr_input.c b/src/xrt/state_trackers/oxr/oxr_input.c
|
||||
index a319e044d..cd1cd4bd9 100644
|
||||
--- a/src/xrt/state_trackers/oxr/oxr_input.c
|
||||
+++ b/src/xrt/state_trackers/oxr/oxr_input.c
|
||||
@@ -1882,15 +1882,22 @@ oxr_session_update_action_bindings(struct oxr_logger *log, struct oxr_session *s
|
||||
}
|
||||
}
|
||||
|
||||
+ bool any_profile_changed = false;
|
||||
+
|
||||
#define POPULATE_PROFILE(X) \
|
||||
- sess->X = XR_NULL_PATH; \
|
||||
- if (profiles.X != NULL) { \
|
||||
- sess->X = profiles.X->path; \
|
||||
- oxr_event_push_XrEventDataInteractionProfileChanged(log, sess); \
|
||||
+ { \
|
||||
+ const XrPath new_path = profiles.X ? profiles.X->path : XR_NULL_PATH; \
|
||||
+ if (sess->X != new_path) { \
|
||||
+ sess->X = new_path; \
|
||||
+ any_profile_changed = true; \
|
||||
+ } \
|
||||
}
|
||||
OXR_FOR_EACH_VALID_SUBACTION_PATH(POPULATE_PROFILE)
|
||||
#undef POPULATE_PROFILE
|
||||
|
||||
+ if (any_profile_changed) {
|
||||
+ oxr_event_push_XrEventDataInteractionProfileChanged(log, sess);
|
||||
+ }
|
||||
return oxr_session_success_result(sess);
|
||||
}
|
||||
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -475,8 +475,8 @@ static xrt_device_name get_name(interaction_profile profile)
|
||||
}
|
||||
void wivrn_session::operator()(from_headset::trackings && tracking)
|
||||
{
|
||||
auto left = (roles.left == left_controller_index || roles.left == left_hand_interaction_index) ? get_name(tracking.interaction_profiles[0]) : XRT_DEVICE_INVALID;
|
||||
auto right = (roles.right == right_controller_index || roles.right == right_hand_interaction_index) ? get_name(tracking.interaction_profiles[1]) : XRT_DEVICE_INVALID;
|
||||
auto left = (roles.left == -1 || roles.left == left_controller_index || roles.left == left_hand_interaction_index) ? get_name(tracking.interaction_profiles[0]) : XRT_DEVICE_INVALID;
|
||||
auto right = (roles.right == -1 || roles.right == right_controller_index || roles.right == right_hand_interaction_index) ? get_name(tracking.interaction_profiles[1]) : XRT_DEVICE_INVALID;
|
||||
if (left != roles.left_profile or right != roles.right_profile)
|
||||
{
|
||||
U_LOG_I("Updating interaction profiles: from \n"
|
||||
@@ -489,37 +489,45 @@ void wivrn_session::operator()(from_headset::trackings && tracking)
|
||||
std::lock_guard lock(roles_mutex);
|
||||
|
||||
// don't change role when hand from other driver is used
|
||||
if (roles.left == left_hand_interaction_index || roles.left == left_controller_index)
|
||||
if (roles.left == -1 || roles.left == left_hand_interaction_index || roles.left == left_controller_index)
|
||||
{
|
||||
if (left == XRT_DEVICE_EXT_HAND_INTERACTION)
|
||||
{
|
||||
left_hand_interaction.reset_history();
|
||||
roles.left = left_hand_interaction_index;
|
||||
}
|
||||
else
|
||||
else if (left != XRT_DEVICE_INVALID)
|
||||
{
|
||||
left_controller.reset_history();
|
||||
roles.left = left_controller_index;
|
||||
set_enabled(device_id::LEFT_PINCH_POSE, false);
|
||||
set_enabled(device_id::LEFT_POKE, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
roles.left = -1;
|
||||
}
|
||||
}
|
||||
roles.left_profile = left;
|
||||
|
||||
if (roles.right == right_hand_interaction_index || roles.right == right_controller_index)
|
||||
if (roles.right == -1 || roles.right == right_hand_interaction_index || roles.right == right_controller_index)
|
||||
{
|
||||
if (right == XRT_DEVICE_EXT_HAND_INTERACTION)
|
||||
{
|
||||
right_hand_interaction.reset_history();
|
||||
roles.right = right_hand_interaction_index;
|
||||
}
|
||||
else
|
||||
else if (right != XRT_DEVICE_INVALID)
|
||||
{
|
||||
right_controller.reset_history();
|
||||
roles.right = right_controller_index;
|
||||
set_enabled(device_id::RIGHT_PINCH_POSE, false);
|
||||
set_enabled(device_id::RIGHT_POKE, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
roles.right = -1;
|
||||
}
|
||||
}
|
||||
roles.right_profile = right;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user