mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 14:10:19 +00:00
84363f2fab
# Objective - There are several redundant imports in the tests and examples that are not caught by CI because additional flags need to be passed. ## Solution - Run `cargo check --workspace --tests` and `cargo check --workspace --examples`, then fix all warnings. - Add `test-check` to CI, which will be run in the check-compiles job. This should catch future warnings for tests. Examples are already checked, but I'm not yet sure why they weren't caught. ## Discussion - Should the `--tests` and `--examples` flags be added to CI, so this is caught in the future? - If so, #12818 will need to be merged first. It was also a warning raised by checking the examples, but I chose to split off into a separate PR. --------- Co-authored-by: François Mockers <francois.mockers@vleue.com>
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
//! Shows handling of gamepad input, connections, and disconnections.
|
|
|
|
use bevy::prelude::*;
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Update, gamepad_system)
|
|
.run();
|
|
}
|
|
|
|
fn gamepad_system(
|
|
gamepads: Res<Gamepads>,
|
|
button_inputs: Res<ButtonInput<GamepadButton>>,
|
|
button_axes: Res<Axis<GamepadButton>>,
|
|
axes: Res<Axis<GamepadAxis>>,
|
|
) {
|
|
for gamepad in gamepads.iter() {
|
|
if button_inputs.just_pressed(GamepadButton::new(gamepad, GamepadButtonType::South)) {
|
|
info!("{:?} just pressed South", gamepad);
|
|
} else if button_inputs.just_released(GamepadButton::new(gamepad, GamepadButtonType::South))
|
|
{
|
|
info!("{:?} just released South", gamepad);
|
|
}
|
|
|
|
let right_trigger = button_axes
|
|
.get(GamepadButton::new(
|
|
gamepad,
|
|
GamepadButtonType::RightTrigger2,
|
|
))
|
|
.unwrap();
|
|
if right_trigger.abs() > 0.01 {
|
|
info!("{:?} RightTrigger2 value is {}", gamepad, right_trigger);
|
|
}
|
|
|
|
let left_stick_x = axes
|
|
.get(GamepadAxis::new(gamepad, GamepadAxisType::LeftStickX))
|
|
.unwrap();
|
|
if left_stick_x.abs() > 0.01 {
|
|
info!("{:?} LeftStickX value is {}", gamepad, left_stick_x);
|
|
}
|
|
}
|
|
}
|