Merge pull request #964 from 17cupsofcoffee/instance-id-u32

Convert joystick instance IDs to u32s
This commit is contained in:
Cobrand
2020-01-29 16:55:49 +01:00
committed by GitHub
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -363,7 +363,7 @@ impl GameController {
}
/// Return the joystick instance id of this controller
pub fn instance_id(&self) -> i32 {
pub fn instance_id(&self) -> u32 {
let result = unsafe {
let joystick = sys::SDL_GameControllerGetJoystick(self.raw);
sys::SDL_JoystickInstanceID(joystick)
@@ -373,7 +373,7 @@ impl GameController {
// Should only fail if the joystick is NULL.
panic!(get_error())
} else {
result
result as u32
}
}
+2 -2
View File
@@ -152,14 +152,14 @@ impl Joystick {
unsafe { sys::SDL_JoystickGetAttached(self.raw) != sys::SDL_bool::SDL_FALSE }
}
pub fn instance_id(&self) -> i32 {
pub fn instance_id(&self) -> u32 {
let result = unsafe { sys::SDL_JoystickInstanceID(self.raw) };
if result < 0 {
// Should only fail if the joystick is NULL.
panic!(get_error())
} else {
result
result as u32
}
}