From fd6ae0c4ff0f9c79e235ad72f38420865b5cb245 Mon Sep 17 00:00:00 2001 From: Maia <66437537+maia-s@users.noreply.github.com> Date: Sun, 3 Nov 2024 01:39:01 +0100 Subject: [PATCH] update sdl3-sys to 0.1.1 (#38) --- Cargo.toml | 3 +-- src/sdl3/audio.rs | 2 +- src/sdl3/gamepad.rs | 6 +++--- src/sdl3/joystick.rs | 6 +++--- src/sdl3/raw_window_handle.rs | 2 +- src/sdl3/render.rs | 10 +++++----- src/sdl3/video.rs | 26 +++++++++++--------------- 7 files changed, 25 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14fc5fba9f..db5cfb9379 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,7 @@ libc = "0.2.92" lazy_static = "1.4.0" [dependencies.sdl3-sys] -# path = "sdl3-sys" -version = "0.0.10+SDL-preview-3.1.3" +version = "0.1.1" [dependencies.c_vec] # allow both 1.* and 2.0 versions diff --git a/src/sdl3/audio.rs b/src/sdl3/audio.rs index e17af73f8e..dd8a9e65a1 100644 --- a/src/sdl3/audio.rs +++ b/src/sdl3/audio.rs @@ -213,7 +213,7 @@ impl AudioSubsystem { } } -#[repr(i32)] +#[repr(u32)] #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)] pub enum AudioFormat { /// Unsigned 8-bit samples diff --git a/src/sdl3/gamepad.rs b/src/sdl3/gamepad.rs index b36cbca089..ce3131cbc8 100644 --- a/src/sdl3/gamepad.rs +++ b/src/sdl3/gamepad.rs @@ -537,7 +537,7 @@ impl Gamepad { let props = sys::gamepad::SDL_GetGamepadProperties(self.raw); sys::properties::SDL_GetBooleanProperty( props, - sys::gamepad::SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN.as_ptr(), + sys::gamepad::SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN, false, ) } @@ -548,7 +548,7 @@ impl Gamepad { let props = sys::gamepad::SDL_GetGamepadProperties(self.raw); sys::properties::SDL_GetBooleanProperty( props, - sys::gamepad::SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN.as_ptr(), + sys::gamepad::SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN, false, ) } @@ -559,7 +559,7 @@ impl Gamepad { let props = sys::gamepad::SDL_GetGamepadProperties(self.raw); sys::properties::SDL_GetBooleanProperty( props, - sys::gamepad::SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN.as_ptr(), + sys::gamepad::SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN, false, ) } diff --git a/src/sdl3/joystick.rs b/src/sdl3/joystick.rs index c8377fc357..c013f30e5a 100644 --- a/src/sdl3/joystick.rs +++ b/src/sdl3/joystick.rs @@ -401,7 +401,7 @@ impl Joystick { let props = unsafe { sys::joystick::SDL_GetJoystickProperties(self.raw) }; sys::properties::SDL_GetBooleanProperty( props, - sys::joystick::SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN.as_ptr(), + sys::joystick::SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, false, ) } @@ -412,7 +412,7 @@ impl Joystick { let props = unsafe { sys::joystick::SDL_GetJoystickProperties(self.raw) }; sys::properties::SDL_GetBooleanProperty( props, - sys::joystick::SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN.as_ptr(), + sys::joystick::SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, false, ) } @@ -423,7 +423,7 @@ impl Joystick { let props = unsafe { sys::joystick::SDL_GetJoystickProperties(self.raw) }; sys::properties::SDL_GetBooleanProperty( props, - sys::joystick::SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN.as_ptr(), + sys::joystick::SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, false, ) } diff --git a/src/sdl3/raw_window_handle.rs b/src/sdl3/raw_window_handle.rs index 3cc92627d0..fd58072858 100644 --- a/src/sdl3/raw_window_handle.rs +++ b/src/sdl3/raw_window_handle.rs @@ -42,7 +42,7 @@ unsafe impl HasRawWindowHandle for Window { handle.ns_window = SDL_GetPointerProperty( window_properties, - sys::video::SDL_PROP_WINDOW_COCOA_WINDOW_POINTER.as_ptr(), + sys::video::SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, std::ptr::null_mut(), ); diff --git a/src/sdl3/render.rs b/src/sdl3/render.rs index 773f14ed21..da75aa528b 100644 --- a/src/sdl3/render.rs +++ b/src/sdl3/render.rs @@ -1859,7 +1859,7 @@ impl InternalTexture { let format = unsafe { sys::properties::SDL_GetNumberProperty( self.get_properties(), - sys::render::SDL_PROP_TEXTURE_FORMAT_NUMBER.as_ptr(), + sys::render::SDL_PROP_TEXTURE_FORMAT_NUMBER, 0, ) }; @@ -1871,7 +1871,7 @@ impl InternalTexture { let access = unsafe { sys::properties::SDL_GetNumberProperty( self.get_properties(), - sys::render::SDL_PROP_TEXTURE_ACCESS_NUMBER.as_ptr(), + sys::render::SDL_PROP_TEXTURE_ACCESS_NUMBER, 0, ) }; @@ -1882,7 +1882,7 @@ impl InternalTexture { unsafe { sys::properties::SDL_GetNumberProperty( self.get_properties(), - sys::render::SDL_PROP_TEXTURE_WIDTH_NUMBER.as_ptr(), + sys::render::SDL_PROP_TEXTURE_WIDTH_NUMBER, 0, ) as u32 } @@ -1892,7 +1892,7 @@ impl InternalTexture { unsafe { sys::properties::SDL_GetNumberProperty( self.get_properties(), - sys::render::SDL_PROP_TEXTURE_HEIGHT_NUMBER.as_ptr(), + sys::render::SDL_PROP_TEXTURE_HEIGHT_NUMBER, 0, ) as u32 } @@ -2210,7 +2210,7 @@ impl InternalTexture { unsafe { sys::properties::SDL_GetNumberProperty( props_id, - sys::render::SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER.as_ptr(), + sys::render::SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER, 0, ) } diff --git a/src/sdl3/video.rs b/src/sdl3/video.rs index 93911291b5..0d4e143b11 100644 --- a/src/sdl3/video.rs +++ b/src/sdl3/video.rs @@ -223,7 +223,7 @@ pub mod gl_attr { macro_rules! gl_set_attribute { ($attr:ident, $value:expr) => {{ let result = - unsafe { sys::video::SDL_GL_SetAttribute(sys::video::SDL_GLattr::$attr, $value) }; + unsafe { sys::video::SDL_GL_SetAttribute(sys::video::SDL_GLAttr::$attr, $value) }; if result == false { // Panic and print the attribute that failed. @@ -240,7 +240,7 @@ pub mod gl_attr { ($attr:ident) => {{ let mut value = 0; let result = unsafe { - sys::video::SDL_GL_GetAttribute(sys::video::SDL_GLattr::$attr, &mut value) + sys::video::SDL_GL_GetAttribute(sys::video::SDL_GLAttr::$attr, &mut value) }; if result == false { // Panic and print the attribute that failed. @@ -814,8 +814,7 @@ impl VideoSubsystem { let mut result = Vec::with_capacity(num_modes as usize); for i in 0..num_modes { let mode = *modes.offset(i as isize); - let mode = *mode; - result.push(DisplayMode::from_ll(&mode)); + result.push(DisplayMode::from_ll(&*mode)); } SDL_free(modes as *mut c_void); Ok(result) @@ -830,8 +829,7 @@ impl VideoSubsystem { if raw_mode.is_null() { return Err(get_error()); } - let mode = *raw_mode; - Ok(DisplayMode::from_ll(&mode)) + Ok(DisplayMode::from_ll(&*raw_mode)) } } @@ -848,8 +846,7 @@ impl VideoSubsystem { if raw_mode.is_null() { return Err(get_error()); } - let mode = *raw_mode; - Ok(DisplayMode::from_ll(&mode)) + Ok(DisplayMode::from_ll(&*raw_mode)) } } @@ -1165,33 +1162,33 @@ impl WindowBuilder { let props = SDL_CreateProperties(); SDL_SetStringProperty( props, - sys::video::SDL_PROP_WINDOW_CREATE_TITLE_STRING.as_ptr(), + sys::video::SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.as_ptr(), ); if self.x != WindowPos::Undefined { SDL_SetNumberProperty( props, - sys::video::SDL_PROP_WINDOW_CREATE_X_NUMBER.as_ptr(), + sys::video::SDL_PROP_WINDOW_CREATE_X_NUMBER, to_ll_windowpos(self.x).into(), ); } if self.y != WindowPos::Undefined { SDL_SetNumberProperty( props, - sys::video::SDL_PROP_WINDOW_CREATE_Y_NUMBER.as_ptr(), + sys::video::SDL_PROP_WINDOW_CREATE_Y_NUMBER, to_ll_windowpos(self.y).into(), ); } SDL_SetNumberProperty( props, - sys::video::SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER.as_ptr(), + sys::video::SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, raw_width.into(), ); SDL_SetNumberProperty( props, - sys::video::SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER.as_ptr(), + sys::video::SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, raw_height.into(), ); let flags_cstr = CString::new("flags").unwrap(); @@ -1664,8 +1661,7 @@ impl Window { if mode_raw.is_null() { return None; } - let mode_raw = *mode_raw; - Some(DisplayMode::from_ll(&mode_raw)) + Some(DisplayMode::from_ll(&*mode_raw)) } }