diff --git a/Cargo.toml b/Cargo.toml index c5d43ba..40375d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ hostname = { version = "0.4.0" } trust-dns-resolver = { version = "0.23.2" } openxr = { version = "0.19.0", default-features = false, features = ["static"] } openvr = { version = "0.7.0" } -sdl3 = { version = "0.14.19" } +sdl3 = { version = "0.14.20" } syn = { version = "2.0.67", features = ["extra-traits", "full"] } quote = "1.0.35" proc-macro2 = "1.0.86" diff --git a/presentation/src/input/controller.rs b/presentation/src/input/controller.rs index c27529f..b3dbea3 100644 --- a/presentation/src/input/controller.rs +++ b/presentation/src/input/controller.rs @@ -55,32 +55,28 @@ impl Controller { id: u32, deadzones: ControllerDeadzones, ) -> Result { - if controller_subsystem.is_game_controller(id) { - let sdl2_controller = controller_subsystem.open(id)?; + let sdl2_controller = controller_subsystem.open(id)?; - let controller_axis = ControllerAxis::default(); + let controller_axis = ControllerAxis::default(); - Ok(Controller { - name: sdl2_controller.name(), - id, + Ok(Controller { + name: sdl2_controller.name().unwrap_or_default(), + id, - _sdl2_controller: sdl2_controller, + _sdl2_controller: sdl2_controller, - controller_axis, + controller_axis, - last_direction: GuiDirection::None, + last_direction: GuiDirection::None, - updated_left_trigger: false, - last_left_trigger: false, + updated_left_trigger: false, + last_left_trigger: false, - updated_right_trigger: false, - last_right_trigger: false, + updated_right_trigger: false, + last_right_trigger: false, - deadzones, - }) - } else { - Err(anyhow::Error::msg("Not a game controller")) - } + deadzones, + }) } pub fn name(&self) -> &String { diff --git a/presentation/src/input/eventsystem.rs b/presentation/src/input/eventsystem.rs index c41d6c2..aa5360d 100644 --- a/presentation/src/input/eventsystem.rs +++ b/presentation/src/input/eventsystem.rs @@ -40,6 +40,10 @@ fn convert_button(button: Button) -> ControllerButton { Button::RightStick => ControllerButton::RightStick, Button::Misc1 => ControllerButton::Misc, + Button::Misc2 => todo!(), + Button::Misc3 => todo!(), + Button::Misc4 => todo!(), + Button::Misc5 => todo!(), Button::RightPaddle1 => ControllerButton::Paddle1, Button::RightPaddle2 => ControllerButton::Paddle2, @@ -116,20 +120,15 @@ impl EventSystem { .joysticks() .map_err(|s| anyhow::Error::msg(s))? .into_iter() - .map(|instance| { - Ok(( - instance.id, - Joystick::new(&event_system.joystick_subsystem, instance)?, - )) - }) + .map(|id| Ok((id, Joystick::new(&event_system.joystick_subsystem, id)?))) .collect::>>()?; - event_system.connected_controllers = (0..event_system + event_system.connected_controllers = event_system .controller_subsystem - .num_gamepads() - .map_err(|s| anyhow::Error::msg(s))?) + .gamepads() + .map_err(|s| anyhow::Error::msg(s))? .into_iter() - .filter(|i| event_system.controller_subsystem.is_game_controller(*i)) + // .filter(|i| event_system.controller_subsystem.is_game_controller(*i)) .map(|i| { Ok(( i, @@ -337,7 +336,7 @@ impl EventSystem { .joysticks() .map_err(|_| anyhow!("failed querying joysticks"))? .into_iter() - .find(|instance| instance.id == which) + .find(|id| *id == which) { let joystick = Joystick::new(&self.joystick_subsystem, joystick_instance)?; diff --git a/presentation/src/input/joystick.rs b/presentation/src/input/joystick.rs index 28c041d..3d7ef59 100644 --- a/presentation/src/input/joystick.rs +++ b/presentation/src/input/joystick.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use sdl3::{JoystickSubsystem, joystick::JoystickInstance}; +use sdl3::{JoystickSubsystem, joystick::JoystickId}; pub struct Joystick { sdl2_joystick: sdl3::joystick::Joystick, @@ -8,8 +8,8 @@ pub struct Joystick { } impl Joystick { - pub fn new(joystick_subsystem: &JoystickSubsystem, instance: JoystickInstance) -> Result { - let sdl2_joystick = joystick_subsystem.open(instance)?; + pub fn new(joystick_subsystem: &JoystickSubsystem, id: JoystickId) -> Result { + let sdl2_joystick = joystick_subsystem.open(id)?; Ok(Self { name: sdl2_joystick.name(), @@ -18,7 +18,7 @@ impl Joystick { } pub fn id(&self) -> u32 { - self.sdl2_joystick.instance_id() + self.sdl2_joystick.id() } pub fn name(&self) -> &str {