Compare commits

..

2 commits

Author SHA1 Message Date
974f89a70a Update Rust crate ron to 0.9.0 2025-03-31 12:02:12 +00:00
Michael Huebner
d0a0e09bd8 Update sdl3 patch version 2025-03-31 13:48:46 +02:00
4 changed files with 29 additions and 34 deletions

View file

@ -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"

View file

@ -55,32 +55,28 @@ impl Controller {
id: u32,
deadzones: ControllerDeadzones,
) -> Result<Controller> {
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 {

View file

@ -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::<Result<HashMap<_, _>>>()?;
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)?;

View file

@ -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<Self> {
let sdl2_joystick = joystick_subsystem.open(instance)?;
pub fn new(joystick_subsystem: &JoystickSubsystem, id: JoystickId) -> Result<Self> {
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 {