Update sdl3 patch version

This commit is contained in:
Michael Huebner 2025-03-31 13:48:46 +02:00
parent 0adaffb27e
commit d0a0e09bd8
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" } trust-dns-resolver = { version = "0.23.2" }
openxr = { version = "0.19.0", default-features = false, features = ["static"] } openxr = { version = "0.19.0", default-features = false, features = ["static"] }
openvr = { version = "0.7.0" } openvr = { version = "0.7.0" }
sdl3 = { version = "0.14.19" } sdl3 = { version = "0.14.20" }
syn = { version = "2.0.67", features = ["extra-traits", "full"] } syn = { version = "2.0.67", features = ["extra-traits", "full"] }
quote = "1.0.35" quote = "1.0.35"
proc-macro2 = "1.0.86" proc-macro2 = "1.0.86"

View file

@ -55,32 +55,28 @@ impl Controller {
id: u32, id: u32,
deadzones: ControllerDeadzones, deadzones: ControllerDeadzones,
) -> Result<Controller> { ) -> 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 { Ok(Controller {
name: sdl2_controller.name(), name: sdl2_controller.name().unwrap_or_default(),
id, 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, updated_left_trigger: false,
last_left_trigger: false, last_left_trigger: false,
updated_right_trigger: false, updated_right_trigger: false,
last_right_trigger: false, last_right_trigger: false,
deadzones, deadzones,
}) })
} else {
Err(anyhow::Error::msg("Not a game controller"))
}
} }
pub fn name(&self) -> &String { pub fn name(&self) -> &String {

View file

@ -40,6 +40,10 @@ fn convert_button(button: Button) -> ControllerButton {
Button::RightStick => ControllerButton::RightStick, Button::RightStick => ControllerButton::RightStick,
Button::Misc1 => ControllerButton::Misc, Button::Misc1 => ControllerButton::Misc,
Button::Misc2 => todo!(),
Button::Misc3 => todo!(),
Button::Misc4 => todo!(),
Button::Misc5 => todo!(),
Button::RightPaddle1 => ControllerButton::Paddle1, Button::RightPaddle1 => ControllerButton::Paddle1,
Button::RightPaddle2 => ControllerButton::Paddle2, Button::RightPaddle2 => ControllerButton::Paddle2,
@ -116,20 +120,15 @@ impl EventSystem {
.joysticks() .joysticks()
.map_err(|s| anyhow::Error::msg(s))? .map_err(|s| anyhow::Error::msg(s))?
.into_iter() .into_iter()
.map(|instance| { .map(|id| Ok((id, Joystick::new(&event_system.joystick_subsystem, id)?)))
Ok((
instance.id,
Joystick::new(&event_system.joystick_subsystem, instance)?,
))
})
.collect::<Result<HashMap<_, _>>>()?; .collect::<Result<HashMap<_, _>>>()?;
event_system.connected_controllers = (0..event_system event_system.connected_controllers = event_system
.controller_subsystem .controller_subsystem
.num_gamepads() .gamepads()
.map_err(|s| anyhow::Error::msg(s))?) .map_err(|s| anyhow::Error::msg(s))?
.into_iter() .into_iter()
.filter(|i| event_system.controller_subsystem.is_game_controller(*i)) // .filter(|i| event_system.controller_subsystem.is_game_controller(*i))
.map(|i| { .map(|i| {
Ok(( Ok((
i, i,
@ -337,7 +336,7 @@ impl EventSystem {
.joysticks() .joysticks()
.map_err(|_| anyhow!("failed querying joysticks"))? .map_err(|_| anyhow!("failed querying joysticks"))?
.into_iter() .into_iter()
.find(|instance| instance.id == which) .find(|id| *id == which)
{ {
let joystick = Joystick::new(&self.joystick_subsystem, joystick_instance)?; let joystick = Joystick::new(&self.joystick_subsystem, joystick_instance)?;

View file

@ -1,5 +1,5 @@
use anyhow::Result; use anyhow::Result;
use sdl3::{JoystickSubsystem, joystick::JoystickInstance}; use sdl3::{JoystickSubsystem, joystick::JoystickId};
pub struct Joystick { pub struct Joystick {
sdl2_joystick: sdl3::joystick::Joystick, sdl2_joystick: sdl3::joystick::Joystick,
@ -8,8 +8,8 @@ pub struct Joystick {
} }
impl Joystick { impl Joystick {
pub fn new(joystick_subsystem: &JoystickSubsystem, instance: JoystickInstance) -> Result<Self> { pub fn new(joystick_subsystem: &JoystickSubsystem, id: JoystickId) -> Result<Self> {
let sdl2_joystick = joystick_subsystem.open(instance)?; let sdl2_joystick = joystick_subsystem.open(id)?;
Ok(Self { Ok(Self {
name: sdl2_joystick.name(), name: sdl2_joystick.name(),
@ -18,7 +18,7 @@ impl Joystick {
} }
pub fn id(&self) -> u32 { pub fn id(&self) -> u32 {
self.sdl2_joystick.instance_id() self.sdl2_joystick.id()
} }
pub fn name(&self) -> &str { pub fn name(&self) -> &str {