forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamepad_input_events.rs
38 lines (35 loc) · 1.09 KB
/
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
31
32
33
34
35
36
37
38
//! Iterates and prints gamepad input and connection events.
use bevy::{
input::gamepad::{GamepadEvent, GamepadEventType},
prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_system(gamepad_events)
.run();
}
fn gamepad_events(mut gamepad_event: EventReader<GamepadEvent>) {
for event in gamepad_event.iter() {
match event.event_type {
GamepadEventType::Connected(_) => {
info!("{:?} Connected", event.gamepad);
}
GamepadEventType::Disconnected => {
info!("{:?} Disconnected", event.gamepad);
}
GamepadEventType::ButtonChanged(button_type, value) => {
info!(
"{:?} of {:?} is changed to {}",
button_type, event.gamepad, value
);
}
GamepadEventType::AxisChanged(axis_type, value) => {
info!(
"{:?} of {:?} is changed to {}",
axis_type, event.gamepad, value
);
}
}
}
}