Skip to content

Commit

Permalink
Merge pull request Rust-SDL2#964 from 17cupsofcoffee/instance-id-u32
Browse files Browse the repository at this point in the history
Convert joystick instance IDs to u32s
  • Loading branch information
Cobrand authored Jan 29, 2020
2 parents d393ffd + 9043d39 commit 9c85f4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sdl2/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -373,7 +373,7 @@ impl GameController {
// Should only fail if the joystick is NULL.
panic!(get_error())
} else {
result
result as u32
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/sdl2/joystick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 9c85f4d

Please sign in to comment.