get_state

Function get_state 

Source
pub fn get_state(user_index: impl TryInto<u32>) -> Result<State, Error>
Expand description

[microsoft.com] XInputGetState

Retrieves the current state of the specified controller.

§Arguments

§Example

let gamepad = 0;
let state : xinput::State = xinput::get_state(gamepad).unwrap_or_default();
println!("{state:#?}");

§Output

State {
    packet_number: 305,
    gamepad: Gamepad {
        buttons: Buttons::None,
        left_trigger: 0,
        right_trigger: 0,
        left_thumb_x: 2479,
        left_thumb_y: -707,
        right_thumb_x: -48,
        right_thumb_y: -1028,
    },
}

§Errors