From b85077b55927601cdbb7f235313f8eba04d6e6d6 Mon Sep 17 00:00:00 2001 From: Beyley Cardellio Date: Sat, 1 Aug 2026 19:59:25 -0700 Subject: [PATCH] openxr: Add support for ContactGlove2+Magnetra2 --- wayvr/src/backend/openxr/helpers.rs | 2 +- wlx-common/assets/openxr_actions.json5 | 56 ++++++++++++++ wlx-common/src/openxr_bindings_schema.rs | 1 + wlx-common/src/openxr_controller_profiles.rs | 78 ++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) diff --git a/wayvr/src/backend/openxr/helpers.rs b/wayvr/src/backend/openxr/helpers.rs index 60aeab73..8bd425e7 100644 --- a/wayvr/src/backend/openxr/helpers.rs +++ b/wayvr/src/backend/openxr/helpers.rs @@ -95,7 +95,7 @@ pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> { enabled_extensions.other.push(xr_extension); } - let xr_extension = b"XR_VALVE_frame_controller_interaction".to_vec(); + let xr_extension: Vec = b"XR_MND_contactglove2_interaction\0".to_vec(); if available_extensions.other.contains(&xr_extension) { enabled_extensions.other.push(xr_extension); } diff --git a/wlx-common/assets/openxr_actions.json5 b/wlx-common/assets/openxr_actions.json5 index 155cfb88..3925f5c7 100644 --- a/wlx-common/assets/openxr_actions.json5 +++ b/wlx-common/assets/openxr_actions.json5 @@ -500,5 +500,61 @@ left: "/user/hand/left/output/haptic", right: "/user/hand/right/output/haptic" } + }, + { + profile: "/interaction_profiles/mnd/contactglove2_with_magnetra2_mnd", + pose: { + left: "/user/hand/left/input/aim/pose", + right: "/user/hand/right/input/aim/pose" + }, + click: { + left: "/user/hand/left/input/trigger/value", + right: "/user/hand/right/input/trigger/value" + }, + grab: { + left: "/user/hand/left/input/squeeze/value", + right: "/user/hand/right/input/squeeze/value" + }, + show_hide: { + left: "/user/hand/left/input/system/click", + }, + toggle_dashboard: { + right: "/user/hand/right/input/system/click", + }, + space_drag: { + left: "/user/hand/left/input/pairing_mnd/click", + }, + space_rotate: { + right: "/user/hand/right/input/pairing_mnd/click", + }, + space_reset: { + left: "/user/hand/left/input/pairing_mnd/click", + right: "/user/hand/right/input/pairing_mnd/click", + double_click: true, + }, + click_modifier_right: { + left: "/user/hand/left/input/y/click", + right: "/user/hand/right/input/y/click" + }, + click_modifier_middle: { + left: "/user/hand/left/input/x/click", + right: "/user/hand/right/input/x/click" + }, + move_mouse: { + left: "/user/hand/left/input/trigger/value", + right: "/user/hand/right/input/trigger/value", + }, + scroll: { + left: "/user/hand/left/input/thumbstick/y", + right: "/user/hand/right/input/thumbstick/y" + }, + scroll_horizontal: { + left: "/user/hand/left/input/thumbstick/x", + right: "/user/hand/right/input/thumbstick/x" + }, + haptic: { + left: "/user/hand/left/output/haptic", + right: "/user/hand/right/output/haptic" + } } ] diff --git a/wlx-common/src/openxr_bindings_schema.rs b/wlx-common/src/openxr_bindings_schema.rs index 93012080..83011c2f 100644 --- a/wlx-common/src/openxr_bindings_schema.rs +++ b/wlx-common/src/openxr_bindings_schema.rs @@ -47,6 +47,7 @@ pub enum XrInputSubpathKind { System, Menu, View, + PairingMnd, Primary, Secondary, diff --git a/wlx-common/src/openxr_controller_profiles.rs b/wlx-common/src/openxr_controller_profiles.rs index fa49046a..919e12d3 100644 --- a/wlx-common/src/openxr_controller_profiles.rs +++ b/wlx-common/src/openxr_controller_profiles.rs @@ -738,3 +738,81 @@ const KHR_GENERIC_CONTROLLER_USER_PATHS: &[XrInputSubpath] = &[ components: &[], }, ]; + +pub const MAGNETRA2_CONTROLLER_PROFILE: XrControllerProfile = XrControllerProfile { + display_name: "ContactGlove2 + Magnetra2", + extension: Some("XR_MND_contactglove2_interaction"), + profile_id: "/interaction_profiles/mnd/contactglove2_with_magnetra2_mnd", + user_paths: &[ + XrControllerUserPath { + hand: XrInputSide::Left, + paths: MAGNETRA2_USER_PATHS, + }, + XrControllerUserPath { + hand: XrInputSide::Right, + paths: MAGNETRA2_USER_PATHS, + }, + ], +}; + +const MAGNETRA2_USER_PATHS: &[XrInputSubpath] = &[ + XrInputSubpath { + kind: XrInputSubpathKind::A, + components: &[XrInputComponent::Click], + }, + XrInputSubpath { + kind: XrInputSubpathKind::B, + components: &[XrInputComponent::Click], + }, + XrInputSubpath { + kind: XrInputSubpathKind::X, + components: &[XrInputComponent::Click], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Y, + components: &[XrInputComponent::Click], + }, + XrInputSubpath { + kind: XrInputSubpathKind::System, + components: &[XrInputComponent::Click], + }, + XrInputSubpath { + kind: XrInputSubpathKind::PairingMnd, + components: &[XrInputComponent::Click], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Squeeze, + components: &[XrInputComponent::Value], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Trigger, + components: &[ + XrInputComponent::Click, + XrInputComponent::Value, + ], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Thumbstick, + components: &[ + XrInputComponent::Click, + XrInputComponent::X, + XrInputComponent::Y, + XrInputComponent::DpadUp, + XrInputComponent::DpadDown, + XrInputComponent::DpadLeft, + XrInputComponent::DpadRight, + ], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Grip, + components: &[XrInputComponent::Pose], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Aim, + components: &[XrInputComponent::Pose], + }, + XrInputSubpath { + kind: XrInputSubpathKind::Haptic, + components: &[], + }, +];