Skip to content

Commit

Permalink
Add bindings for WMR controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
hare_ware committed Apr 12, 2024
1 parent 0b087cb commit 958dcd7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/backend/openxr/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> {
let mut enabled_extensions = xr::ExtensionSet::default();
enabled_extensions.khr_vulkan_enable2 = true;
enabled_extensions.extx_overlay = true;
if available_extensions.khr_binding_modification && available_extensions.ext_dpad_binding {
enabled_extensions.khr_binding_modification = true;
enabled_extensions.ext_dpad_binding = true;
} else {
log::warn!("Missing EXT_dpad_binding extension.");
}

//#[cfg(not(debug_assertions))]
let layers = [];
Expand Down
63 changes: 63 additions & 0 deletions src/backend/openxr/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,5 +521,68 @@ fn suggest_bindings(
],
)?;

let path = instance.string_to_path("/interaction_profiles/microsoft/motion_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/click")?,
),
xr::Binding::new(
&hands[1].action_grab,
instance.string_to_path("/user/hand/right/input/squeeze/click")?,
),
xr::Binding::new(
&hands[0].action_click_modifier_right,
instance.string_to_path("/user/hand/left/input/trackpad/dpad_up")?,
),
xr::Binding::new(
&hands[1].action_click_modifier_right,
instance.string_to_path("/user/hand/right/input/trackpad/dpad_up")?,
),
xr::Binding::new(
&hands[0].action_click_modifier_middle,
instance.string_to_path("/user/hand/left/input/trackpad/dpad_down")?,
),
xr::Binding::new(
&hands[1].action_click_modifier_middle,
instance.string_to_path("/user/hand/right/input/trackpad/dpad_down")?,
),
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(())
}

0 comments on commit 958dcd7

Please sign in to comment.