forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamepad_input_events.rs
30 lines (28 loc) · 1021 Bytes
/
gamepad_input_events.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use bevy::{
input::gamepad::{GamepadEvent, GamepadEventType},
prelude::*,
};
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_system(gamepad_events.system())
.run();
}
fn gamepad_events(mut gamepad_event: EventReader<GamepadEvent>) {
for event in gamepad_event.iter() {
match &event {
GamepadEvent(gamepad, GamepadEventType::Connected) => {
println!("{:?} Connected", gamepad);
}
GamepadEvent(gamepad, GamepadEventType::Disconnected) => {
println!("{:?} Disconnected", gamepad);
}
GamepadEvent(gamepad, GamepadEventType::ButtonChanged(button_type, value)) => {
println!("{:?} of {:?} is changed to {}", button_type, gamepad, value);
}
GamepadEvent(gamepad, GamepadEventType::AxisChanged(axis_type, value)) => {
println!("{:?} of {:?} is changed to {}", axis_type, gamepad, value);
}
}
}
}