Add space reset to openvr actions

This commit is contained in:
founta 2026-03-22 17:02:24 -04:00
parent b0bbc25083
commit fe547d1f69
3 changed files with 34 additions and 0 deletions

View File

@ -40,6 +40,7 @@ const PATH_SCROLL: &str = "/actions/default/in/Scroll";
const PATH_SHOW_HIDE: &str = "/actions/default/in/ShowHide";
const PATH_SPACE_DRAG: &str = "/actions/default/in/SpaceDrag";
const PATH_SPACE_ROTATE: &str = "/actions/default/in/SpaceRotate";
const PATH_SPACE_RESET: &str = "/actions/default/in/SpaceReset";
const PATH_TOGGLE_DASHBOARD: &str = "/actions/default/in/ToggleDashboard";
const INPUT_ANY: InputValueHandle = InputValueHandle(ovr_overlay::sys::k_ulInvalidInputValueHandle);
@ -55,6 +56,7 @@ pub(super) struct OpenVrInputSource {
toggle_dashboard_hnd: ActionHandle,
space_drag_hnd: ActionHandle,
space_rotate_hnd: ActionHandle,
space_reset_hnd: ActionHandle,
click_modifier_right_hnd: ActionHandle,
click_modifier_middle_hnd: ActionHandle,
move_mouse_hnd: ActionHandle,
@ -80,6 +82,7 @@ impl OpenVrInputSource {
let toggle_dashboard_hnd = input.get_action_handle(PATH_TOGGLE_DASHBOARD)?;
let space_drag_hnd = input.get_action_handle(PATH_SPACE_DRAG)?;
let space_rotate_hnd = input.get_action_handle(PATH_SPACE_ROTATE)?;
let space_reset_hnd = input.get_action_handle(PATH_SPACE_RESET)?;
let click_modifier_right_hnd = input.get_action_handle(PATH_CLICK_MODIFIER_RIGHT)?;
let click_modifier_middle_hnd = input.get_action_handle(PATH_CLICK_MODIFIER_MIDDLE)?;
let move_mouse_hnd = input.get_action_handle(PATH_MOVE_MOUSE)?;
@ -118,6 +121,7 @@ impl OpenVrInputSource {
toggle_dashboard_hnd,
space_drag_hnd,
space_rotate_hnd,
space_reset_hnd,
click_modifier_right_hnd,
click_modifier_middle_hnd,
move_mouse_hnd,
@ -243,6 +247,11 @@ impl OpenVrInputSource {
.map(|x| x.0.bState)
.unwrap_or(false);
app_hand.now.space_reset = input
.get_digital_action_data(self.space_reset_hnd, hand.input_hnd)
.map(|x| x.0.bState)
.unwrap_or(false);
app_hand.now.click_modifier_right = input
.get_digital_action_data(self.click_modifier_right_hnd, hand.input_hnd)
.map(|x| x.0.bState)

View File

@ -23,6 +23,7 @@ pub(super) struct PlayspaceMover {
universe: ETrackingUniverseOrigin,
drag: Option<MoverData<Vec3A>>,
rotate: Option<MoverData<Quat>>,
reset: Option<usize>,
}
impl PlayspaceMover {
@ -31,6 +32,7 @@ impl PlayspaceMover {
universe: ETrackingUniverseOrigin::TrackingUniverseRawAndUncalibrated,
drag: None,
rotate: None,
reset: None,
}
}
@ -178,6 +180,24 @@ impl PlayspaceMover {
}
}
}
if self.reset.is_none() {
for (i, pointer) in app.input_state.pointers.iter().enumerate() {
if pointer.now.space_reset {
self.reset_offset(chaperone_mgr, &app.input_state);
self.reset = Some(i);
log::info!("Space reset");
return;
}
}
} else {
let pointer = &app.input_state.pointers[self.reset.unwrap()];
if !pointer.now.space_reset {
self.reset = None;
log::debug!("End space reset");
return;
}
}
}
pub fn reset_offset(&mut self, chaperone_mgr: &mut ChaperoneSetupManager, input: &InputState) {

View File

@ -50,6 +50,11 @@
"type": "boolean",
"requirement": "optional"
},
{
"name": "/actions/default/in/SpaceReset",
"type": "boolean",
"requirement": "optional"
},
{
"name": "/actions/default/in/LeftHand",
"type": "pose",