mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Fix obsolete absolute paths
This commit is contained in:
+7
-6
@@ -66,6 +66,7 @@ use crate::get_error;
|
||||
use crate::rwops::RWops;
|
||||
|
||||
use crate::sys;
|
||||
use crate::sys::SDL_AudioStatus;
|
||||
|
||||
impl AudioSubsystem {
|
||||
/// Opens a new audio device given the desired parameters and callback.
|
||||
@@ -199,18 +200,18 @@ impl AudioFormat {
|
||||
#[repr(i32)]
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
pub enum AudioStatus {
|
||||
Stopped = sys::SDL_AudioStatus::SDL_AUDIO_STOPPED as i32,
|
||||
Playing = sys::SDL_AudioStatus::SDL_AUDIO_PLAYING as i32,
|
||||
Paused = sys::SDL_AudioStatus::SDL_AUDIO_PAUSED as i32,
|
||||
Stopped = SDL_AudioStatus::SDL_AUDIO_STOPPED as i32,
|
||||
Playing = SDL_AudioStatus::SDL_AUDIO_PLAYING as i32,
|
||||
Paused = SDL_AudioStatus::SDL_AUDIO_PAUSED as i32,
|
||||
}
|
||||
|
||||
impl FromPrimitive for AudioStatus {
|
||||
fn from_i64(n: i64) -> Option<AudioStatus> {
|
||||
use self::AudioStatus::*;
|
||||
|
||||
const STOPPED: i64 = sys::SDL_AudioStatus::SDL_AUDIO_STOPPED as i64;
|
||||
const PLAYING: i64 = sys::SDL_AudioStatus::SDL_AUDIO_PLAYING as i64;
|
||||
const PAUSED: i64 = sys::SDL_AudioStatus::SDL_AUDIO_PAUSED as i64;
|
||||
const STOPPED: i64 = SDL_AudioStatus::SDL_AUDIO_STOPPED as i64;
|
||||
const PLAYING: i64 = SDL_AudioStatus::SDL_AUDIO_PLAYING as i64;
|
||||
const PAUSED: i64 = SDL_AudioStatus::SDL_AUDIO_PAUSED as i64;
|
||||
|
||||
Some(match n {
|
||||
STOPPED => Stopped,
|
||||
|
||||
+11
-10
@@ -1,4 +1,5 @@
|
||||
use crate::sys;
|
||||
use crate::sys::SDL_bool;
|
||||
|
||||
pub const CACHELINESIZE: u8 = 128;
|
||||
|
||||
@@ -11,43 +12,43 @@ pub fn cpu_cache_line_size() -> i32 {
|
||||
}
|
||||
|
||||
pub fn has_rdtsc() -> bool {
|
||||
unsafe { sys::SDL_HasRDTSC() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasRDTSC() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_alti_vec() -> bool {
|
||||
unsafe { sys::SDL_HasAltiVec() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasAltiVec() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_mmx() -> bool {
|
||||
unsafe { sys::SDL_HasMMX() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasMMX() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_3d_now() -> bool {
|
||||
unsafe { sys::SDL_Has3DNow() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_Has3DNow() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_sse() -> bool {
|
||||
unsafe { sys::SDL_HasSSE() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasSSE() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_sse2() -> bool {
|
||||
unsafe { sys::SDL_HasSSE2() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasSSE2() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_sse3() -> bool {
|
||||
unsafe { sys::SDL_HasSSE3() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasSSE3() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_sse41() -> bool {
|
||||
unsafe { sys::SDL_HasSSE41() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasSSE41() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_sse42() -> bool {
|
||||
unsafe { sys::SDL_HasSSE42() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasSSE42() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn has_avx() -> bool {
|
||||
unsafe { sys::SDL_HasAVX() == sys::SDL_bool::SDL_TRUE }
|
||||
unsafe { sys::SDL_HasAVX() == SDL_bool::SDL_TRUE }
|
||||
}
|
||||
|
||||
pub fn system_ram() -> i32 {
|
||||
|
||||
+64
-63
@@ -28,6 +28,7 @@ use crate::keyboard::Scancode;
|
||||
use crate::get_error;
|
||||
|
||||
use crate::sys;
|
||||
use crate::sys::SDL_EventType;
|
||||
|
||||
struct CustomEventTypeMaps {
|
||||
sdl_id_to_type_id: HashMap<u32, ::std::any::TypeId>,
|
||||
@@ -91,8 +92,8 @@ impl crate::EventSubsystem {
|
||||
events_ptr,
|
||||
max_amount as c_int,
|
||||
sys::SDL_eventaction::SDL_PEEKEVENT,
|
||||
sys::SDL_EventType::SDL_FIRSTEVENT as u32,
|
||||
sys::SDL_EventType::SDL_LASTEVENT as u32
|
||||
SDL_EventType::SDL_FIRSTEVENT as u32,
|
||||
SDL_EventType::SDL_LASTEVENT as u32
|
||||
)
|
||||
};
|
||||
|
||||
@@ -264,56 +265,56 @@ impl crate::EventSubsystem {
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
#[repr(u32)]
|
||||
pub enum EventType {
|
||||
First = sys::SDL_EventType::SDL_FIRSTEVENT as u32,
|
||||
First = SDL_EventType::SDL_FIRSTEVENT as u32,
|
||||
|
||||
Quit = sys::SDL_EventType::SDL_QUIT as u32,
|
||||
AppTerminating = sys::SDL_EventType::SDL_APP_TERMINATING as u32,
|
||||
AppLowMemory = sys::SDL_EventType::SDL_APP_LOWMEMORY as u32,
|
||||
AppWillEnterBackground = sys::SDL_EventType::SDL_APP_WILLENTERBACKGROUND as u32,
|
||||
AppDidEnterBackground = sys::SDL_EventType::SDL_APP_DIDENTERBACKGROUND as u32,
|
||||
AppWillEnterForeground = sys::SDL_EventType::SDL_APP_WILLENTERFOREGROUND as u32,
|
||||
AppDidEnterForeground = sys::SDL_EventType::SDL_APP_DIDENTERFOREGROUND as u32,
|
||||
Quit = SDL_EventType::SDL_QUIT as u32,
|
||||
AppTerminating = SDL_EventType::SDL_APP_TERMINATING as u32,
|
||||
AppLowMemory = SDL_EventType::SDL_APP_LOWMEMORY as u32,
|
||||
AppWillEnterBackground = SDL_EventType::SDL_APP_WILLENTERBACKGROUND as u32,
|
||||
AppDidEnterBackground = SDL_EventType::SDL_APP_DIDENTERBACKGROUND as u32,
|
||||
AppWillEnterForeground = SDL_EventType::SDL_APP_WILLENTERFOREGROUND as u32,
|
||||
AppDidEnterForeground = SDL_EventType::SDL_APP_DIDENTERFOREGROUND as u32,
|
||||
|
||||
Window = sys::SDL_EventType::SDL_WINDOWEVENT as u32,
|
||||
Window = SDL_EventType::SDL_WINDOWEVENT as u32,
|
||||
// TODO: SysWM = sys::SDL_SYSWMEVENT as u32,
|
||||
|
||||
KeyDown = sys::SDL_EventType::SDL_KEYDOWN as u32,
|
||||
KeyUp = sys::SDL_EventType::SDL_KEYUP as u32,
|
||||
TextEditing = sys::SDL_EventType::SDL_TEXTEDITING as u32,
|
||||
TextInput = sys::SDL_EventType::SDL_TEXTINPUT as u32,
|
||||
KeyDown = SDL_EventType::SDL_KEYDOWN as u32,
|
||||
KeyUp = SDL_EventType::SDL_KEYUP as u32,
|
||||
TextEditing = SDL_EventType::SDL_TEXTEDITING as u32,
|
||||
TextInput = SDL_EventType::SDL_TEXTINPUT as u32,
|
||||
|
||||
MouseMotion = sys::SDL_EventType::SDL_MOUSEMOTION as u32,
|
||||
MouseButtonDown = sys::SDL_EventType::SDL_MOUSEBUTTONDOWN as u32,
|
||||
MouseButtonUp = sys::SDL_EventType::SDL_MOUSEBUTTONUP as u32,
|
||||
MouseWheel = sys::SDL_EventType::SDL_MOUSEWHEEL as u32,
|
||||
MouseMotion = SDL_EventType::SDL_MOUSEMOTION as u32,
|
||||
MouseButtonDown = SDL_EventType::SDL_MOUSEBUTTONDOWN as u32,
|
||||
MouseButtonUp = SDL_EventType::SDL_MOUSEBUTTONUP as u32,
|
||||
MouseWheel = SDL_EventType::SDL_MOUSEWHEEL as u32,
|
||||
|
||||
JoyAxisMotion = sys::SDL_EventType::SDL_JOYAXISMOTION as u32,
|
||||
JoyBallMotion = sys::SDL_EventType::SDL_JOYBALLMOTION as u32,
|
||||
JoyHatMotion = sys::SDL_EventType::SDL_JOYHATMOTION as u32,
|
||||
JoyButtonDown = sys::SDL_EventType::SDL_JOYBUTTONDOWN as u32,
|
||||
JoyButtonUp = sys::SDL_EventType::SDL_JOYBUTTONUP as u32,
|
||||
JoyDeviceAdded = sys::SDL_EventType::SDL_JOYDEVICEADDED as u32,
|
||||
JoyDeviceRemoved = sys::SDL_EventType::SDL_JOYDEVICEREMOVED as u32,
|
||||
JoyAxisMotion = SDL_EventType::SDL_JOYAXISMOTION as u32,
|
||||
JoyBallMotion = SDL_EventType::SDL_JOYBALLMOTION as u32,
|
||||
JoyHatMotion = SDL_EventType::SDL_JOYHATMOTION as u32,
|
||||
JoyButtonDown = SDL_EventType::SDL_JOYBUTTONDOWN as u32,
|
||||
JoyButtonUp = SDL_EventType::SDL_JOYBUTTONUP as u32,
|
||||
JoyDeviceAdded = SDL_EventType::SDL_JOYDEVICEADDED as u32,
|
||||
JoyDeviceRemoved = SDL_EventType::SDL_JOYDEVICEREMOVED as u32,
|
||||
|
||||
ControllerAxisMotion = sys::SDL_EventType::SDL_CONTROLLERAXISMOTION as u32,
|
||||
ControllerButtonDown = sys::SDL_EventType::SDL_CONTROLLERBUTTONDOWN as u32,
|
||||
ControllerButtonUp = sys::SDL_EventType::SDL_CONTROLLERBUTTONUP as u32,
|
||||
ControllerDeviceAdded = sys::SDL_EventType::SDL_CONTROLLERDEVICEADDED as u32,
|
||||
ControllerDeviceRemoved = sys::SDL_EventType::SDL_CONTROLLERDEVICEREMOVED as u32,
|
||||
ControllerDeviceRemapped = sys::SDL_EventType::SDL_CONTROLLERDEVICEREMAPPED as u32,
|
||||
ControllerAxisMotion = SDL_EventType::SDL_CONTROLLERAXISMOTION as u32,
|
||||
ControllerButtonDown = SDL_EventType::SDL_CONTROLLERBUTTONDOWN as u32,
|
||||
ControllerButtonUp = SDL_EventType::SDL_CONTROLLERBUTTONUP as u32,
|
||||
ControllerDeviceAdded = SDL_EventType::SDL_CONTROLLERDEVICEADDED as u32,
|
||||
ControllerDeviceRemoved = SDL_EventType::SDL_CONTROLLERDEVICEREMOVED as u32,
|
||||
ControllerDeviceRemapped = SDL_EventType::SDL_CONTROLLERDEVICEREMAPPED as u32,
|
||||
|
||||
FingerDown = sys::SDL_EventType::SDL_FINGERDOWN as u32,
|
||||
FingerUp = sys::SDL_EventType::SDL_FINGERUP as u32,
|
||||
FingerMotion = sys::SDL_EventType::SDL_FINGERMOTION as u32,
|
||||
DollarGesture = sys::SDL_EventType::SDL_DOLLARGESTURE as u32,
|
||||
DollarRecord = sys::SDL_EventType::SDL_DOLLARRECORD as u32,
|
||||
MultiGesture = sys::SDL_EventType::SDL_MULTIGESTURE as u32,
|
||||
FingerDown = SDL_EventType::SDL_FINGERDOWN as u32,
|
||||
FingerUp = SDL_EventType::SDL_FINGERUP as u32,
|
||||
FingerMotion = SDL_EventType::SDL_FINGERMOTION as u32,
|
||||
DollarGesture = SDL_EventType::SDL_DOLLARGESTURE as u32,
|
||||
DollarRecord = SDL_EventType::SDL_DOLLARRECORD as u32,
|
||||
MultiGesture = SDL_EventType::SDL_MULTIGESTURE as u32,
|
||||
|
||||
ClipboardUpdate = sys::SDL_EventType::SDL_CLIPBOARDUPDATE as u32,
|
||||
DropFile = sys::SDL_EventType::SDL_DROPFILE as u32,
|
||||
ClipboardUpdate = SDL_EventType::SDL_CLIPBOARDUPDATE as u32,
|
||||
DropFile = SDL_EventType::SDL_DROPFILE as u32,
|
||||
|
||||
User = sys::SDL_EventType::SDL_USEREVENT as u32,
|
||||
Last = sys::SDL_EventType::SDL_LASTEVENT as u32,
|
||||
User = SDL_EventType::SDL_USEREVENT as u32,
|
||||
Last = SDL_EventType::SDL_LASTEVENT as u32,
|
||||
}
|
||||
|
||||
impl FromPrimitive for EventType {
|
||||
@@ -766,7 +767,7 @@ impl Event {
|
||||
|
||||
Event::Quit{timestamp} => {
|
||||
let event = sys::SDL_QuitEvent {
|
||||
type_: sys::SDL_EventType::SDL_QUIT as u32,
|
||||
type_: SDL_EventType::SDL_QUIT as u32,
|
||||
timestamp: timestamp,
|
||||
};
|
||||
unsafe {
|
||||
@@ -782,7 +783,7 @@ impl Event {
|
||||
} => {
|
||||
let (win_event_id, data1, data2) = win_event.to_ll();
|
||||
let event = sys::SDL_WindowEvent {
|
||||
type_: sys::SDL_EventType::SDL_WINDOWEVENT as u32,
|
||||
type_: SDL_EventType::SDL_WINDOWEVENT as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
event: win_event_id,
|
||||
@@ -808,7 +809,7 @@ impl Event {
|
||||
} => {
|
||||
let keysym = mk_keysym(scancode, keycode, keymod);
|
||||
let event = sys::SDL_KeyboardEvent{
|
||||
type_: sys::SDL_EventType::SDL_KEYDOWN as u32,
|
||||
type_: SDL_EventType::SDL_KEYDOWN as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
state: sys::SDL_PRESSED as u8,
|
||||
@@ -832,7 +833,7 @@ impl Event {
|
||||
} => {
|
||||
let keysym = mk_keysym(scancode, keycode, keymod);
|
||||
let event = sys::SDL_KeyboardEvent{
|
||||
type_: sys::SDL_EventType::SDL_KEYUP as u32,
|
||||
type_: SDL_EventType::SDL_KEYUP as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
state: sys::SDL_RELEASED as u8,
|
||||
@@ -858,7 +859,7 @@ impl Event {
|
||||
} => {
|
||||
let state = mousestate.to_sdl_state();
|
||||
let event = sys::SDL_MouseMotionEvent {
|
||||
type_: sys::SDL_EventType::SDL_MOUSEMOTION as u32,
|
||||
type_: SDL_EventType::SDL_MOUSEMOTION as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
which: which,
|
||||
@@ -884,7 +885,7 @@ impl Event {
|
||||
y
|
||||
} => {
|
||||
let event = sys::SDL_MouseButtonEvent {
|
||||
type_: sys::SDL_EventType::SDL_MOUSEBUTTONDOWN as u32,
|
||||
type_: SDL_EventType::SDL_MOUSEBUTTONDOWN as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
which: which,
|
||||
@@ -910,7 +911,7 @@ impl Event {
|
||||
y
|
||||
} => {
|
||||
let event = sys::SDL_MouseButtonEvent {
|
||||
type_: sys::SDL_EventType::SDL_MOUSEBUTTONUP as u32,
|
||||
type_: SDL_EventType::SDL_MOUSEBUTTONUP as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
which: which,
|
||||
@@ -936,7 +937,7 @@ impl Event {
|
||||
direction,
|
||||
} => {
|
||||
let event = sys::SDL_MouseWheelEvent {
|
||||
type_: sys::SDL_EventType::SDL_MOUSEWHEEL as u32,
|
||||
type_: SDL_EventType::SDL_MOUSEWHEEL as u32,
|
||||
timestamp: timestamp,
|
||||
windowID: window_id,
|
||||
which: which,
|
||||
@@ -956,7 +957,7 @@ impl Event {
|
||||
value
|
||||
} => {
|
||||
let event = sys::SDL_JoyAxisEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYAXISMOTION as u32,
|
||||
type_: SDL_EventType::SDL_JOYAXISMOTION as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
axis: axis_idx,
|
||||
@@ -980,7 +981,7 @@ impl Event {
|
||||
yrel
|
||||
} => {
|
||||
let event = sys::SDL_JoyBallEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYBALLMOTION as u32,
|
||||
type_: SDL_EventType::SDL_JOYBALLMOTION as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
ball: ball_idx,
|
||||
@@ -1004,7 +1005,7 @@ impl Event {
|
||||
} => {
|
||||
let hatvalue = state.to_raw();
|
||||
let event = sys::SDL_JoyHatEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYHATMOTION as u32,
|
||||
type_: SDL_EventType::SDL_JOYHATMOTION as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
hat: hat_idx,
|
||||
@@ -1024,7 +1025,7 @@ impl Event {
|
||||
button_idx
|
||||
} => {
|
||||
let event = sys::SDL_JoyButtonEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYBUTTONDOWN as u32,
|
||||
type_: SDL_EventType::SDL_JOYBUTTONDOWN as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
button: button_idx,
|
||||
@@ -1045,7 +1046,7 @@ impl Event {
|
||||
button_idx,
|
||||
} => {
|
||||
let event = sys::SDL_JoyButtonEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYBUTTONUP as u32,
|
||||
type_: SDL_EventType::SDL_JOYBUTTONUP as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
button: button_idx,
|
||||
@@ -1065,7 +1066,7 @@ impl Event {
|
||||
which,
|
||||
} => {
|
||||
let event = sys::SDL_JoyDeviceEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYDEVICEADDED as u32,
|
||||
type_: SDL_EventType::SDL_JOYDEVICEADDED as u32,
|
||||
timestamp: timestamp,
|
||||
which: which as i32,
|
||||
};
|
||||
@@ -1080,7 +1081,7 @@ impl Event {
|
||||
which,
|
||||
} => {
|
||||
let event = sys::SDL_JoyDeviceEvent {
|
||||
type_: sys::SDL_EventType::SDL_JOYDEVICEREMOVED as u32,
|
||||
type_: SDL_EventType::SDL_JOYDEVICEREMOVED as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
};
|
||||
@@ -1098,7 +1099,7 @@ impl Event {
|
||||
} => {
|
||||
let axisval = axis.to_ll();
|
||||
let event = sys::SDL_ControllerAxisEvent {
|
||||
type_: sys::SDL_EventType::SDL_CONTROLLERAXISMOTION as u32,
|
||||
type_: SDL_EventType::SDL_CONTROLLERAXISMOTION as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
axis: axisval as u8,
|
||||
@@ -1120,7 +1121,7 @@ impl Event {
|
||||
} => {
|
||||
let buttonval = button.to_ll();
|
||||
let event = sys::SDL_ControllerButtonEvent {
|
||||
type_: sys::SDL_EventType::SDL_CONTROLLERBUTTONDOWN as u32,
|
||||
type_: SDL_EventType::SDL_CONTROLLERBUTTONDOWN as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
// This conversion turns an i32 into a u8; signed-to-unsigned conversions
|
||||
@@ -1143,7 +1144,7 @@ impl Event {
|
||||
} => {
|
||||
let buttonval = button.to_ll();
|
||||
let event = sys::SDL_ControllerButtonEvent {
|
||||
type_: sys::SDL_EventType::SDL_CONTROLLERBUTTONUP as u32,
|
||||
type_: SDL_EventType::SDL_CONTROLLERBUTTONUP as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
button: buttonval as u8,
|
||||
@@ -1162,7 +1163,7 @@ impl Event {
|
||||
which,
|
||||
} => {
|
||||
let event = sys::SDL_ControllerDeviceEvent {
|
||||
type_: sys::SDL_EventType::SDL_CONTROLLERDEVICEADDED as u32,
|
||||
type_: SDL_EventType::SDL_CONTROLLERDEVICEADDED as u32,
|
||||
timestamp: timestamp,
|
||||
which: which as i32,
|
||||
};
|
||||
@@ -1178,7 +1179,7 @@ impl Event {
|
||||
which,
|
||||
} => {
|
||||
let event = sys::SDL_ControllerDeviceEvent {
|
||||
type_: sys::SDL_EventType::SDL_CONTROLLERDEVICEREMOVED as u32,
|
||||
type_: SDL_EventType::SDL_CONTROLLERDEVICEREMOVED as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
};
|
||||
@@ -1194,7 +1195,7 @@ impl Event {
|
||||
which,
|
||||
} => {
|
||||
let event = sys::SDL_ControllerDeviceEvent {
|
||||
type_: sys::SDL_EventType::SDL_CONTROLLERDEVICEREMAPPED as u32,
|
||||
type_: SDL_EventType::SDL_CONTROLLERDEVICEREMAPPED as u32,
|
||||
timestamp: timestamp,
|
||||
which: which,
|
||||
};
|
||||
|
||||
@@ -4,27 +4,27 @@ use libc;
|
||||
use libc::{c_void, uint32_t, size_t};
|
||||
use std::mem;
|
||||
use ::get_error;
|
||||
use sys;
|
||||
use sys::gfx;
|
||||
|
||||
/// Structure holding the state and timing information of the framerate controller.
|
||||
pub struct FPSManager {
|
||||
raw: *mut sys::gfx::framerate::FPSmanager,
|
||||
raw: *mut gfx::framerate::FPSmanager,
|
||||
}
|
||||
|
||||
impl FPSManager {
|
||||
/// Create the framerate manager.
|
||||
pub fn new() -> FPSManager {
|
||||
unsafe {
|
||||
let size = mem::size_of::<sys::gfx::framerate::FPSmanager>() as size_t;
|
||||
let raw = libc::malloc(size) as *mut sys::gfx::framerate::FPSmanager;
|
||||
sys::gfx::framerate::SDL_initFramerate(raw);
|
||||
let size = mem::size_of::<gfx::framerate::FPSmanager>() as size_t;
|
||||
let raw = libc::malloc(size) as *mut gfx::framerate::FPSmanager;
|
||||
gfx::framerate::SDL_initFramerate(raw);
|
||||
FPSManager { raw: raw }
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the framerate in Hz.
|
||||
pub fn set_framerate(&mut self, rate: u32) -> Result<(), String> {
|
||||
let ret = unsafe { sys::gfx::framerate::SDL_setFramerate(self.raw, rate as uint32_t) };
|
||||
let ret = unsafe { gfx::framerate::SDL_setFramerate(self.raw, rate as uint32_t) };
|
||||
match ret {
|
||||
0 => Ok(()),
|
||||
_ => Err(get_error())
|
||||
@@ -34,18 +34,18 @@ impl FPSManager {
|
||||
/// Return the current target framerate in Hz.
|
||||
pub fn get_framerate(&self) -> i32 {
|
||||
// will not get an error
|
||||
unsafe { sys::gfx::framerate::SDL_getFramerate(self.raw) as i32 }
|
||||
unsafe { gfx::framerate::SDL_getFramerate(self.raw) as i32 }
|
||||
}
|
||||
|
||||
/// Return the current framecount.
|
||||
pub fn get_frame_count(&self) -> i32 {
|
||||
// will not get an error
|
||||
unsafe { sys::gfx::framerate::SDL_getFramecount(self.raw) as i32 }
|
||||
unsafe { gfx::framerate::SDL_getFramecount(self.raw) as i32 }
|
||||
}
|
||||
|
||||
/// Delay execution to maintain a constant framerate and calculate fps.
|
||||
pub fn delay(&mut self) -> u32 {
|
||||
unsafe { sys::gfx::framerate::SDL_framerateDelay(self.raw) as u32 }
|
||||
unsafe { gfx::framerate::SDL_framerateDelay(self.raw) as u32 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+44
-43
@@ -29,15 +29,16 @@ use rwops::RWops;
|
||||
use version::Version;
|
||||
use get_error;
|
||||
use sys;
|
||||
use sys::image;
|
||||
|
||||
/// InitFlags are passed to init() to control which subsystem
|
||||
/// functionality to load.
|
||||
bitflags! {
|
||||
pub struct InitFlag : u32 {
|
||||
const JPG = sys::image::IMG_InitFlags_IMG_INIT_JPG as u32;
|
||||
const PNG = sys::image::IMG_InitFlags_IMG_INIT_PNG as u32;
|
||||
const TIF = sys::image::IMG_InitFlags_IMG_INIT_TIF as u32;
|
||||
const WEBP = sys::image::IMG_InitFlags_IMG_INIT_WEBP as u32;
|
||||
const JPG = image::IMG_InitFlags_IMG_INIT_JPG as u32;
|
||||
const PNG = image::IMG_InitFlags_IMG_INIT_PNG as u32;
|
||||
const TIF = image::IMG_InitFlags_IMG_INIT_TIF as u32;
|
||||
const WEBP = image::IMG_InitFlags_IMG_INIT_WEBP as u32;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ impl<'a> LoadSurface for Surface<'a> {
|
||||
//! Loads an SDL Surface from a file
|
||||
unsafe {
|
||||
let c_filename = CString::new(filename.as_ref().to_str().unwrap()).unwrap();
|
||||
let raw = sys::image::IMG_Load(c_filename.as_ptr() as *const _);
|
||||
let raw = image::IMG_Load(c_filename.as_ptr() as *const _);
|
||||
if (raw as *mut ()).is_null() {
|
||||
Err(get_error())
|
||||
} else {
|
||||
@@ -93,7 +94,7 @@ impl<'a> LoadSurface for Surface<'a> {
|
||||
fn from_xpm_array(xpm: *const *const i8) -> Result<Surface<'a>, String> {
|
||||
//! Loads an SDL Surface from XPM data
|
||||
unsafe {
|
||||
let raw = sys::image::IMG_ReadXPMFromArray(xpm as *mut *mut c_char);
|
||||
let raw = image::IMG_ReadXPMFromArray(xpm as *mut *mut c_char);
|
||||
if (raw as *mut ()).is_null() {
|
||||
Err(get_error())
|
||||
} else {
|
||||
@@ -108,7 +109,7 @@ impl<'a> SaveSurface for Surface<'a> {
|
||||
//! Saves an SDL Surface to a file
|
||||
unsafe {
|
||||
let c_filename = CString::new(filename.as_ref().to_str().unwrap()).unwrap();
|
||||
let status = sys::image::IMG_SavePNG(self.raw(), c_filename.as_ptr() as *const _);
|
||||
let status = image::IMG_SavePNG(self.raw(), c_filename.as_ptr() as *const _);
|
||||
if status != 0 {
|
||||
Err(get_error())
|
||||
} else {
|
||||
@@ -120,7 +121,7 @@ impl<'a> SaveSurface for Surface<'a> {
|
||||
fn save_rw(&self, dst: &mut RWops) -> Result<(), String> {
|
||||
//! Saves an SDL Surface to an RWops
|
||||
unsafe {
|
||||
let status = sys::image::IMG_SavePNG_RW(self.raw(), dst.raw(), 0);
|
||||
let status = image::IMG_SavePNG_RW(self.raw(), dst.raw(), 0);
|
||||
|
||||
if status != 0 {
|
||||
Err(get_error())
|
||||
@@ -141,7 +142,7 @@ impl<T> LoadTexture for TextureCreator<T> {
|
||||
//! Loads an SDL Texture from a file
|
||||
unsafe {
|
||||
let c_filename = CString::new(filename.as_ref().to_str().unwrap()).unwrap();
|
||||
let raw = sys::image::IMG_LoadTexture(self.raw(), c_filename.as_ptr() as *const _);
|
||||
let raw = image::IMG_LoadTexture(self.raw(), c_filename.as_ptr() as *const _);
|
||||
if (raw as *mut ()).is_null() {
|
||||
Err(get_error())
|
||||
} else {
|
||||
@@ -158,7 +159,7 @@ pub struct Sdl2ImageContext;
|
||||
impl Drop for Sdl2ImageContext {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
sys::image::IMG_Quit();
|
||||
image::IMG_Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +168,7 @@ impl Drop for Sdl2ImageContext {
|
||||
/// If not every flag is set it returns an error
|
||||
pub fn init(flags: InitFlag) -> Result<Sdl2ImageContext, String> {
|
||||
let return_flags = unsafe {
|
||||
let used = sys::image::IMG_Init(flags.bits() as c_int);
|
||||
let used = image::IMG_Init(flags.bits() as c_int);
|
||||
InitFlag::from_bits_truncate(used as u32)
|
||||
};
|
||||
if !flags.intersects(return_flags) {
|
||||
@@ -186,7 +187,7 @@ pub fn init(flags: InitFlag) -> Result<Sdl2ImageContext, String> {
|
||||
|
||||
/// Returns the version of the dynamically linked `SDL_image` library
|
||||
pub fn get_linked_version() -> Version {
|
||||
unsafe { Version::from_ll(*sys::image::IMG_Linked_Version()) }
|
||||
unsafe { Version::from_ll(*image::IMG_Linked_Version()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -238,118 +239,118 @@ pub trait ImageRWops {
|
||||
|
||||
impl<'a> ImageRWops for RWops<'a> {
|
||||
fn load(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_Load_RW(self.raw(), 0) };
|
||||
let raw = unsafe { image::IMG_Load_RW(self.raw(), 0) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_typed(&self, _type: &str) -> Result<Surface, String> {
|
||||
let raw = unsafe {
|
||||
let c_type = CString::new(_type.as_bytes()).unwrap();
|
||||
sys::image::IMG_LoadTyped_RW(self.raw(), 0, c_type.as_ptr() as *const _)
|
||||
image::IMG_LoadTyped_RW(self.raw(), 0, c_type.as_ptr() as *const _)
|
||||
};
|
||||
to_surface_result(raw)
|
||||
}
|
||||
|
||||
fn load_cur(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadCUR_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadCUR_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_ico(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadICO_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadICO_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_bmp(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadBMP_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadBMP_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_pnm(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadPNM_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadPNM_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_xpm(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadXPM_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadXPM_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_xcf(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadXCF_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadXCF_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_pcx(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadPCX_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadPCX_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_gif(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadGIF_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadGIF_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_jpg(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadJPG_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadJPG_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_tif(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadTIF_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadTIF_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_png(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadPNG_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadPNG_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_tga(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadTGA_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadTGA_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_lbm(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadLBM_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadLBM_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_xv(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadXV_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadXV_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
fn load_webp(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { sys::image::IMG_LoadWEBP_RW(self.raw()) };
|
||||
let raw = unsafe { image::IMG_LoadWEBP_RW(self.raw()) };
|
||||
to_surface_result(raw)
|
||||
}
|
||||
|
||||
fn is_cur(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isCUR(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isCUR(self.raw()) == 1 }
|
||||
}
|
||||
fn is_ico(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isICO(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isICO(self.raw()) == 1 }
|
||||
}
|
||||
fn is_bmp(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isBMP(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isBMP(self.raw()) == 1 }
|
||||
}
|
||||
fn is_pnm(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isPNM(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isPNM(self.raw()) == 1 }
|
||||
}
|
||||
fn is_xpm(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isXPM(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isXPM(self.raw()) == 1 }
|
||||
}
|
||||
fn is_xcf(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isXCF(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isXCF(self.raw()) == 1 }
|
||||
}
|
||||
fn is_pcx(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isPCX(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isPCX(self.raw()) == 1 }
|
||||
}
|
||||
fn is_gif(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isGIF(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isGIF(self.raw()) == 1 }
|
||||
}
|
||||
fn is_jpg(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isJPG(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isJPG(self.raw()) == 1 }
|
||||
}
|
||||
fn is_tif(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isTIF(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isTIF(self.raw()) == 1 }
|
||||
}
|
||||
fn is_png(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isPNG(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isPNG(self.raw()) == 1 }
|
||||
}
|
||||
fn is_lbm(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isLBM(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isLBM(self.raw()) == 1 }
|
||||
}
|
||||
fn is_xv(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isXV(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isXV(self.raw()) == 1 }
|
||||
}
|
||||
fn is_webp(&self) -> bool {
|
||||
unsafe { sys::image::IMG_isWEBP(self.raw()) == 1 }
|
||||
unsafe { image::IMG_isWEBP(self.raw()) == 1 }
|
||||
}
|
||||
}
|
||||
|
||||
+22
-21
@@ -1,4 +1,5 @@
|
||||
use crate::sys;
|
||||
use crate::sys::SDL_JoystickPowerLevel;
|
||||
|
||||
use crate::JoystickSubsystem;
|
||||
use crate::get_error;
|
||||
@@ -93,35 +94,35 @@ impl JoystickSubsystem {
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
#[repr(i32)]
|
||||
pub enum PowerLevel {
|
||||
Unknown = sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN as i32,
|
||||
Empty = sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_EMPTY as i32,
|
||||
Low = sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_LOW as i32,
|
||||
Medium = sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM as i32,
|
||||
Full = sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL as i32,
|
||||
Wired = sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED as i32,
|
||||
Unknown = SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN as i32,
|
||||
Empty = SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_EMPTY as i32,
|
||||
Low = SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_LOW as i32,
|
||||
Medium = SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM as i32,
|
||||
Full = SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL as i32,
|
||||
Wired = SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED as i32,
|
||||
}
|
||||
|
||||
impl PowerLevel {
|
||||
pub fn from_ll(raw: sys::SDL_JoystickPowerLevel) -> PowerLevel {
|
||||
pub fn from_ll(raw: SDL_JoystickPowerLevel) -> PowerLevel {
|
||||
match raw {
|
||||
sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN => PowerLevel::Unknown,
|
||||
sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_EMPTY => PowerLevel::Empty,
|
||||
sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_LOW => PowerLevel::Low,
|
||||
sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM => PowerLevel::Medium,
|
||||
sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL => PowerLevel::Full,
|
||||
sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED => PowerLevel::Wired,
|
||||
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN => PowerLevel::Unknown,
|
||||
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_EMPTY => PowerLevel::Empty,
|
||||
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_LOW => PowerLevel::Low,
|
||||
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM => PowerLevel::Medium,
|
||||
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL => PowerLevel::Full,
|
||||
SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED => PowerLevel::Wired,
|
||||
_ => panic!("Unexpected power level: {:?}", raw),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_ll(&self) -> sys::SDL_JoystickPowerLevel {
|
||||
pub fn to_ll(&self) -> SDL_JoystickPowerLevel {
|
||||
match *self {
|
||||
PowerLevel::Unknown => sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN,
|
||||
PowerLevel::Empty => sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_EMPTY,
|
||||
PowerLevel::Low => sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_LOW,
|
||||
PowerLevel::Medium => sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM,
|
||||
PowerLevel::Full => sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL,
|
||||
PowerLevel::Wired => sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED,
|
||||
PowerLevel::Unknown => SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN,
|
||||
PowerLevel::Empty => SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_EMPTY,
|
||||
PowerLevel::Low => SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_LOW,
|
||||
PowerLevel::Medium => SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_MEDIUM,
|
||||
PowerLevel::Full => SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_FULL,
|
||||
PowerLevel::Wired => SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_WIRED,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -185,7 +186,7 @@ impl Joystick {
|
||||
|
||||
let state = PowerLevel::from_ll(result);
|
||||
|
||||
if result != sys::SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN {
|
||||
if result != SDL_JoystickPowerLevel::SDL_JOYSTICK_POWER_UNKNOWN {
|
||||
Ok(state)
|
||||
} else {
|
||||
let err = get_error();
|
||||
|
||||
+487
-486
File diff suppressed because it is too large
Load Diff
+109
-108
File diff suppressed because it is too large
Load Diff
+13
-12
@@ -5,6 +5,7 @@ use crate::EventPump;
|
||||
use std::mem::transmute;
|
||||
|
||||
use crate::sys;
|
||||
use crate::sys::SDL_SystemCursor;
|
||||
|
||||
mod relative;
|
||||
pub use self::relative::RelativeMouseState;
|
||||
@@ -12,18 +13,18 @@ pub use self::relative::RelativeMouseState;
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
#[repr(u32)]
|
||||
pub enum SystemCursor {
|
||||
Arrow = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_ARROW as u32,
|
||||
IBeam = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_IBEAM as u32,
|
||||
Wait = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_WAIT as u32,
|
||||
Crosshair = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_CROSSHAIR as u32,
|
||||
WaitArrow = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_WAITARROW as u32,
|
||||
SizeNWSE = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZENWSE as u32,
|
||||
SizeNESW = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZENESW as u32,
|
||||
SizeWE = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZEWE as u32,
|
||||
SizeNS = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZENS as u32,
|
||||
SizeAll = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZEALL as u32,
|
||||
No = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_NO as u32,
|
||||
Hand = sys::SDL_SystemCursor::SDL_SYSTEM_CURSOR_HAND as u32,
|
||||
Arrow = SDL_SystemCursor::SDL_SYSTEM_CURSOR_ARROW as u32,
|
||||
IBeam = SDL_SystemCursor::SDL_SYSTEM_CURSOR_IBEAM as u32,
|
||||
Wait = SDL_SystemCursor::SDL_SYSTEM_CURSOR_WAIT as u32,
|
||||
Crosshair = SDL_SystemCursor::SDL_SYSTEM_CURSOR_CROSSHAIR as u32,
|
||||
WaitArrow = SDL_SystemCursor::SDL_SYSTEM_CURSOR_WAITARROW as u32,
|
||||
SizeNWSE = SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZENWSE as u32,
|
||||
SizeNESW = SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZENESW as u32,
|
||||
SizeWE = SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZEWE as u32,
|
||||
SizeNS = SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZENS as u32,
|
||||
SizeAll = SDL_SystemCursor::SDL_SYSTEM_CURSOR_SIZEALL as u32,
|
||||
No = SDL_SystemCursor::SDL_SYSTEM_CURSOR_NO as u32,
|
||||
Hand = SDL_SystemCursor::SDL_SYSTEM_CURSOR_HAND as u32,
|
||||
}
|
||||
|
||||
pub struct Cursor {
|
||||
|
||||
+22
-20
@@ -53,6 +53,8 @@ use std::mem::{transmute, uninitialized};
|
||||
use libc::c_void;
|
||||
|
||||
use crate::sys;
|
||||
use crate::sys::SDL_TextureAccess;
|
||||
use crate::sys::SDL_BlendMode;
|
||||
|
||||
/// Contains the description of an error returned by SDL
|
||||
#[derive(Debug)]
|
||||
@@ -102,9 +104,9 @@ impl Error for TargetRenderError {
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
#[repr(i32)]
|
||||
pub enum TextureAccess {
|
||||
Static = sys::SDL_TextureAccess::SDL_TEXTUREACCESS_STATIC as i32,
|
||||
Streaming = sys::SDL_TextureAccess::SDL_TEXTUREACCESS_STREAMING as i32,
|
||||
Target = sys::SDL_TextureAccess::SDL_TEXTUREACCESS_TARGET as i32,
|
||||
Static = SDL_TextureAccess::SDL_TEXTUREACCESS_STATIC as i32,
|
||||
Streaming = SDL_TextureAccess::SDL_TEXTUREACCESS_STREAMING as i32,
|
||||
Target = SDL_TextureAccess::SDL_TEXTUREACCESS_TARGET as i32,
|
||||
}
|
||||
|
||||
impl FromPrimitive for TextureAccess {
|
||||
@@ -112,10 +114,10 @@ impl FromPrimitive for TextureAccess {
|
||||
use self::TextureAccess::*;
|
||||
let n = n as u32;
|
||||
|
||||
Some(match unsafe { transmute::<u32, sys::SDL_TextureAccess>(n) } {
|
||||
sys::SDL_TextureAccess::SDL_TEXTUREACCESS_STATIC => Static,
|
||||
sys::SDL_TextureAccess::SDL_TEXTUREACCESS_STREAMING => Streaming,
|
||||
sys::SDL_TextureAccess::SDL_TEXTUREACCESS_TARGET => Target,
|
||||
Some(match unsafe { transmute::<u32, SDL_TextureAccess>(n) } {
|
||||
SDL_TextureAccess::SDL_TEXTUREACCESS_STATIC => Static,
|
||||
SDL_TextureAccess::SDL_TEXTUREACCESS_STREAMING => Streaming,
|
||||
SDL_TextureAccess::SDL_TEXTUREACCESS_TARGET => Target,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -138,11 +140,11 @@ pub struct RendererInfo {
|
||||
#[repr(i32)]
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
pub enum BlendMode {
|
||||
None = sys::SDL_BlendMode::SDL_BLENDMODE_NONE as i32,
|
||||
Blend = sys::SDL_BlendMode::SDL_BLENDMODE_BLEND as i32,
|
||||
Add = sys::SDL_BlendMode::SDL_BLENDMODE_ADD as i32,
|
||||
Mod = sys::SDL_BlendMode::SDL_BLENDMODE_MOD as i32,
|
||||
Invalid = sys::SDL_BlendMode::SDL_BLENDMODE_INVALID as i32,
|
||||
None = SDL_BlendMode::SDL_BLENDMODE_NONE as i32,
|
||||
Blend = SDL_BlendMode::SDL_BLENDMODE_BLEND as i32,
|
||||
Add = SDL_BlendMode::SDL_BLENDMODE_ADD as i32,
|
||||
Mod = SDL_BlendMode::SDL_BLENDMODE_MOD as i32,
|
||||
Invalid = SDL_BlendMode::SDL_BLENDMODE_INVALID as i32,
|
||||
}
|
||||
|
||||
impl FromPrimitive for BlendMode {
|
||||
@@ -150,12 +152,12 @@ impl FromPrimitive for BlendMode {
|
||||
use self::BlendMode::*;
|
||||
let n = n as u32;
|
||||
|
||||
Some(match unsafe { transmute::<u32, sys::SDL_BlendMode>(n) } {
|
||||
sys::SDL_BlendMode::SDL_BLENDMODE_NONE => None,
|
||||
sys::SDL_BlendMode::SDL_BLENDMODE_BLEND => Blend,
|
||||
sys::SDL_BlendMode::SDL_BLENDMODE_ADD => Add,
|
||||
sys::SDL_BlendMode::SDL_BLENDMODE_MOD => Mod,
|
||||
sys::SDL_BlendMode::SDL_BLENDMODE_INVALID => Invalid,
|
||||
Some(match unsafe { transmute::<u32, SDL_BlendMode>(n) } {
|
||||
SDL_BlendMode::SDL_BLENDMODE_NONE => None,
|
||||
SDL_BlendMode::SDL_BLENDMODE_BLEND => Blend,
|
||||
SDL_BlendMode::SDL_BLENDMODE_ADD => Add,
|
||||
SDL_BlendMode::SDL_BLENDMODE_MOD => Mod,
|
||||
SDL_BlendMode::SDL_BLENDMODE_INVALID => Invalid,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -937,7 +939,7 @@ impl<T: RenderTarget> Canvas<T> {
|
||||
|
||||
/// Gets the blend mode used for drawing operations.
|
||||
pub fn blend_mode(&self) -> BlendMode {
|
||||
let mut blend: sys::SDL_BlendMode;
|
||||
let mut blend: SDL_BlendMode;
|
||||
unsafe { blend = uninitialized(); }
|
||||
let ret = unsafe { sys::SDL_GetRenderDrawBlendMode(self.context.raw, &mut blend) };
|
||||
// Should only fail on an invalid renderer
|
||||
@@ -1737,7 +1739,7 @@ impl InternalTexture {
|
||||
}
|
||||
|
||||
pub fn blend_mode(&self) -> BlendMode {
|
||||
let mut blend: sys::SDL_BlendMode;
|
||||
let mut blend: SDL_BlendMode;
|
||||
unsafe { blend = uninitialized(); }
|
||||
let ret = unsafe { sys::SDL_GetTextureBlendMode(self.raw, &mut blend) };
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::path::Path;
|
||||
use ::get_error;
|
||||
use ::rwops::RWops;
|
||||
use ::version::Version;
|
||||
use sys;
|
||||
use sys::ttf;
|
||||
|
||||
use super::font::{
|
||||
internal_load_font,
|
||||
@@ -22,7 +22,7 @@ pub struct Sdl2TtfContext;
|
||||
// Clean up the context once it goes out of scope
|
||||
impl Drop for Sdl2TtfContext {
|
||||
fn drop(&mut self) {
|
||||
unsafe { sys::ttf::TTF_Quit(); }
|
||||
unsafe { ttf::TTF_Quit(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Sdl2TtfContext {
|
||||
pub fn load_font_from_rwops<'ttf,'r>(&'ttf self, rwops: RWops<'r>, point_size: u16)
|
||||
-> Result<Font<'ttf,'r>, String> {
|
||||
let raw = unsafe {
|
||||
sys::ttf::TTF_OpenFontRW(rwops.raw(), 0, point_size as c_int)
|
||||
ttf::TTF_OpenFontRW(rwops.raw(), 0, point_size as c_int)
|
||||
};
|
||||
if (raw as *mut ()).is_null() {
|
||||
Err(get_error())
|
||||
@@ -58,7 +58,7 @@ impl Sdl2TtfContext {
|
||||
pub fn load_font_at_index_from_rwops<'ttf,'r>(&'ttf self, rwops: RWops<'r>, index: u32,
|
||||
point_size: u16) -> Result<Font<'ttf,'r>, String> {
|
||||
let raw = unsafe {
|
||||
sys::ttf::TTF_OpenFontIndexRW(rwops.raw(), 0, point_size as c_int,
|
||||
ttf::TTF_OpenFontIndexRW(rwops.raw(), 0, point_size as c_int,
|
||||
index as c_long)
|
||||
};
|
||||
if (raw as *mut ()).is_null() {
|
||||
@@ -72,7 +72,7 @@ impl Sdl2TtfContext {
|
||||
/// Returns the version of the dynamically linked `SDL_TTF` library
|
||||
pub fn get_linked_version() -> Version {
|
||||
unsafe {
|
||||
Version::from_ll(*sys::ttf::TTF_Linked_Version())
|
||||
Version::from_ll(*ttf::TTF_Linked_Version())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ impl fmt::Display for InitError {
|
||||
/// clean up the library once it goes out of scope.
|
||||
pub fn init() -> Result<Sdl2TtfContext, InitError> {
|
||||
unsafe {
|
||||
if sys::ttf::TTF_WasInit() == 1 {
|
||||
if ttf::TTF_WasInit() == 1 {
|
||||
Err(InitError::AlreadyInitializedError)
|
||||
} else if sys::ttf::TTF_Init() == 0 {
|
||||
} else if ttf::TTF_Init() == 0 {
|
||||
Ok(Sdl2TtfContext)
|
||||
} else {
|
||||
Err(InitError::InitializationError(
|
||||
@@ -133,6 +133,6 @@ pub fn init() -> Result<Sdl2TtfContext, InitError> {
|
||||
/// Returns whether library has been initialized already.
|
||||
pub fn has_been_initialized() -> bool {
|
||||
unsafe {
|
||||
sys::ttf::TTF_WasInit() == 1
|
||||
ttf::TTF_WasInit() == 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use std::ffi::NulError;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use ::surface::Surface;
|
||||
use sys;
|
||||
use sys::ttf;
|
||||
use sys::SDL_Surface;
|
||||
use ::get_error;
|
||||
|
||||
Reference in New Issue
Block a user