use bevy::{input::gamepad::GamepadButton, prelude::*}; fn main() { App::new() .add_plugins(DefaultPlugins) .add_system(gamepad_system) .run(); } fn gamepad_system( gamepads: Res, button_inputs: Res>, button_axes: Res>, axes: Res>, ) { for gamepad in gamepads.iter().cloned() { if button_inputs.just_pressed(GamepadButton(gamepad, GamepadButtonType::South)) { info!("{:?} just pressed South", gamepad); } else if button_inputs.just_released(GamepadButton(gamepad, GamepadButtonType::South)) { info!("{:?} just released South", gamepad); } let right_trigger = button_axes .get(GamepadButton(gamepad, GamepadButtonType::RightTrigger2)) .unwrap(); if right_trigger.abs() > 0.01 { info!("{:?} RightTrigger2 value is {}", gamepad, right_trigger); } let left_stick_x = axes .get(GamepadAxis(gamepad, GamepadAxisType::LeftStickX)) .unwrap(); if left_stick_x.abs() > 0.01 { info!("{:?} LeftStickX value is {}", gamepad, left_stick_x); } } }