Player

Struct Player 

Source
pub struct Player<'player> { /* private fields */ }
Expand description

Represents a console controller type

It’s essentially a wrapper type over HID shared-memory to simplify input detection

Implementations§

Source§

impl<'player, 'context: 'player> Player<'player>

Source

pub fn new( npad_id: NpadIdType, supported_style_tags: NpadStyleTag, shmem: &'context SharedMemoryFormat, ) -> Result<Self>

Creates a Player from shared-memory information

If using a Context, look for Context::get_player instead (for simplicity)

§Arguments
  • npad_id: The NpadIdType of the desired controller
  • supported_style_tags: The NpadStyleTag flags which will be used by the Player to scan for input, etc.
  • shmem_ptr: The address of HID shared-memory
Source

pub fn get_previous_buttons(&self) -> NpadButton

Source

pub fn get_style_tag_attributes(&self, style_tag: NpadStyleTag) -> NpadAttribute

Gets the NpadAttributes for a certain NpadStyleTag

§Arguments
  • style_tag: Must be a NpadStyleTag with a single flag set (otherwise only one will take effect and the rest will be ignored)
Source

pub fn get_stick_status( &self, style_tag: NpadStyleTag, ) -> (AnalogStickState, AnalogStickState)

Gets the stick status from a provided style tag (which may or may not be configured)

Source

pub fn get_first_stick_status( &self, deadzone: f32, ) -> Option<(AnalogStickState, AnalogStickState)>

Source

pub fn get_style_tag_buttons(&mut self, style_tag: NpadStyleTag) -> NpadButton

Gets the NpadButtons for a certain NpadStyleTag

§Arguments
  • style_tag: Must be a NpadStyleTag with a single flag set (otherwise only one will take effect and the rest will be ignored)
Source

pub fn get_style_tag_buttons_down( &mut self, style_tag: NpadStyleTag, ) -> NpadButton

Gets the down NpadButtons for a certain NpadStyleTag

This is similar to get_style_tag_buttons but this only gets the buttons once after they’re down/pressed

§Arguments
  • style_tag: Must be a NpadStyleTag with a single flag set (otherwise only one will take effect and the rest will be ignored)
Source

pub fn get_style_tag_buttons_up( &mut self, style_tag: NpadStyleTag, ) -> NpadButton

Gets the up NpadButtons for a certain NpadStyleTag

This is similar to get_style_tag_buttons but this only gets the buttons once after they’re up/released

§Arguments
  • style_tag: Must be a NpadStyleTag with a single flag set (otherwise only one will take effect and the rest will be ignored)
Source

pub fn get_buttons(&mut self) -> NpadButton

Gets the NpadButtons for all of the supported NpadStyleTags, combining all of them

This is like combining the result of get_style_tag_buttons with all the supported NpadStyleTag flags

Source

pub fn get_buttons_down(&mut self) -> NpadButton

Gets the down NpadButtons for all of the supported NpadStyleTags, combining all of them

This is similar to get_buttons but this only gets the buttons once after they’re down/pressed

Source

pub fn get_buttons_up(&mut self) -> NpadButton

Gets the up NpadButtons for all of the supported NpadStyleTags, combining all of them

This is similar to get_buttons but this only gets the buttons once after they’re up/released

Source

pub fn get_button_updates( &mut self, ) -> (NpadButton, NpadButton, NpadButton, NpadButton)

Gets the up NpadButtons for all of the supported NpadStyleTags, combining all of them

This only updates the state once, but is otherwise equivalent to (self.get_previous(), self.get_buttons(), self.get_buttons_down(), self.get_buttons_up())

Source

pub fn get_npad_id(&self) -> NpadIdType

Gets the NpadIdType being used with this Player

Source

pub fn get_supported_style_tags(&self) -> NpadStyleTag

Gets the supported NpadStyleTag flags being used with this Player

Source

pub fn get_reported_style_tag(&self) -> NpadStyleTag

Source

pub fn get_controller_type(&self) -> DeviceType

Source

pub fn get_keyboard_state(&self) -> KeyboardState

Auto Trait Implementations§

§

impl<'player> Freeze for Player<'player>

§

impl<'player> RefUnwindSafe for Player<'player>

§

impl<'player> Send for Player<'player>

§

impl<'player> Sync for Player<'player>

§

impl<'player> Unpin for Player<'player>

§

impl<'player> UnwindSafe for Player<'player>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where 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>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.