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
user_index— The controller to get the state of (0 .. xuser::MAX_COUNT.)
§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
- error::BAD_ARGUMENTS - Invalid
user_index(expected0 .. xuser::MAX_COUNT) - error::DEVICE_NOT_CONNECTED - No gamepad connected for
user_index. - error::INVALID_FUNCTION - API unavailable: XInput not loaded