Skip to content

Commit 809fee0

Browse files
tickyCobrand
authored andcommitted
Use power_level in the joystick example
1 parent d8b3a28 commit 809fee0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/joystick.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ fn main() {
2727
}
2828
}
2929

30-
if joystick.is_none() {
31-
panic!("Couldn't open any joystick");
32-
};
30+
// Print the joystick's power level, if a joystick was found.
31+
match joystick {
32+
Some(j) => {
33+
println!("\"{}\" power level: {:?}", j.name(), j.power_level().unwrap());
34+
},
35+
None => panic!("Couldn't open any joystick"),
36+
}
3337

3438
for event in sdl_context.event_pump().unwrap().wait_iter() {
3539
use sdl2::event::Event;

0 commit comments

Comments
 (0)