mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 17:07:47 +00:00
6d6bc2a8b4
This is extracted out of eb8f973646476b4a4926ba644a77e2b3a5772159 and includes some additional changes to remove all references to AppBuilder and fix examples that still used App::build() instead of App::new(). In addition I didn't extract the sub app feature as it isn't ready yet. You can use `git diff --diff-filter=M eb8f973646476b4a4926ba644a77e2b3a5772159` to find all differences in this PR. The `--diff-filtered=M` filters all files added in the original commit but not in this commit away. Co-Authored-By: Carter Anderson <mcanders1@gmail.com>
30 lines
1,007 B
Rust
30 lines
1,007 B
Rust
use bevy::{
|
|
input::gamepad::{GamepadEvent, GamepadEventType},
|
|
prelude::*,
|
|
};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.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) => {
|
|
info!("{:?} Connected", gamepad);
|
|
}
|
|
GamepadEvent(gamepad, GamepadEventType::Disconnected) => {
|
|
info!("{:?} Disconnected", gamepad);
|
|
}
|
|
GamepadEvent(gamepad, GamepadEventType::ButtonChanged(button_type, value)) => {
|
|
info!("{:?} of {:?} is changed to {}", button_type, gamepad, value);
|
|
}
|
|
GamepadEvent(gamepad, GamepadEventType::AxisChanged(axis_type, value)) => {
|
|
info!("{:?} of {:?} is changed to {}", axis_type, gamepad, value);
|
|
}
|
|
}
|
|
}
|
|
}
|