diff --git a/src/xr_input/actions.rs b/src/xr_input/actions.rs index 827464a5..f6d2a598 100644 --- a/src/xr_input/actions.rs +++ b/src/xr_input/actions.rs @@ -35,40 +35,40 @@ pub fn setup_oxr_actions(world: &mut World) { while let Some((set_name, set)) = a_iter.next() { let mut actions: HashMap<&'static str, TypedAction> = default(); let oxr_action_set = instance - .create_action_set(set_name, set.pretty_name, set.priority) + .create_action_set(set_name, &set.pretty_name, set.priority) .expect("Unable to create action set"); for (action_name, action) in set.actions.into_iter() { let typed_action = match action.action_type { ActionType::F32 => TypedAction::F32(match action.handednes { ActionHandednes::Single => oxr_action_set - .create_action(action_name, action.pretty_name, &[]) + .create_action(action_name, &action.pretty_name, &[]) .expect(&format!("Unable to create action: {}", action_name)), ActionHandednes::Double => oxr_action_set - .create_action(action_name, action.pretty_name, &hands) + .create_action(action_name, &action.pretty_name, &hands) .expect(&format!("Unable to create action: {}", action_name)), }), ActionType::Bool => TypedAction::Bool(match action.handednes { ActionHandednes::Single => oxr_action_set - .create_action(action_name, action.pretty_name, &[]) + .create_action(action_name, &action.pretty_name, &[]) .expect(&format!("Unable to create action: {}", action_name)), ActionHandednes::Double => oxr_action_set - .create_action(action_name, action.pretty_name, &hands) + .create_action(action_name, &action.pretty_name, &hands) .expect(&format!("Unable to create action: {}", action_name)), }), ActionType::PoseF => TypedAction::PoseF(match action.handednes { ActionHandednes::Single => oxr_action_set - .create_action(action_name, action.pretty_name, &[]) + .create_action(action_name, &action.pretty_name, &[]) .expect(&format!("Unable to create action: {}", action_name)), ActionHandednes::Double => oxr_action_set - .create_action(action_name, action.pretty_name, &hands) + .create_action(action_name, &action.pretty_name, &hands) .expect(&format!("Unable to create action: {}", action_name)), }), ActionType::Haptic => TypedAction::Haptic(match action.handednes { ActionHandednes::Single => oxr_action_set - .create_action(action_name, action.pretty_name, &[]) + .create_action(action_name, &action.pretty_name, &[]) .expect(&format!("Unable to create action: {}", action_name)), ActionHandednes::Double => oxr_action_set - .create_action(action_name, action.pretty_name, &hands) + .create_action(action_name, &action.pretty_name, &hands) .expect(&format!("Unable to create action: {}", action_name)), }), }; @@ -164,14 +164,14 @@ pub enum TypedAction { } pub struct SetupAction { - pretty_name: &'static str, + pretty_name: String, action_type: ActionType, handednes: ActionHandednes, bindings: HashMap<&'static str, Vec<&'static str>>, } pub struct SetupActionSet { - pretty_name: &'static str, + pretty_name: String, priority: u32, actions: HashMap<&'static str, SetupAction>, } @@ -180,7 +180,7 @@ impl SetupActionSet { pub fn new_action( &mut self, name: &'static str, - pretty_name: &'static str, + pretty_name: String, action_type: ActionType, handednes: ActionHandednes, ) { @@ -230,7 +230,7 @@ impl SetupActionSets { pub fn add_action_set( &mut self, name: &'static str, - pretty_name: &'static str, + pretty_name: String, priority: u32, ) -> &mut SetupActionSet { self.sets.insert( diff --git a/src/xr_input/hands/emulated.rs b/src/xr_input/hands/emulated.rs index a3423d28..ab1e6271 100644 --- a/src/xr_input/hands/emulated.rs +++ b/src/xr_input/hands/emulated.rs @@ -5,8 +5,8 @@ use openxr::{ActionTy, HandJoint}; use super::common::{get_bone_gizmo_style, HandBoneRadius}; use crate::{ - xr_init::{xr_only, XrSetup}, resources::{XrInstance, XrSession}, + xr_init::{xr_only, XrSetup}, xr_input::{ actions::{ ActionHandednes, ActionType, SetupActionSet, SetupActionSets, XrActionSets, XrBinding, @@ -28,10 +28,7 @@ pub struct HandEmulationPlugin; impl Plugin for HandEmulationPlugin { fn build(&self, app: &mut App) { - app.add_systems( - Update, - update_hand_skeleton_from_emulated.run_if(xr_only()), - ); + app.add_systems(Update, update_hand_skeleton_from_emulated.run_if(xr_only())); app.add_systems(XrSetup, setup_hand_emulation_action_set); } } @@ -39,54 +36,55 @@ impl Plugin for HandEmulationPlugin { const HAND_ACTION_SET: &str = "hand_pose_approx"; fn setup_hand_emulation_action_set(mut action_sets: ResMut) { - let mut action_set = action_sets.add_action_set(HAND_ACTION_SET, "Hand Pose Approximaiton", 0); + let action_set = + action_sets.add_action_set(HAND_ACTION_SET, "Hand Pose Approximaiton".into(), 0); action_set.new_action( "thumb_touch", - "Thumb Touched", + "Thumb Touched".into(), ActionType::Bool, ActionHandednes::Double, ); action_set.new_action( "thumb_x", - "Thumb X", + "Thumb X".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "thumb_y", - "Thumb Y", + "Thumb Y".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "index_touch", - "Index Finger Touched", + "Index Finger Touched".into(), ActionType::Bool, ActionHandednes::Double, ); action_set.new_action( "index_value", - "Index Finger Pull", + "Index Finger Pull".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "middle_value", - "Middle Finger Pull", + "Middle Finger Pull".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "ring_value", - "Ring Finger Pull", + "Ring Finger Pull".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "little_value", - "Little Finger Pull", + "Little Finger Pull".into(), ActionType::F32, ActionHandednes::Double, ); @@ -126,6 +124,7 @@ fn suggest_oculus_touch_profile(action_set: &mut SetupActionSet) { ); } +#[allow(clippy::type_complexity)] pub(crate) fn update_hand_skeleton_from_emulated( session: Res, instance: Res, @@ -546,5 +545,6 @@ fn get_bone_curl_angle(bone: HandJoint, curl: f32) -> f32 { _ => 1.0, }; let curl_angle = -((mul * curl * 80.0) + 5.0); + #[allow(clippy::needless_return)] return curl_angle; } diff --git a/src/xr_input/oculus_touch.rs b/src/xr_input/oculus_touch.rs index abd501f5..6d416bb0 100644 --- a/src/xr_input/oculus_touch.rs +++ b/src/xr_input/oculus_touch.rs @@ -305,124 +305,124 @@ pub struct OculusController { impl OculusController { pub fn new(mut action_sets: ResMut) -> anyhow::Result { let action_set = - action_sets.add_action_set("oculus_input", "Oculus Touch Controller Input", 0); + action_sets.add_action_set("oculus_input", "Oculus Touch Controller Input".into(), 0); action_set.new_action( "hand_pose", - "Hand Pose", + "Hand Pose".into(), ActionType::PoseF, ActionHandednes::Double, ); action_set.new_action( "pointer_pose", - "Pointer Pose", + "Pointer Pose".into(), ActionType::PoseF, ActionHandednes::Double, ); action_set.new_action( "squeeze", - "Grip Pull", + "Grip Pull".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "trigger", - "Trigger Pull", + "Trigger Pull".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "trigger_touched", - "Trigger Touch", + "Trigger Touch".into(), ActionType::Bool, ActionHandednes::Double, ); action_set.new_action( "haptic_feedback", - "Haptic Feedback", + "Haptic Feedback".into(), ActionType::Haptic, ActionHandednes::Double, ); action_set.new_action( "x_button", - "X Button", + "X Button".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "x_button_touch", - "X Button Touch", + "X Button Touch".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "y_button", - "Y Button", + "Y Button".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "y_button_touch", - "Y Button Touch", + "Y Button Touch".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "a_button", - "A Button", + "A Button".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "a_button_touch", - "A Button Touch", + "A Button Touch".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "b_button", - "B Button", + "B Button".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "b_button_touch", - "B Button Touch", + "B Button Touch".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "menu_button", - "Menu Button", + "Menu Button".into(), ActionType::Bool, ActionHandednes::Single, ); action_set.new_action( "thumbstick_x", - "Thumbstick X", + "Thumbstick X".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "thumbstick_y", - "Thumbstick y", + "Thumbstick y".into(), ActionType::F32, ActionHandednes::Double, ); action_set.new_action( "thumbstick_touch", - "Thumbstick Touch", + "Thumbstick Touch".into(), ActionType::Bool, ActionHandednes::Double, ); action_set.new_action( "thumbstick_click", - "Thumbstick Click", + "Thumbstick Click".into(), ActionType::Bool, ActionHandednes::Double, ); action_set.new_action( "thumbrest_touch", - "Thumbrest Touch", + "Thumbrest Touch".into(), ActionType::Bool, ActionHandednes::Double, );