Skip to main content

ActivePad

Struct ActivePad 

Source
pub struct ActivePad { /* private fields */ }
Expand description

The pad whose sticks drive the game, its filtered sticks, and the let-go rule.

  • The first pad to move a stick past the dead zone holds them, or the first to be activated by a button, and keeps them until it disconnects: a second pad cannot take over mid-move.
  • Each stick reads through a scaled radial dead zone (crate::radial_deadzone): zero inside it, rescaled from its edge to full throw.
  • release_until_neutral — on opening a menu, on losing focus — zeroes the sticks and keeps each stick of each pad at zero until that stick has come back inside the dead zone, so a stick still held as the menu closes does not walk the player off. Every pad first seen after a release is held to the same rule, and so is a pad that disconnected while it held the sticks, when it returns.

Implementations§

Source§

impl ActivePad

Source

pub fn new(dead_zone: f32) -> Option<Self>

No pad holding the sticks, with dead_zone in 0.0..1.0; None outside it.

Source

pub const fn active(&self) -> Option<GamepadId>

The pad holding the sticks.

Source

pub fn activate(&mut self, id: GamepadId) -> bool

Gives id the sticks, as a button press on it does, unless another pad holds them. Returns whether id holds them now.

Source

pub fn release_until_neutral(&mut self)

Zeroes the sticks and holds every stick of every pad at zero until it has rested.

Source

pub fn submit( &mut self, id: GamepadId, snapshot: &GamepadSnapshot, ) -> StickUpdate

Reads snapshot from pad id: see StickUpdate. A pad that moves while none holds the sticks takes them.

Source

pub fn disconnect(&mut self, id: GamepadId) -> bool

Takes the sticks from id if it holds them, zeroing them; when it returns, its sticks must rest before they drive again. Returns whether it held them.

Source

pub const fn stick(&self, stick: Stick) -> (f32, f32)

A stick as the holding pad last reported it, filtered: (x, y), +Y up, inside the unit disc.

Trait Implementations§

Source§

impl Clone for ActivePad

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActivePad

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.