From a70b9a8a85efda5abe4bc6e29b650b6538aad133 Mon Sep 17 00:00:00 2001 From: hare_ware <3469405-hare_ware@users.noreply.gitlab.com> Date: Fri, 12 Apr 2024 04:06:32 -0400 Subject: [PATCH] Add support for HP Mixed Reality Controllers --- src/backend/openxr/helpers.rs | 5 +++ src/backend/openxr/input.rs | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/src/backend/openxr/helpers.rs b/src/backend/openxr/helpers.rs index 529bdbd..7ba86b5 100644 --- a/src/backend/openxr/helpers.rs +++ b/src/backend/openxr/helpers.rs @@ -26,6 +26,11 @@ pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> { enabled_extensions.ext_dpad_binding = true; } else { log::warn!("Missing EXT_dpad_binding extension."); + } + if available_extensions.ext_hp_mixed_reality_controller { + enabled_extensions.ext_hp_mixed_reality_controller = true; + } else { + log::warn!("Missing EXT_hp_mixed_reality_controller extension."); } //#[cfg(not(debug_assertions))] diff --git a/src/backend/openxr/input.rs b/src/backend/openxr/input.rs index 752dbdd..bcc2ef3 100644 --- a/src/backend/openxr/input.rs +++ b/src/backend/openxr/input.rs @@ -584,5 +584,68 @@ fn suggest_bindings( ], )?; + let path = instance.string_to_path("/interaction_profiles/hp/mixed_reality_controller")?; + instance.suggest_interaction_profile_bindings( + path, + &[ + xr::Binding::new( + &hands[0].action_pose, + instance.string_to_path("/user/hand/left/input/aim/pose")?, + ), + xr::Binding::new( + &hands[1].action_pose, + instance.string_to_path("/user/hand/right/input/aim/pose")?, + ), + xr::Binding::new( + &hands[1].action_click, + instance.string_to_path("/user/hand/right/input/trigger/value")?, + ), + xr::Binding::new( + &hands[0].action_grab, + instance.string_to_path("/user/hand/left/input/squeeze/value")?, + ), + xr::Binding::new( + &hands[1].action_grab, + instance.string_to_path("/user/hand/right/input/squeeze/value")?, + ), + xr::Binding::new( + &hands[0].action_click_modifier_right, + instance.string_to_path("/user/hand/left/input/y/click")?, + ), + xr::Binding::new( + &hands[1].action_click_modifier_right, + instance.string_to_path("/user/hand/right/input/b/click")?, + ), + xr::Binding::new( + &hands[0].action_click_modifier_middle, + instance.string_to_path("/user/hand/left/input/x/click")?, + ), + xr::Binding::new( + &hands[1].action_click_modifier_middle, + instance.string_to_path("/user/hand/right/input/a/click")?, + ), + xr::Binding::new( + &hands[0].action_scroll, + instance.string_to_path("/user/hand/left/input/thumbstick/y")?, + ), + xr::Binding::new( + &hands[1].action_scroll, + instance.string_to_path("/user/hand/right/input/thumbstick/y")?, + ), + xr::Binding::new( + &hands[0].action_show_hide, + instance.string_to_path("/user/hand/left/input/menu/click")?, + ), + xr::Binding::new( + &hands[0].action_haptics, + instance.string_to_path("/user/hand/left/output/haptic")?, + ), + xr::Binding::new( + &hands[1].action_haptics, + instance.string_to_path("/user/hand/right/output/haptic")?, + ), + ], + )?; + Ok(()) }