Skip to content

Document how to configure gamepads #3246

@alice-i-cecile

Description

@alice-i-cecile

How can Bevy's documentation be improved?

GamepadInputSettings is somewhat challenging to figure out how to use. A simple example system would go a long way.

fn configure_gamepad(mut settings: ResMut<GamepadSettings>, gamepads: Res<Gamepads>) {
    if !settings.is_changed() | gamepads.is_changed() {
        return;
    }
    const DEADZONE: f32 = 0.1;

    // The joystick should not register inputs when near the center
    for &gamepad in gamepad_lobby.iter() {
        let left_stick_x = GamepadAxis(gamepad, GamepadAxisType::LeftStickX);
        let left_stick_y = GamepadAxis(gamepad, GamepadAxisType::LeftStickY);

        let mut left_x_settings = settings.axis_settings.get_mut(&left_stick_x).unwrap();
        left_x_settings.threshold = DEADZONE;

        let mut left_y_settings = settings.axis_settings.get_mut(&left_stick_y).unwrap();
        left_y_settings.threshold = DEADZONE;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-DocsAn addition or correction to our documentationD-TrivialNice and easy! A great choice to get started with BevyS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions