Skip to content

Commit 9c85f4d

Browse files
authored
Merge pull request Rust-SDL2#964 from 17cupsofcoffee/instance-id-u32
Convert joystick instance IDs to u32s
2 parents d393ffd + 9043d39 commit 9c85f4d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/sdl2/controller.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl GameController {
363363
}
364364

365365
/// Return the joystick instance id of this controller
366-
pub fn instance_id(&self) -> i32 {
366+
pub fn instance_id(&self) -> u32 {
367367
let result = unsafe {
368368
let joystick = sys::SDL_GameControllerGetJoystick(self.raw);
369369
sys::SDL_JoystickInstanceID(joystick)
@@ -373,7 +373,7 @@ impl GameController {
373373
// Should only fail if the joystick is NULL.
374374
panic!(get_error())
375375
} else {
376-
result
376+
result as u32
377377
}
378378
}
379379

src/sdl2/joystick.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ impl Joystick {
152152
unsafe { sys::SDL_JoystickGetAttached(self.raw) != sys::SDL_bool::SDL_FALSE }
153153
}
154154

155-
pub fn instance_id(&self) -> i32 {
155+
pub fn instance_id(&self) -> u32 {
156156
let result = unsafe { sys::SDL_JoystickInstanceID(self.raw) };
157157

158158
if result < 0 {
159159
// Should only fail if the joystick is NULL.
160160
panic!(get_error())
161161
} else {
162-
result
162+
result as u32
163163
}
164164
}
165165

0 commit comments

Comments
 (0)