[−][src]Struct rusty_xinput::XInputState
This wraps an XINPUT_STATE
value and provides a more rusty (read-only)
interface to the data it contains.
All three major game companies use different names for most of the buttons, so the docs for each button method list out what each of the major companies call that button. To the driver it's all the same, it's just however you want to think of them.
If sequential calls to xinput_get_state
for a given controller slot have
the same packet number then the controller state has not changed since the
last call. The PartialEq
and Eq
implementations for this wrapper type
reflect that. The exact value of the packet number is unimportant.
If you want to do something that the rust wrapper doesn't support, just use the raw field to get at the inner value.
Fields
raw: XINPUT_STATE
The raw value we're wrapping.
Methods
impl XInputState
[src]
pub fn north_button(&self) -> bool
[src]
The north button of the action button group.
- Nintendo: X
- Playstation: Triangle
- XBox: Y
pub fn south_button(&self) -> bool
[src]
The south button of the action button group.
- Nintendo: B
- Playstation: X
- XBox: A
pub fn east_button(&self) -> bool
[src]
The east button of the action button group.
- Nintendo: A
- Playstation: Circle
- XBox: B
pub fn west_button(&self) -> bool
[src]
The west button of the action button group.
- Nintendo: Y
- Playstation: Square
- XBox: X
pub fn arrow_up(&self) -> bool
[src]
The up button on the directional pad.
pub fn arrow_down(&self) -> bool
[src]
The down button on the directional pad.
pub fn arrow_left(&self) -> bool
[src]
The left button on the directional pad.
pub fn arrow_right(&self) -> bool
[src]
The right button on the directional pad.
pub fn start_button(&self) -> bool
[src]
The "start" button.
- Nintendo: Start (NES / SNES), '+' (Pro Controller)
- Playstation: Start
- XBox: Start
pub fn select_button(&self) -> bool
[src]
The "not start" button.
- Nintendo: Select (NES / NES), '-' (Pro Controller)
- Playstation: Select
- XBox: Back
pub fn left_shoulder(&self) -> bool
[src]
The upper left shoulder button.
- Nintendo: L
- Playstation: L1
- XBox: LB
pub fn right_shoulder(&self) -> bool
[src]
The upper right shoulder button.
- Nintendo: R
- Playstation: R1
- XBox: RB
pub const TRIGGER_THRESHOLD: u8
[src]
The default threshold to count a trigger as being "pressed".
pub fn left_trigger(&self) -> u8
[src]
The lower left shoulder trigger. If you want to use this as a simple
boolean it is suggested that you compare it to the TRIGGER_THRESHOLD
constant.
- Nintendo: ZL
- Playstation: L2
- XBox: LT
pub fn right_trigger(&self) -> u8
[src]
The lower right shoulder trigger. If you want to use this as a simple
boolean it is suggested that you compare it to the TRIGGER_THRESHOLD
constant.
- Nintendo: ZR
- Playstation: R2
- XBox: RT
pub fn left_trigger_bool(&self) -> bool
[src]
The lower left shoulder trigger as a bool using the default threshold.
- Nintendo: ZL
- Playstation: L2
- XBox: LT
pub fn right_trigger_bool(&self) -> bool
[src]
The lower right shoulder trigger as a bool using the default threshold.
- Nintendo: ZR
- Playstation: R2
- XBox: RT
pub fn left_thumb_button(&self) -> bool
[src]
The left thumb stick being pressed inward.
- Nintendo: (L)
- Playstation: L3
- XBox: (L)
pub fn right_thumb_button(&self) -> bool
[src]
The right thumb stick being pressed inward.
- Nintendo: (R)
- Playstation: R3
- XBox: (R)
pub const LEFT_STICK_DEADZONE: i16
[src]
The suggested default deadzone for use with the left thumb stick.
pub const RIGHT_STICK_DEADZONE: i16
[src]
The suggested default deadzone for use with the right thumb stick.
pub fn left_stick_raw(&self) -> (i16, i16)
[src]
The left stick raw value.
Positive values are to the right (X-axis) or up (Y-axis).
pub fn right_stick_raw(&self) -> (i16, i16)
[src]
The right stick raw value.
Positive values are to the right (X-axis) or up (Y-axis).
pub fn left_stick_normalized(&self) -> (f32, f32)
[src]
The left stick value normalized with the default dead-zone.
See normalize_raw_stick_value
for more.
pub fn right_stick_normalized(&self) -> (f32, f32)
[src]
The right stick value normalized with the default dead-zone.
See normalize_raw_stick_value
for more.
pub fn normalize_raw_stick_value(
raw_stick: (i16, i16),
deadzone: i16
) -> (f32, f32)
[src]
raw_stick: (i16, i16),
deadzone: i16
) -> (f32, f32)
This helper normalizes a raw stick value using the given deadzone.
If the raw value's 2d length is less than the deadzone the result will be
(0.0,0.0)
, otherwise the result is normalized across the range from the
deadzone point to the maximum value.
The deadzone
value is clamped to the range 0 to 32,766 (inclusive)
before use. Negative inputs or maximum value inputs make the normalization
just work improperly.
Trait Implementations
impl PartialEq<XInputState> for XInputState
[src]
fn eq(&self, other: &XInputState) -> bool
[src]
Equality for XInputState
values is based only on the
dwPacketNumber
of the wrapped XINPUT_STATE
value. This is entirely
correct for values obtained from the xinput system, but if you make your
own XInputState
values for some reason you can confuse it.
#[must_use]
default fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for XInputState
[src]
impl Debug for XInputState
[src]
Auto Trait Implementations
impl Send for XInputState
impl Sync for XInputState
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,