### Basic Bevy App Setup with Input Manager Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/README.md Demonstrates the minimal setup for a Bevy application using the InputManagerPlugin. Ensure your action enum derives `Actionlike` and is provided to the plugin. The `InputMap` and `ActionState` components are automatically added to entities with the `Player` component. ```rust use bevy::prelude::*; use leafwing_input_manager::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) // This plugin maps inputs to an input-type agnostic action-state // We need to provide it with an enum which stores the possible actions a player could take .add_plugins(InputManagerPlugin::::default()) // The InputMap and ActionState components will be added to any entity with the Player component .add_systems(Startup, spawn_player) // Read the ActionState in your systems using queries! .add_systems(Update, jump) .run(); } // This is the list of "things in the game I want to be able to do based on input" #[derive(Actionlike, PartialEq, Eq, Hash, Clone, Copy, Debug, Reflect)] enum Action { Run, Jump, } #[derive(Component)] struct Player; fn spawn_player(mut commands: Commands) { // Describes how to convert from player inputs into those actions let input_map = InputMap::new([(Action::Jump, KeyCode::Space)]); commands.spawn(input_map).insert(Player); } // Query for the `ActionState` component in your game logic systems! fn jump(query: Query<&ActionState, With>) { let action_state = query.single(); if let Ok(action_state) = action_state { // Each action has a button-like state of its own that you can check if action_state.just_pressed(&Action::Jump) { println!("I'm jumping!"); } } } ``` -------------------------------- ### Build and Open Local Documentation Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/CONTRIBUTING.md Generate and open the project's documentation locally for review. ```bash cargo doc --open ``` -------------------------------- ### Insert Keyboard and Gamepad Input for an Action Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/README.md Demonstrates how to bind both keyboard and gamepad inputs to the same action. This allows for flexible control schemes where players can choose their preferred input method. ```rust input_map.insert(Action::Jump, KeyCode::Space); input_map.insert(Action::Jump, GamepadButton::South); ``` -------------------------------- ### Run All Tests Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/CONTRIBUTING.md Execute all tests within the project, including unit and integration tests. ```bash cargo test ``` -------------------------------- ### Insert Button-like Chord Input Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/README.md Shows how to define a chord, which is a combination of multiple button inputs that trigger a single action. This is useful for complex commands or shortcuts. ```rust input_map.insert(Action::Console, ButtonlikeChord::new([KeyCode::ControlLeft, KeyCode::Shift, KeyCode::KeyC])) ``` -------------------------------- ### Format Code Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/CONTRIBUTING.md Ensure code adheres to the project's formatting standards using cargo fmt. ```bash cargo fmt ``` -------------------------------- ### Run CI Locally Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/CONTRIBUTING.md Execute the project's CI checks locally to ensure code quality and compliance. ```bash cargo run -p ci ``` -------------------------------- ### Run Clippy Lints Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/CONTRIBUTING.md Check for common Rust code issues and style problems using clippy. ```bash clippy ``` -------------------------------- ### Run Workspace Tests Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/CONTRIBUTING.md Execute all tests across the entire workspace. ```bash cargo test --workspace ``` -------------------------------- ### Pressing an input using trait method Source: https://github.com/leafwing-studios/leafwing-input-manager/blob/main/RELEASES.md Use the `press` method on the input enum for pressing inputs, replacing the older `app.press_input()` method. This change applies to `Buttonlike`, `Axislike`, and `DualAxislike` traits. ```rust KeyCode::Space.press(app.world_mut()) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.