Updated Oculus controller to use the
This commit is contained in:
@@ -18,6 +18,7 @@ use bevy_oxr::{
|
|||||||
input::XrInput,
|
input::XrInput,
|
||||||
resources::{XrFrameState, XrInstance, XrSession},
|
resources::{XrFrameState, XrInstance, XrSession},
|
||||||
xr_input::{
|
xr_input::{
|
||||||
|
actions::ActionSets,
|
||||||
debug_gizmos::OpenXrDebugRenderer,
|
debug_gizmos::OpenXrDebugRenderer,
|
||||||
hand::{HandBone, HandInputDebugRenderer, HandResource, HandsResource, OpenXrHandInput},
|
hand::{HandBone, HandInputDebugRenderer, HandResource, HandsResource, OpenXrHandInput},
|
||||||
interactions::{
|
interactions::{
|
||||||
@@ -516,13 +517,14 @@ fn request_cube_spawn(
|
|||||||
mut writer: EventWriter<SpawnCubeRequest>,
|
mut writer: EventWriter<SpawnCubeRequest>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut timer: ResMut<SpawnCubeTimer>,
|
mut timer: ResMut<SpawnCubeTimer>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
timer.0.tick(time.delta());
|
timer.0.tick(time.delta());
|
||||||
if timer.0.finished() {
|
if timer.0.finished() {
|
||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
//get controller triggers
|
//get controller triggers
|
||||||
let left_main_button = controller.a_button();
|
let left_main_button = controller.a_button();
|
||||||
if left_main_button {
|
if left_main_button {
|
||||||
@@ -568,7 +570,6 @@ fn prototype_interaction_input(
|
|||||||
oculus_controller: Res<OculusController>,
|
oculus_controller: Res<OculusController>,
|
||||||
frame_state: Res<XrFrameState>,
|
frame_state: Res<XrFrameState>,
|
||||||
xr_input: Res<XrInput>,
|
xr_input: Res<XrInput>,
|
||||||
instance: Res<XrInstance>,
|
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
mut right_interactor_query: Query<
|
mut right_interactor_query: Query<
|
||||||
(&mut XRInteractorState),
|
(&mut XRInteractorState),
|
||||||
@@ -586,11 +587,12 @@ fn prototype_interaction_input(
|
|||||||
Without<OpenXRRightController>,
|
Without<OpenXRRightController>,
|
||||||
),
|
),
|
||||||
>,
|
>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
//get controller triggers
|
//get controller triggers
|
||||||
let left_trigger = controller.trigger(Hand::Left);
|
let left_trigger = controller.trigger(Hand::Left);
|
||||||
let right_trigger = controller.trigger(Hand::Right);
|
let right_trigger = controller.trigger(Hand::Right);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
@@ -7,7 +5,8 @@ use bevy::transform::components::Transform;
|
|||||||
use bevy_oxr::input::XrInput;
|
use bevy_oxr::input::XrInput;
|
||||||
use bevy_oxr::resources::{XrFrameState, XrInstance, XrSession};
|
use bevy_oxr::resources::{XrFrameState, XrInstance, XrSession};
|
||||||
|
|
||||||
use bevy_oxr::xr_input::hand::{OpenXrHandInput, HandInputDebugRenderer};
|
use bevy_oxr::xr_input::actions::ActionSets;
|
||||||
|
use bevy_oxr::xr_input::hand::{HandInputDebugRenderer, OpenXrHandInput};
|
||||||
use bevy_oxr::xr_input::interactions::{
|
use bevy_oxr::xr_input::interactions::{
|
||||||
draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions,
|
draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions,
|
||||||
update_interactable_states, InteractionEvent, Touched, XRDirectInteractor, XRInteractable,
|
update_interactable_states, InteractionEvent, Touched, XRDirectInteractor, XRInteractable,
|
||||||
@@ -143,7 +142,6 @@ fn prototype_interaction_input(
|
|||||||
oculus_controller: Res<OculusController>,
|
oculus_controller: Res<OculusController>,
|
||||||
frame_state: Res<XrFrameState>,
|
frame_state: Res<XrFrameState>,
|
||||||
xr_input: Res<XrInput>,
|
xr_input: Res<XrInput>,
|
||||||
instance: Res<XrInstance>,
|
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
mut right_interactor_query: Query<
|
mut right_interactor_query: Query<
|
||||||
(&mut XRInteractorState),
|
(&mut XRInteractorState),
|
||||||
@@ -161,11 +159,12 @@ fn prototype_interaction_input(
|
|||||||
Without<OpenXRRightController>,
|
Without<OpenXRRightController>,
|
||||||
),
|
),
|
||||||
>,
|
>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
//get controller triggers
|
//get controller triggers
|
||||||
let left_trigger = controller.trigger(Hand::Left);
|
let left_trigger = controller.trigger(Hand::Left);
|
||||||
let right_trigger = controller.trigger(Hand::Right);
|
let right_trigger = controller.trigger(Hand::Right);
|
||||||
|
|||||||
14
src/lib.rs
14
src/lib.rs
@@ -6,7 +6,6 @@ pub mod xr_input;
|
|||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use crate::xr_input::oculus_touch::ActionSets;
|
|
||||||
use bevy::app::PluginGroupBuilder;
|
use bevy::app::PluginGroupBuilder;
|
||||||
use bevy::ecs::system::SystemState;
|
use bevy::ecs::system::SystemState;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
@@ -97,7 +96,7 @@ impl Plugin for OpenXrPlugin {
|
|||||||
views,
|
views,
|
||||||
frame_state,
|
frame_state,
|
||||||
));
|
));
|
||||||
app.insert_resource(ActionSets(vec![]));
|
// app.insert_resource(ActionSets(vec![]));
|
||||||
app.add_plugins(RenderPlugin {
|
app.add_plugins(RenderPlugin {
|
||||||
render_creation: RenderCreation::Manual(
|
render_creation: RenderCreation::Manual(
|
||||||
device,
|
device,
|
||||||
@@ -132,7 +131,7 @@ impl Plugin for OpenXrPlugin {
|
|||||||
frame_state,
|
frame_state,
|
||||||
) = future_renderer_resources.0.lock().unwrap().take().unwrap();
|
) = future_renderer_resources.0.lock().unwrap().take().unwrap();
|
||||||
|
|
||||||
let action_sets = app.world.resource::<ActionSets>().clone();
|
// let action_sets = app.world.resource::<ActionSets>().clone();
|
||||||
|
|
||||||
app.insert_resource(xr_instance.clone())
|
app.insert_resource(xr_instance.clone())
|
||||||
.insert_resource(session.clone())
|
.insert_resource(session.clone())
|
||||||
@@ -144,9 +143,10 @@ impl Plugin for OpenXrPlugin {
|
|||||||
.insert_resource(swapchain.clone())
|
.insert_resource(swapchain.clone())
|
||||||
.insert_resource(input.clone())
|
.insert_resource(input.clone())
|
||||||
.insert_resource(views.clone())
|
.insert_resource(views.clone())
|
||||||
.insert_resource(frame_state.clone())
|
.insert_resource(frame_state.clone());
|
||||||
.insert_resource(action_sets.clone());
|
// .insert_resource(action_sets.clone());
|
||||||
let hands = xr_instance.exts().ext_hand_tracking.is_some();
|
let hands = xr_instance.exts().ext_hand_tracking.is_some();
|
||||||
|
let hands = false;
|
||||||
if hands {
|
if hands {
|
||||||
app.insert_resource(HandTrackingTracker::new(&session).unwrap());
|
app.insert_resource(HandTrackingTracker::new(&session).unwrap());
|
||||||
app.insert_resource(HandInputSource::OpenXr);
|
app.insert_resource(HandInputSource::OpenXr);
|
||||||
@@ -183,8 +183,8 @@ impl Plugin for OpenXrPlugin {
|
|||||||
.insert_resource(swapchain)
|
.insert_resource(swapchain)
|
||||||
.insert_resource(input)
|
.insert_resource(input)
|
||||||
.insert_resource(views)
|
.insert_resource(views)
|
||||||
.insert_resource(frame_state)
|
.insert_resource(frame_state);
|
||||||
.insert_resource(action_sets);
|
// .insert_resource(action_sets);
|
||||||
|
|
||||||
render_app.add_systems(
|
render_app.add_systems(
|
||||||
Render,
|
Render,
|
||||||
|
|||||||
@@ -1,15 +1,27 @@
|
|||||||
use bevy::{prelude::*, utils::HashMap};
|
use bevy::{prelude::*, utils::HashMap};
|
||||||
use openxr as xr;
|
use openxr as xr;
|
||||||
use xr::{Action, Binding, Posef};
|
use xr::{Action, Binding, Haptic, Posef};
|
||||||
|
|
||||||
use crate::resources::XrInstance;
|
use crate::resources::{XrInstance, XrSession};
|
||||||
|
|
||||||
pub fn setup_oxr_actions(world: &mut World, instance: Ref<XrInstance>) {
|
pub struct OpenXrActionsPlugin;
|
||||||
|
impl Plugin for OpenXrActionsPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.insert_resource(SetupActionSets {
|
||||||
|
sets: HashMap::new(),
|
||||||
|
});
|
||||||
|
app.add_systems(PostStartup, setup_oxr_actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setup_oxr_actions(world: &mut World) {
|
||||||
|
let actions = world.remove_resource::<SetupActionSets>().unwrap();
|
||||||
|
let instance = world.get_resource::<XrInstance>().unwrap();
|
||||||
|
let session = world.get_resource::<XrSession>().unwrap();
|
||||||
let left_path = instance.string_to_path("/user/hand/left").unwrap();
|
let left_path = instance.string_to_path("/user/hand/left").unwrap();
|
||||||
let right_path = instance.string_to_path("/user/hand/right").unwrap();
|
let right_path = instance.string_to_path("/user/hand/right").unwrap();
|
||||||
let hands = [left_path, right_path];
|
let hands = [left_path, right_path];
|
||||||
|
|
||||||
let actions = world.remove_resource::<SetupActionSets>().unwrap();
|
|
||||||
let mut action_sets = ActionSets { sets: default() };
|
let mut action_sets = ActionSets { sets: default() };
|
||||||
let mut action_bindings: HashMap<&'static str, Vec<xr::Path>> = HashMap::new();
|
let mut action_bindings: HashMap<&'static str, Vec<xr::Path>> = HashMap::new();
|
||||||
let mut a_iter = actions.sets.into_iter();
|
let mut a_iter = actions.sets.into_iter();
|
||||||
@@ -31,7 +43,7 @@ pub fn setup_oxr_actions(world: &mut World, instance: Ref<XrInstance>) {
|
|||||||
ActionType::Bool => TypedAction::Bool(match action.handednes {
|
ActionType::Bool => TypedAction::Bool(match action.handednes {
|
||||||
ActionHandednes::Single => oxr_action_set
|
ActionHandednes::Single => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &[])
|
.create_action(action_name, action.pretty_name, &[])
|
||||||
.unwrap(),
|
.expect(action.pretty_name),
|
||||||
ActionHandednes::Double => oxr_action_set
|
ActionHandednes::Double => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &hands)
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@@ -44,6 +56,14 @@ pub fn setup_oxr_actions(world: &mut World, instance: Ref<XrInstance>) {
|
|||||||
.create_action(action_name, action.pretty_name, &hands)
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
}),
|
}),
|
||||||
|
ActionType::Haptic => TypedAction::Haptic(match action.handednes {
|
||||||
|
ActionHandednes::Single => oxr_action_set
|
||||||
|
.create_action(action_name, action.pretty_name, &[])
|
||||||
|
.unwrap(),
|
||||||
|
ActionHandednes::Double => oxr_action_set
|
||||||
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
|
.unwrap(),
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
actions.insert(action_name, typed_action);
|
actions.insert(action_name, typed_action);
|
||||||
for (device_path, bindings) in action.bindings.into_iter() {
|
for (device_path, bindings) in action.bindings.into_iter() {
|
||||||
@@ -60,6 +80,7 @@ pub fn setup_oxr_actions(world: &mut World, instance: Ref<XrInstance>) {
|
|||||||
ActionSet {
|
ActionSet {
|
||||||
oxr_action_set,
|
oxr_action_set,
|
||||||
actions,
|
actions,
|
||||||
|
enabled: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -77,6 +98,7 @@ pub fn setup_oxr_actions(world: &mut World, instance: Ref<XrInstance>) {
|
|||||||
TypedAction::F32(a) => Binding::new(a, binding),
|
TypedAction::F32(a) => Binding::new(a, binding),
|
||||||
TypedAction::Bool(a) => Binding::new(a, binding),
|
TypedAction::Bool(a) => Binding::new(a, binding),
|
||||||
TypedAction::PoseF(a) => Binding::new(a, binding),
|
TypedAction::PoseF(a) => Binding::new(a, binding),
|
||||||
|
TypedAction::Haptic(a) => Binding::new(a, binding),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
@@ -86,6 +108,17 @@ pub fn setup_oxr_actions(world: &mut World, instance: Ref<XrInstance>) {
|
|||||||
.suggest_interaction_profile_bindings(instance.string_to_path(dev).unwrap(), &bindings)
|
.suggest_interaction_profile_bindings(instance.string_to_path(dev).unwrap(), &bindings)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
session
|
||||||
|
.attach_action_sets(
|
||||||
|
&action_sets
|
||||||
|
.sets
|
||||||
|
.iter()
|
||||||
|
.map(|(_, set)| &set.oxr_action_set)
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
world.insert_resource(action_sets);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ActionHandednes {
|
pub enum ActionHandednes {
|
||||||
@@ -97,12 +130,14 @@ pub enum ActionType {
|
|||||||
F32,
|
F32,
|
||||||
Bool,
|
Bool,
|
||||||
PoseF,
|
PoseF,
|
||||||
|
Haptic,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum TypedAction {
|
pub enum TypedAction {
|
||||||
F32(Action<f32>),
|
F32(Action<f32>),
|
||||||
Bool(Action<bool>),
|
Bool(Action<bool>),
|
||||||
PoseF(Action<Posef>),
|
PoseF(Action<Posef>),
|
||||||
|
Haptic(Action<Haptic>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SetupAction {
|
pub struct SetupAction {
|
||||||
@@ -136,19 +171,30 @@ impl SetupActionSet {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub fn suggest_binding(
|
pub fn suggest_binding(&mut self, device_path: &'static str, bindings: &[XrBinding]) {
|
||||||
&mut self,
|
for binding in bindings {
|
||||||
action_name: &'static str,
|
self.actions
|
||||||
device_path: &'static str,
|
.get_mut(binding.action)
|
||||||
action_path: &'static str,
|
.ok_or(anyhow::anyhow!("Missing Action: {}", binding.action))
|
||||||
) {
|
.unwrap()
|
||||||
self.actions
|
.bindings
|
||||||
.get_mut(action_name)
|
.entry(device_path)
|
||||||
.unwrap()
|
.or_default()
|
||||||
.bindings
|
.push(binding.path);
|
||||||
.entry(device_path)
|
}
|
||||||
.or_default()
|
}
|
||||||
.push(action_path);
|
}
|
||||||
|
pub struct XrBinding {
|
||||||
|
action: &'static str,
|
||||||
|
path: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl XrBinding {
|
||||||
|
pub fn new(action_name: &'static str, binding_path: &'static str) -> XrBinding {
|
||||||
|
XrBinding {
|
||||||
|
action: action_name,
|
||||||
|
path: binding_path,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +224,7 @@ impl SetupActionSets {
|
|||||||
|
|
||||||
pub struct ActionSet {
|
pub struct ActionSet {
|
||||||
oxr_action_set: xr::ActionSet,
|
oxr_action_set: xr::ActionSet,
|
||||||
|
enabled: bool,
|
||||||
actions: HashMap<&'static str, TypedAction>,
|
actions: HashMap<&'static str, TypedAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,3 +232,74 @@ pub struct ActionSet {
|
|||||||
pub struct ActionSets {
|
pub struct ActionSets {
|
||||||
sets: HashMap<&'static str, ActionSet>,
|
sets: HashMap<&'static str, ActionSet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ActionSets {
|
||||||
|
pub fn get_action_f32(
|
||||||
|
&self,
|
||||||
|
action_set: &'static str,
|
||||||
|
action_name: &'static str,
|
||||||
|
) -> anyhow::Result<&Action<f32>> {
|
||||||
|
let action = self
|
||||||
|
.sets
|
||||||
|
.get(action_set)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Set Not Found!"))?
|
||||||
|
.actions
|
||||||
|
.get(action_name)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Not Found!"))?;
|
||||||
|
match action {
|
||||||
|
TypedAction::F32(a) => Ok(a),
|
||||||
|
_ => anyhow::bail!("wrong action type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn get_action_bool(
|
||||||
|
&self,
|
||||||
|
action_set: &'static str,
|
||||||
|
action_name: &'static str,
|
||||||
|
) -> anyhow::Result<&Action<bool>> {
|
||||||
|
let action = self
|
||||||
|
.sets
|
||||||
|
.get(action_set)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Set Not Found!"))?
|
||||||
|
.actions
|
||||||
|
.get(action_name)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Not Found!"))?;
|
||||||
|
match action {
|
||||||
|
TypedAction::Bool(a) => Ok(a),
|
||||||
|
_ => anyhow::bail!("wrong action type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn get_action_posef(
|
||||||
|
&self,
|
||||||
|
action_set: &'static str,
|
||||||
|
action_name: &'static str,
|
||||||
|
) -> anyhow::Result<&Action<Posef>> {
|
||||||
|
let action = self
|
||||||
|
.sets
|
||||||
|
.get(action_set)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Set Not Found!"))?
|
||||||
|
.actions
|
||||||
|
.get(action_name)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Not Found!"))?;
|
||||||
|
match action {
|
||||||
|
TypedAction::PoseF(a) => Ok(a),
|
||||||
|
_ => anyhow::bail!("wrong action type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn get_action_haptic(
|
||||||
|
&self,
|
||||||
|
action_set: &'static str,
|
||||||
|
action_name: &'static str,
|
||||||
|
) -> anyhow::Result<&Action<Haptic>> {
|
||||||
|
let action = self
|
||||||
|
.sets
|
||||||
|
.get(action_set)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Set Not Found!"))?
|
||||||
|
.actions
|
||||||
|
.get(action_name)
|
||||||
|
.ok_or(anyhow::anyhow!("Action Not Found!"))?;
|
||||||
|
match action {
|
||||||
|
TypedAction::Haptic(a) => Ok(a),
|
||||||
|
_ => anyhow::bail!("wrong action type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use crate::xr_input::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
actions::ActionSets,
|
||||||
handtracking::{HandTrackingRef, HandTrackingTracker},
|
handtracking::{HandTrackingRef, HandTrackingTracker},
|
||||||
trackers::{OpenXRLeftController, OpenXRRightController, OpenXRTrackingRoot},
|
trackers::{OpenXRLeftController, OpenXRRightController, OpenXRTrackingRoot},
|
||||||
QuatConv,
|
QuatConv,
|
||||||
@@ -54,44 +55,48 @@ pub fn draw_gizmos(
|
|||||||
Without<OpenXRLeftController>,
|
Without<OpenXRLeftController>,
|
||||||
Without<OpenXRTrackingRoot>,
|
Without<OpenXRTrackingRoot>,
|
||||||
)>,
|
)>,
|
||||||
hand_tracking: Res<HandTrackingTracker>,
|
hand_tracking: Option<Res<HandTrackingTracker>>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
let handtracking_ref = hand_tracking.get_ref(&xr_input, &frame_state);
|
if let Some(hand_tracking) = hand_tracking {
|
||||||
if let Some(joints) = handtracking_ref.get_left_poses() {
|
let handtracking_ref = hand_tracking.get_ref(&xr_input, &frame_state);
|
||||||
for joint in joints {
|
if let Some(joints) = handtracking_ref.get_left_poses() {
|
||||||
let p = joint.pose.position;
|
for joint in joints {
|
||||||
let r = joint.pose.orientation;
|
let p = joint.pose.position;
|
||||||
let quat = r.to_quat();
|
let r = joint.pose.orientation;
|
||||||
let trans = Transform::from_rotation(quat);
|
let quat = r.to_quat();
|
||||||
gizmos.circle(
|
let trans = Transform::from_rotation(quat);
|
||||||
(p.x, p.y, p.z).into(),
|
gizmos.circle(
|
||||||
trans.forward(),
|
(p.x, p.y, p.z).into(),
|
||||||
joint.radius,
|
trans.forward(),
|
||||||
Color::ORANGE_RED,
|
joint.radius,
|
||||||
);
|
Color::ORANGE_RED,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("left_hand_poses returned None");
|
||||||
}
|
}
|
||||||
} else {
|
if let Some(joints) = handtracking_ref.get_right_poses() {
|
||||||
info!("left_hand_poses returned None");
|
for joint in joints {
|
||||||
}
|
let p = joint.pose.position;
|
||||||
if let Some(joints) = handtracking_ref.get_right_poses() {
|
let r = joint.pose.orientation;
|
||||||
for joint in joints {
|
let quat = r.to_quat();
|
||||||
let p = joint.pose.position;
|
let trans = Transform::from_rotation(quat);
|
||||||
let r = joint.pose.orientation;
|
gizmos.circle(
|
||||||
let quat = r.to_quat();
|
(p.x, p.y, p.z).into(),
|
||||||
let trans = Transform::from_rotation(quat);
|
trans.forward(),
|
||||||
gizmos.circle(
|
joint.radius,
|
||||||
(p.x, p.y, p.z).into(),
|
Color::LIME_GREEN,
|
||||||
trans.forward(),
|
);
|
||||||
joint.radius,
|
}
|
||||||
Color::LIME_GREEN,
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
|
info!("{}",controller.x_button());
|
||||||
//tracking root?
|
//tracking root?
|
||||||
let mut tracking_transform = &Transform::IDENTITY;
|
let mut tracking_transform = &Transform::IDENTITY;
|
||||||
let root = tracking_root_query.get_single();
|
let root = tracking_root_query.get_single();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
actions::ActionSets,
|
||||||
hand_poses::get_simulated_open_hand_transforms,
|
hand_poses::get_simulated_open_hand_transforms,
|
||||||
handtracking::HandTrackingTracker,
|
handtracking::HandTrackingTracker,
|
||||||
oculus_touch::OculusController,
|
oculus_touch::OculusController,
|
||||||
@@ -363,6 +364,7 @@ pub fn update_hand_states(
|
|||||||
xr_input: Res<XrInput>,
|
xr_input: Res<XrInput>,
|
||||||
instance: Res<XrInstance>,
|
instance: Res<XrInstance>,
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
match hand_states_option {
|
match hand_states_option {
|
||||||
Some(mut hands) => {
|
Some(mut hands) => {
|
||||||
@@ -370,7 +372,7 @@ pub fn update_hand_states(
|
|||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller =
|
let controller =
|
||||||
oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
|
|
||||||
//right hand
|
//right hand
|
||||||
let squeeze = controller.squeeze(Hand::Right);
|
let squeeze = controller.squeeze(Hand::Right);
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
|
pub mod actions;
|
||||||
pub mod controllers;
|
pub mod controllers;
|
||||||
pub mod debug_gizmos;
|
pub mod debug_gizmos;
|
||||||
|
pub mod hand;
|
||||||
|
pub mod hand_poses;
|
||||||
|
pub mod handtracking;
|
||||||
pub mod interactions;
|
pub mod interactions;
|
||||||
pub mod oculus_touch;
|
pub mod oculus_touch;
|
||||||
pub mod prototype_locomotion;
|
pub mod prototype_locomotion;
|
||||||
pub mod trackers;
|
pub mod trackers;
|
||||||
pub mod xr_camera;
|
pub mod xr_camera;
|
||||||
pub mod hand_poses;
|
|
||||||
pub mod hand;
|
|
||||||
pub mod handtracking;
|
|
||||||
pub mod actions;
|
|
||||||
|
|
||||||
use crate::resources::XrSession;
|
use crate::resources::XrSession;
|
||||||
use crate::xr_begin_frame;
|
use crate::xr_begin_frame;
|
||||||
use crate::xr_input::controllers::XrControllerType;
|
use crate::xr_input::controllers::XrControllerType;
|
||||||
use crate::xr_input::oculus_touch::{setup_oculus_controller, ActionSets};
|
use crate::xr_input::oculus_touch::setup_oculus_controller;
|
||||||
use crate::xr_input::xr_camera::{xr_camera_head_sync, Eye, XRProjection, XrCameraBundle};
|
use crate::xr_input::xr_camera::{xr_camera_head_sync, Eye, XRProjection, XrCameraBundle};
|
||||||
use bevy::app::{App, PostUpdate, Startup};
|
use bevy::app::{App, PostUpdate, Startup};
|
||||||
use bevy::log::warn;
|
use bevy::log::warn;
|
||||||
use bevy::prelude::{BuildChildren, IntoSystemConfigs, Component};
|
use bevy::prelude::{BuildChildren, Component, IntoSystemConfigs};
|
||||||
use bevy::prelude::{Commands, Plugin, PreUpdate, Quat, Res, SpatialBundle, Update, Vec3};
|
use bevy::prelude::{Commands, Plugin, PreUpdate, Quat, Res, SpatialBundle, Update, Vec3};
|
||||||
use bevy::render::camera::CameraProjectionPlugin;
|
use bevy::render::camera::CameraProjectionPlugin;
|
||||||
use bevy::render::view::{update_frusta, VisibilitySystems};
|
use bevy::render::view::{update_frusta, VisibilitySystems};
|
||||||
use bevy::transform::TransformSystem;
|
use bevy::transform::TransformSystem;
|
||||||
|
|
||||||
|
use self::actions::{setup_oxr_actions, OpenXrActionsPlugin};
|
||||||
|
use self::oculus_touch::post_action_setup_oculus_controller;
|
||||||
use self::trackers::{
|
use self::trackers::{
|
||||||
adopt_open_xr_trackers, update_open_xr_controllers, OpenXRLeftEye, OpenXRRightEye,
|
adopt_open_xr_trackers, update_open_xr_controllers, OpenXRLeftEye, OpenXRRightEye,
|
||||||
OpenXRTrackingRoot,
|
OpenXRTrackingRoot,
|
||||||
@@ -47,6 +49,11 @@ impl OpenXrInput {
|
|||||||
impl Plugin for OpenXrInput {
|
impl Plugin for OpenXrInput {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins(CameraProjectionPlugin::<XRProjection>::default());
|
app.add_plugins(CameraProjectionPlugin::<XRProjection>::default());
|
||||||
|
app.add_plugins(OpenXrActionsPlugin);
|
||||||
|
app.add_systems(
|
||||||
|
PreUpdate,
|
||||||
|
(post_action_setup_oculus_controller.after(setup_oxr_actions),),
|
||||||
|
);
|
||||||
match self.controller_type {
|
match self.controller_type {
|
||||||
XrControllerType::OculusTouch => {
|
XrControllerType::OculusTouch => {
|
||||||
app.add_systems(Startup, setup_oculus_controller);
|
app.add_systems(Startup, setup_oculus_controller);
|
||||||
@@ -54,7 +61,7 @@ impl Plugin for OpenXrInput {
|
|||||||
}
|
}
|
||||||
//adopt any new trackers
|
//adopt any new trackers
|
||||||
app.add_systems(PreUpdate, adopt_open_xr_trackers);
|
app.add_systems(PreUpdate, adopt_open_xr_trackers);
|
||||||
app.add_systems(PreUpdate, action_set_system);
|
// app.add_systems(PreUpdate, action_set_system);
|
||||||
app.add_systems(PreUpdate, xr_camera_head_sync.after(xr_begin_frame));
|
app.add_systems(PreUpdate, xr_camera_head_sync.after(xr_begin_frame));
|
||||||
//update controller trackers
|
//update controller trackers
|
||||||
app.add_systems(Update, update_open_xr_controllers);
|
app.add_systems(Update, update_open_xr_controllers);
|
||||||
@@ -83,19 +90,19 @@ fn setup_xr_cameras(mut commands: Commands) {
|
|||||||
commands.entity(tracking_root).push_children(&[right, left]);
|
commands.entity(tracking_root).push_children(&[right, left]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn action_set_system(action_sets: Res<ActionSets>, session: Res<XrSession>) {
|
// fn action_set_system(action_sets: Res<ActionSets>, session: Res<XrSession>) {
|
||||||
let mut active_action_sets = vec![];
|
// let mut active_action_sets = vec![];
|
||||||
for i in &action_sets.0 {
|
// for i in &action_sets.0 {
|
||||||
active_action_sets.push(openxr::ActiveActionSet::new(i));
|
// active_action_sets.push(openxr::ActiveActionSet::new(i));
|
||||||
}
|
// }
|
||||||
//info!("action sets: {:#?}", action_sets.0.len());
|
// //info!("action sets: {:#?}", action_sets.0.len());
|
||||||
match session.sync_actions(&active_action_sets) {
|
// match session.sync_actions(&active_action_sets) {
|
||||||
Err(err) => {
|
// Err(err) => {
|
||||||
warn!("{}", err);
|
// warn!("{}", err);
|
||||||
}
|
// }
|
||||||
_ => {}
|
// _ => {}
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub trait Vec3Conv {
|
pub trait Vec3Conv {
|
||||||
fn to_vec3(&self) -> Vec3;
|
fn to_vec3(&self) -> Vec3;
|
||||||
|
|||||||
@@ -2,39 +2,81 @@ use crate::input::XrInput;
|
|||||||
use crate::resources::{XrInstance, XrSession};
|
use crate::resources::{XrInstance, XrSession};
|
||||||
use crate::xr_input::controllers::{Handed, Touchable};
|
use crate::xr_input::controllers::{Handed, Touchable};
|
||||||
use crate::xr_input::Hand;
|
use crate::xr_input::Hand;
|
||||||
use bevy::prelude::{Commands, Res, Resource};
|
use bevy::prelude::{Commands, Res, ResMut, Resource};
|
||||||
use openxr::{
|
use openxr::{
|
||||||
Action, ActionSet, AnyGraphics, Binding, FrameState, Haptic, Instance, Path, Posef, Session,
|
Action, ActionSet, AnyGraphics, Binding, FrameState, Haptic, Instance, Path, Posef, Session,
|
||||||
Space, SpaceLocation, SpaceVelocity,
|
Space, SpaceLocation, SpaceVelocity,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::convert::identity;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
pub fn setup_oculus_controller(
|
use super::actions::{ActionHandednes, ActionSets, ActionType, SetupActionSets, XrBinding};
|
||||||
mut commands: Commands,
|
|
||||||
|
pub fn post_action_setup_oculus_controller(
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
|
mut controller: ResMut<OculusController>,
|
||||||
instance: Res<XrInstance>,
|
instance: Res<XrInstance>,
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
) {
|
) {
|
||||||
let mut action_sets = vec![];
|
let s = Session::<AnyGraphics>::clone(&session);
|
||||||
let oculus_controller = OculusController::new(
|
let left_path = instance.string_to_path("/user/hand/left").unwrap();
|
||||||
Instance::clone(&instance),
|
let right_path = instance.string_to_path("/user/hand/right").unwrap();
|
||||||
Session::clone(&session),
|
let grip_action = action_sets
|
||||||
&mut action_sets,
|
.get_action_posef("oculus_input", "hand_pose")
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
session
|
|
||||||
.attach_action_sets(&action_sets.iter().map(|a| a).collect::<Vec<_>>())
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let aim_action = action_sets
|
||||||
|
.get_action_posef("oculus_input", "pointer_pose")
|
||||||
|
.unwrap();
|
||||||
|
controller.grip_space = Some(Handed {
|
||||||
|
left: grip_action
|
||||||
|
.create_space(
|
||||||
|
s.clone(),
|
||||||
|
left_path,
|
||||||
|
Posef::IDENTITY,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
right: grip_action
|
||||||
|
.create_space(
|
||||||
|
s.clone(),
|
||||||
|
right_path,
|
||||||
|
Posef::IDENTITY,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
});
|
||||||
|
controller.aim_space = Some(Handed {
|
||||||
|
left: aim_action
|
||||||
|
.create_space(
|
||||||
|
s.clone(),
|
||||||
|
left_path,
|
||||||
|
Posef::IDENTITY,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
right: aim_action
|
||||||
|
.create_space(
|
||||||
|
s.clone(),
|
||||||
|
right_path,
|
||||||
|
Posef::IDENTITY,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pub fn setup_oculus_controller(
|
||||||
|
mut commands: Commands,
|
||||||
|
instance: Res<XrInstance>,
|
||||||
|
mut action_sets: ResMut<SetupActionSets>,
|
||||||
|
) {
|
||||||
|
let oculus_controller = OculusController::new(action_sets).unwrap();
|
||||||
|
init_subaction_path(&instance);
|
||||||
commands.insert_resource(oculus_controller);
|
commands.insert_resource(oculus_controller);
|
||||||
commands.insert_resource(ActionSets(action_sets));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Clone)]
|
// #[derive(Resource, Clone)]
|
||||||
pub struct ActionSets(pub Vec<ActionSet>);
|
// pub struct ActionSets(pub Vec<ActionSet>);
|
||||||
|
|
||||||
pub struct OculusControllerRef<'a> {
|
pub struct OculusControllerRef<'a> {
|
||||||
oculus_controller: &'a OculusController,
|
oculus_controller: &'a OculusController,
|
||||||
instance: &'a Instance,
|
action_sets: &'a ActionSets,
|
||||||
session: &'a Session<AnyGraphics>,
|
session: &'a Session<AnyGraphics>,
|
||||||
frame_state: &'a FrameState,
|
frame_state: &'a FrameState,
|
||||||
xr_input: &'a XrInput,
|
xr_input: &'a XrInput,
|
||||||
@@ -58,11 +100,11 @@ pub fn subaction_path(hand: Hand) -> Path {
|
|||||||
impl OculusControllerRef<'_> {
|
impl OculusControllerRef<'_> {
|
||||||
pub fn grip_space(&self, hand: Hand) -> (SpaceLocation, SpaceVelocity) {
|
pub fn grip_space(&self, hand: Hand) -> (SpaceLocation, SpaceVelocity) {
|
||||||
match hand {
|
match hand {
|
||||||
Hand::Left => self.oculus_controller.grip_space.left.relate(
|
Hand::Left => self.oculus_controller.grip_space.as_ref().unwrap().left.relate(
|
||||||
&self.xr_input.stage,
|
&self.xr_input.stage,
|
||||||
self.frame_state.predicted_display_time,
|
self.frame_state.predicted_display_time,
|
||||||
),
|
),
|
||||||
Hand::Right => self.oculus_controller.grip_space.right.relate(
|
Hand::Right => self.oculus_controller.grip_space.as_ref().unwrap().right.relate(
|
||||||
&self.xr_input.stage,
|
&self.xr_input.stage,
|
||||||
self.frame_state.predicted_display_time,
|
self.frame_state.predicted_display_time,
|
||||||
),
|
),
|
||||||
@@ -71,11 +113,11 @@ impl OculusControllerRef<'_> {
|
|||||||
}
|
}
|
||||||
pub fn aim_space(&self, hand: Hand) -> (SpaceLocation, SpaceVelocity) {
|
pub fn aim_space(&self, hand: Hand) -> (SpaceLocation, SpaceVelocity) {
|
||||||
match hand {
|
match hand {
|
||||||
Hand::Left => self.oculus_controller.aim_space.left.relate(
|
Hand::Left => self.oculus_controller.aim_space.as_ref().unwrap().left.relate(
|
||||||
&self.xr_input.stage,
|
&self.xr_input.stage,
|
||||||
self.frame_state.predicted_display_time,
|
self.frame_state.predicted_display_time,
|
||||||
),
|
),
|
||||||
Hand::Right => self.oculus_controller.aim_space.right.relate(
|
Hand::Right => self.oculus_controller.aim_space.as_ref().unwrap().right.relate(
|
||||||
&self.xr_input.stage,
|
&self.xr_input.stage,
|
||||||
self.frame_state.predicted_display_time,
|
self.frame_state.predicted_display_time,
|
||||||
),
|
),
|
||||||
@@ -83,102 +125,107 @@ impl OculusControllerRef<'_> {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
pub fn squeeze(&self, hand: Hand) -> f32 {
|
pub fn squeeze(&self, hand: Hand) -> f32 {
|
||||||
let action = &self.oculus_controller.squeeze;
|
let action = &self
|
||||||
|
.action_sets
|
||||||
|
.get_action_f32("oculus_input", "squeeze")
|
||||||
|
.unwrap();
|
||||||
action
|
action
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn trigger(&self, hand: Hand) -> f32 {
|
pub fn trigger(&self, hand: Hand) -> f32 {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.trigger
|
.get_action_f32("oculus_input", "trigger")
|
||||||
.inner
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn trigger_touched(&self, hand: Hand) -> bool {
|
pub fn trigger_touched(&self, hand: Hand) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.trigger
|
.get_action_bool("oculus_input", "trigger_touched")
|
||||||
.touch
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn x_button(&self) -> bool {
|
pub fn x_button(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.x_button
|
.get_action_bool("oculus_input", "x_button")
|
||||||
.inner
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn x_button_touched(&self) -> bool {
|
pub fn x_button_touched(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.x_button
|
.get_action_bool("oculus_input", "x_button_touch")
|
||||||
.touch
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn y_button(&self) -> bool {
|
pub fn y_button(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.y_button
|
.get_action_bool("oculus_input", "y_button")
|
||||||
.inner
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn y_button_touched(&self) -> bool {
|
pub fn y_button_touched(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.y_button
|
.get_action_bool("oculus_input", "y_button_touch")
|
||||||
.touch
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn menu_button(&self) -> bool {
|
pub fn menu_button(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.menu_button
|
.get_action_bool("oculus_input", "menu_button")
|
||||||
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn a_button(&self) -> bool {
|
pub fn a_button(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.a_button
|
.get_action_bool("oculus_input", "a_button")
|
||||||
.inner
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn a_button_touched(&self) -> bool {
|
pub fn a_button_touched(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.a_button
|
.get_action_bool("oculus_input", "a_button_touch")
|
||||||
.touch
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn b_button(&self) -> bool {
|
pub fn b_button(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.b_button
|
.get_action_bool("oculus_input", "b_button")
|
||||||
.inner
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn b_button_touched(&self) -> bool {
|
pub fn b_button_touched(&self) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.b_button
|
.get_action_bool("oculus_input", "b_button_touch")
|
||||||
.touch
|
.unwrap()
|
||||||
.state(&self.session, Path::NULL)
|
.state(&self.session, Path::NULL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
}
|
}
|
||||||
pub fn thumbstick_touch(&self, hand: Hand) -> bool {
|
pub fn thumbstick_touch(&self, hand: Hand) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.thumbstick_touch
|
.get_action_bool("oculus_input", "thumbstick_touch")
|
||||||
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
@@ -186,28 +233,32 @@ impl OculusControllerRef<'_> {
|
|||||||
pub fn thumbstick(&self, hand: Hand) -> Thumbstick {
|
pub fn thumbstick(&self, hand: Hand) -> Thumbstick {
|
||||||
Thumbstick {
|
Thumbstick {
|
||||||
x: self
|
x: self
|
||||||
.oculus_controller
|
.action_sets
|
||||||
.thumbstick_x
|
.get_action_f32("oculus_input", "thumbstick_x")
|
||||||
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state,
|
.current_state,
|
||||||
y: self
|
y: self
|
||||||
.oculus_controller
|
.action_sets
|
||||||
.thumbstick_y
|
.get_action_f32("oculus_input", "thumbstick_y")
|
||||||
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state,
|
.current_state,
|
||||||
click: self
|
click: self
|
||||||
.oculus_controller
|
.action_sets
|
||||||
.thumbstick_click
|
.get_action_bool("oculus_input", "thumbstick_click")
|
||||||
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state,
|
.current_state,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn thumbrest_touch(&self, hand: Hand) -> bool {
|
pub fn thumbrest_touch(&self, hand: Hand) -> bool {
|
||||||
self.oculus_controller
|
self.action_sets
|
||||||
.thumbrest_touch
|
.get_action_bool("oculus_input", "thumbrest_touch")
|
||||||
|
.unwrap()
|
||||||
.state(&self.session, subaction_path(hand))
|
.state(&self.session, subaction_path(hand))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_state
|
.current_state
|
||||||
@@ -224,244 +275,197 @@ pub struct Thumbstick {
|
|||||||
impl OculusController {
|
impl OculusController {
|
||||||
pub fn get_ref<'a>(
|
pub fn get_ref<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
instance: &'a Instance,
|
|
||||||
session: &'a Session<AnyGraphics>,
|
session: &'a Session<AnyGraphics>,
|
||||||
frame_state: &'a FrameState,
|
frame_state: &'a FrameState,
|
||||||
xr_input: &'a XrInput,
|
xr_input: &'a XrInput,
|
||||||
|
action_sets: &'a ActionSets,
|
||||||
) -> OculusControllerRef {
|
) -> OculusControllerRef {
|
||||||
OculusControllerRef {
|
OculusControllerRef {
|
||||||
oculus_controller: self,
|
oculus_controller: self,
|
||||||
instance,
|
|
||||||
session,
|
session,
|
||||||
frame_state,
|
frame_state,
|
||||||
xr_input,
|
xr_input,
|
||||||
|
action_sets,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct OculusController {
|
pub struct OculusController {
|
||||||
pub grip_space: Handed<Space>,
|
pub grip_space: Option<Handed<Space>>,
|
||||||
pub aim_space: Handed<Space>,
|
pub aim_space: Option<Handed<Space>>,
|
||||||
pub grip_pose: Action<Posef>,
|
|
||||||
pub aim_pose: Action<Posef>,
|
|
||||||
pub squeeze: Action<f32>,
|
|
||||||
pub trigger: Touchable<f32>,
|
|
||||||
pub haptic_feedback: Action<Haptic>,
|
|
||||||
pub x_button: Touchable<bool>,
|
|
||||||
pub y_button: Touchable<bool>,
|
|
||||||
pub menu_button: Action<bool>,
|
|
||||||
pub a_button: Touchable<bool>,
|
|
||||||
pub b_button: Touchable<bool>,
|
|
||||||
pub thumbstick_x: Action<f32>,
|
|
||||||
pub thumbstick_y: Action<f32>,
|
|
||||||
pub thumbstick_touch: Action<bool>,
|
|
||||||
pub thumbstick_click: Action<bool>,
|
|
||||||
pub thumbrest_touch: Action<bool>,
|
|
||||||
}
|
}
|
||||||
impl OculusController {
|
impl OculusController {
|
||||||
pub fn new(
|
pub fn new(mut action_sets: ResMut<SetupActionSets>) -> anyhow::Result<Self> {
|
||||||
instance: Instance,
|
|
||||||
session: Session<AnyGraphics>,
|
|
||||||
action_sets: &mut Vec<ActionSet>,
|
|
||||||
) -> anyhow::Result<Self> {
|
|
||||||
let action_set =
|
let action_set =
|
||||||
instance.create_action_set("oculus_input", "Oculus Touch Controller Input", 0)?;
|
action_sets.add_action_set("oculus_input", "Oculus Touch Controller Input", 0);
|
||||||
init_subaction_path(&instance);
|
action_set.new_action(
|
||||||
let left_path = instance.string_to_path("/user/hand/left").unwrap();
|
"hand_pose",
|
||||||
let right_path = instance.string_to_path("/user/hand/right").unwrap();
|
"Hand Pose",
|
||||||
let hands = [left_path, right_path];
|
ActionType::PoseF,
|
||||||
let grip_pose = action_set.create_action::<Posef>("hand_pose", "Hand Pose", &hands)?;
|
ActionHandednes::Double,
|
||||||
let aim_pose = action_set.create_action::<Posef>("pointer_pose", "Pointer Pose", &hands)?;
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"pointer_pose",
|
||||||
|
"Pointer Pose",
|
||||||
|
ActionType::PoseF,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"squeeze",
|
||||||
|
"Grip Pull",
|
||||||
|
ActionType::F32,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"trigger",
|
||||||
|
"Trigger Pull",
|
||||||
|
ActionType::F32,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"trigger_touched",
|
||||||
|
"Trigger Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"haptic_feedback",
|
||||||
|
"Haptic Feedback",
|
||||||
|
ActionType::Haptic,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"x_button",
|
||||||
|
"X Button",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"x_button_touch",
|
||||||
|
"X Button Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"y_button",
|
||||||
|
"Y Button",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"y_button_touch",
|
||||||
|
"Y Button Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"a_button",
|
||||||
|
"A Button",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"a_button_touch",
|
||||||
|
"A Button Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"b_button",
|
||||||
|
"B Button",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"b_button_touch",
|
||||||
|
"B Button Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"menu_button",
|
||||||
|
"Menu Button",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Single,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"thumbstick_x",
|
||||||
|
"Thumbstick X",
|
||||||
|
ActionType::F32,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"thumbstick_y",
|
||||||
|
"Thumbstick y",
|
||||||
|
ActionType::F32,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"thumbstick_touch",
|
||||||
|
"Thumbstick Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"thumbstick_click",
|
||||||
|
"Thumbstick Click",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
action_set.new_action(
|
||||||
|
"thumbrest_touch",
|
||||||
|
"Thumbrest Touch",
|
||||||
|
ActionType::Bool,
|
||||||
|
ActionHandednes::Double,
|
||||||
|
);
|
||||||
|
|
||||||
let this = OculusController {
|
let this = OculusController {
|
||||||
grip_space: Handed {
|
grip_space: None,
|
||||||
left: grip_pose.create_space(session.clone(), left_path, Posef::IDENTITY)?,
|
aim_space: None,
|
||||||
right: grip_pose.create_space(session.clone(), right_path, Posef::IDENTITY)?,
|
|
||||||
},
|
|
||||||
aim_space: Handed {
|
|
||||||
left: aim_pose.create_space(session.clone(), left_path, Posef::IDENTITY)?,
|
|
||||||
right: aim_pose.create_space(session.clone(), right_path, Posef::IDENTITY)?,
|
|
||||||
},
|
|
||||||
grip_pose,
|
|
||||||
aim_pose,
|
|
||||||
squeeze: action_set.create_action("squeeze", "Grip Pull", &hands)?,
|
|
||||||
trigger: Touchable {
|
|
||||||
inner: action_set.create_action("trigger", "Trigger Pull", &hands)?,
|
|
||||||
touch: action_set.create_action("trigger_touched", "Trigger Touch", &hands)?,
|
|
||||||
},
|
|
||||||
haptic_feedback: action_set.create_action(
|
|
||||||
"haptic_feedback",
|
|
||||||
"Haptic Feedback",
|
|
||||||
&hands,
|
|
||||||
)?,
|
|
||||||
x_button: Touchable {
|
|
||||||
inner: action_set.create_action("x_button", "X Button", &[])?,
|
|
||||||
touch: action_set.create_action("x_button_touch", "X Button Touch", &[])?,
|
|
||||||
},
|
|
||||||
y_button: Touchable {
|
|
||||||
inner: action_set.create_action("y_button", "Y Button", &[])?,
|
|
||||||
touch: action_set.create_action("y_button_touch", "Y Button Touch", &[])?,
|
|
||||||
},
|
|
||||||
menu_button: action_set.create_action("menu_button", "Menu Button", &[])?,
|
|
||||||
a_button: Touchable {
|
|
||||||
inner: action_set.create_action("a_button", "A Button", &[])?,
|
|
||||||
touch: action_set.create_action("a_button_touch", "A Button Touch", &[])?,
|
|
||||||
},
|
|
||||||
b_button: Touchable {
|
|
||||||
inner: action_set.create_action("b_button", "B Button", &[])?,
|
|
||||||
touch: action_set.create_action("b_button_touch", "B Button Touch", &[])?,
|
|
||||||
},
|
|
||||||
thumbstick_x: action_set.create_action("thumbstick_x", "Thumbstick X", &hands)?,
|
|
||||||
thumbstick_y: action_set.create_action("thumbstick_y", "Thumbstick Y", &hands)?,
|
|
||||||
thumbstick_touch: action_set.create_action(
|
|
||||||
"thumbstick_touch",
|
|
||||||
"Thumbstick Touch",
|
|
||||||
&hands,
|
|
||||||
)?,
|
|
||||||
thumbstick_click: action_set.create_action(
|
|
||||||
"thumbstick_click",
|
|
||||||
"Thumbstick Click",
|
|
||||||
&hands,
|
|
||||||
)?,
|
|
||||||
thumbrest_touch: action_set.create_action(
|
|
||||||
"thumbrest_touch",
|
|
||||||
"Thumbrest Touch",
|
|
||||||
&hands,
|
|
||||||
)?,
|
|
||||||
};
|
};
|
||||||
let i = instance;
|
action_set.suggest_binding(
|
||||||
i.suggest_interaction_profile_bindings(
|
"/interaction_profiles/oculus/touch_controller",
|
||||||
i.string_to_path("/interaction_profiles/oculus/touch_controller")?,
|
|
||||||
&[
|
&[
|
||||||
Binding::new(
|
XrBinding::new("hand_pose", "/user/hand/left/input/grip/pose"),
|
||||||
&this.grip_pose,
|
XrBinding::new("hand_pose", "/user/hand/right/input/grip/pose"),
|
||||||
i.string_to_path("/user/hand/left/input/grip/pose")?,
|
XrBinding::new("pointer_pose", "/user/hand/left/input/aim/pose"),
|
||||||
|
XrBinding::new("pointer_pose", "/user/hand/right/input/aim/pose"),
|
||||||
|
XrBinding::new("squeeze", "/user/hand/left/input/squeeze/value"),
|
||||||
|
XrBinding::new("squeeze", "/user/hand/right/input/squeeze/value"),
|
||||||
|
XrBinding::new("trigger", "/user/hand/left/input/trigger/value"),
|
||||||
|
XrBinding::new("trigger", "/user/hand/right/input/trigger/value"),
|
||||||
|
XrBinding::new("trigger_touched", "/user/hand/left/input/trigger/touch"),
|
||||||
|
XrBinding::new("trigger_touched", "/user/hand/right/input/trigger/touch"),
|
||||||
|
XrBinding::new("haptic_feedback", "/user/hand/left/output/haptic"),
|
||||||
|
XrBinding::new("haptic_feedback", "/user/hand/right/output/haptic"),
|
||||||
|
XrBinding::new("x_button", "/user/hand/left/input/x/click"),
|
||||||
|
XrBinding::new("x_button_touch", "/user/hand/left/input/x/touch"),
|
||||||
|
XrBinding::new("y_button", "/user/hand/left/input/y/click"),
|
||||||
|
XrBinding::new("y_button_touch", "/user/hand/left/input/y/touch"),
|
||||||
|
XrBinding::new("a_button", "/user/hand/right/input/a/click"),
|
||||||
|
XrBinding::new("a_button_touch", "/user/hand/right/input/a/touch"),
|
||||||
|
XrBinding::new("b_button", "/user/hand/right/input/b/click"),
|
||||||
|
XrBinding::new("b_button_touch", "/user/hand/right/input/b/touch"),
|
||||||
|
XrBinding::new("menu_button", "/user/hand/left/input/menu/click"),
|
||||||
|
XrBinding::new("thumbstick_x", "/user/hand/left/input/thumbstick/x"),
|
||||||
|
XrBinding::new("thumbstick_y", "/user/hand/left/input/thumbstick/y"),
|
||||||
|
XrBinding::new("thumbstick_x", "/user/hand/right/input/thumbstick/x"),
|
||||||
|
XrBinding::new("thumbstick_y", "/user/hand/right/input/thumbstick/y"),
|
||||||
|
XrBinding::new("thumbstick_click", "/user/hand/left/input/thumbstick/click"),
|
||||||
|
XrBinding::new(
|
||||||
|
"thumbstick_click",
|
||||||
|
"/user/hand/right/input/thumbstick/click",
|
||||||
),
|
),
|
||||||
Binding::new(
|
XrBinding::new("thumbstick_touch", "/user/hand/left/input/thumbstick/touch"),
|
||||||
&this.grip_pose,
|
XrBinding::new(
|
||||||
i.string_to_path("/user/hand/right/input/grip/pose")?,
|
"thumbstick_touch",
|
||||||
),
|
"/user/hand/right/input/thumbstick/touch",
|
||||||
Binding::new(
|
|
||||||
&this.aim_pose,
|
|
||||||
i.string_to_path("/user/hand/left/input/aim/pose")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.aim_pose,
|
|
||||||
i.string_to_path("/user/hand/left/input/aim/pose")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.squeeze,
|
|
||||||
i.string_to_path("/user/hand/left/input/squeeze/value")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.squeeze,
|
|
||||||
i.string_to_path("/user/hand/right/input/squeeze/value")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.trigger.inner,
|
|
||||||
i.string_to_path("/user/hand/right/input/trigger/value")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.trigger.inner,
|
|
||||||
i.string_to_path("/user/hand/left/input/trigger/value")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.trigger.touch,
|
|
||||||
i.string_to_path("/user/hand/right/input/trigger/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.trigger.touch,
|
|
||||||
i.string_to_path("/user/hand/left/input/trigger/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.haptic_feedback,
|
|
||||||
i.string_to_path("/user/hand/right/output/haptic")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.haptic_feedback,
|
|
||||||
i.string_to_path("/user/hand/left/output/haptic")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.x_button.inner,
|
|
||||||
i.string_to_path("/user/hand/left/input/x/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.x_button.touch,
|
|
||||||
i.string_to_path("/user/hand/left/input/x/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.y_button.inner,
|
|
||||||
i.string_to_path("/user/hand/left/input/y/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.y_button.touch,
|
|
||||||
i.string_to_path("/user/hand/left/input/y/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.menu_button,
|
|
||||||
i.string_to_path("/user/hand/left/input/menu/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.a_button.inner,
|
|
||||||
i.string_to_path("/user/hand/right/input/a/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.a_button.touch,
|
|
||||||
i.string_to_path("/user/hand/right/input/a/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.b_button.inner,
|
|
||||||
i.string_to_path("/user/hand/right/input/b/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.b_button.touch,
|
|
||||||
i.string_to_path("/user/hand/right/input/b/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_x,
|
|
||||||
i.string_to_path("/user/hand/left/input/thumbstick/x")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_x,
|
|
||||||
i.string_to_path("/user/hand/right/input/thumbstick/x")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_y,
|
|
||||||
i.string_to_path("/user/hand/left/input/thumbstick/y")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_y,
|
|
||||||
i.string_to_path("/user/hand/right/input/thumbstick/y")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_click,
|
|
||||||
i.string_to_path("/user/hand/left/input/thumbstick/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_click,
|
|
||||||
i.string_to_path("/user/hand/right/input/thumbstick/click")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_touch,
|
|
||||||
i.string_to_path("/user/hand/left/input/thumbstick/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbstick_touch,
|
|
||||||
i.string_to_path("/user/hand/right/input/thumbstick/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbrest_touch,
|
|
||||||
i.string_to_path("/user/hand/left/input/thumbrest/touch")?,
|
|
||||||
),
|
|
||||||
Binding::new(
|
|
||||||
&this.thumbrest_touch,
|
|
||||||
i.string_to_path("/user/hand/right/input/thumbrest/touch")?,
|
|
||||||
),
|
),
|
||||||
|
XrBinding::new("thumbrest_touch", "/user/hand/left/input/thumbrest/touch"),
|
||||||
|
XrBinding::new("thumbrest_touch", "/user/hand/right/input/thumbrest/touch"),
|
||||||
],
|
],
|
||||||
)?;
|
);
|
||||||
|
|
||||||
action_sets.push(action_set);
|
|
||||||
Ok(this)
|
Ok(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
oculus_touch::OculusController, trackers::OpenXRTrackingRoot, Hand, QuatConv, Vec3Conv,
|
actions::ActionSets, oculus_touch::OculusController, trackers::OpenXRTrackingRoot, Hand,
|
||||||
|
QuatConv, Vec3Conv,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum LocomotionType {
|
pub enum LocomotionType {
|
||||||
@@ -67,6 +68,7 @@ pub fn proto_locomotion(
|
|||||||
views: ResMut<XrViews>,
|
views: ResMut<XrViews>,
|
||||||
mut gizmos: Gizmos,
|
mut gizmos: Gizmos,
|
||||||
config_option: Option<ResMut<PrototypeLocomotionConfig>>,
|
config_option: Option<ResMut<PrototypeLocomotionConfig>>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
match config_option {
|
match config_option {
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
@@ -80,7 +82,7 @@ pub fn proto_locomotion(
|
|||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
let root = tracking_root_query.get_single_mut();
|
let root = tracking_root_query.get_single_mut();
|
||||||
match root {
|
match root {
|
||||||
Ok(mut position) => {
|
Ok(mut position) => {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
resources::{XrFrameState, XrInstance, XrSession},
|
resources::{XrFrameState, XrInstance, XrSession},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{oculus_touch::OculusController, Hand, QuatConv, Vec3Conv};
|
use super::{actions::ActionSets, oculus_touch::OculusController, Hand, QuatConv, Vec3Conv};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct OpenXRTrackingRoot;
|
pub struct OpenXRTrackingRoot;
|
||||||
@@ -62,14 +62,14 @@ pub fn update_open_xr_controllers(
|
|||||||
Without<OpenXRLeftController>,
|
Without<OpenXRLeftController>,
|
||||||
)>,
|
)>,
|
||||||
frame_state: Res<XrFrameState>,
|
frame_state: Res<XrFrameState>,
|
||||||
instance: Res<XrInstance>,
|
|
||||||
xr_input: Res<XrInput>,
|
xr_input: Res<XrInput>,
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
|
action_sets: Res<ActionSets>,
|
||||||
) {
|
) {
|
||||||
//lock dat frame?
|
//lock dat frame?
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&instance, &session, &frame_state, &xr_input);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
//get left controller
|
//get left controller
|
||||||
let left_grip_space = controller.grip_space(Hand::Left);
|
let left_grip_space = controller.grip_space(Hand::Left);
|
||||||
let left_aim_space = controller.aim_space(Hand::Left);
|
let left_aim_space = controller.aim_space(Hand::Left);
|
||||||
|
|||||||
Reference in New Issue
Block a user