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 itdisconnects: 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
impl ActivePad
Sourcepub fn new(dead_zone: f32) -> Option<Self>
pub fn new(dead_zone: f32) -> Option<Self>
No pad holding the sticks, with dead_zone in 0.0..1.0; None
outside it.
Sourcepub fn activate(&mut self, id: GamepadId) -> bool
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.
Sourcepub fn release_until_neutral(&mut self)
pub fn release_until_neutral(&mut self)
Zeroes the sticks and holds every stick of every pad at zero until it has rested.
Sourcepub fn submit(
&mut self,
id: GamepadId,
snapshot: &GamepadSnapshot,
) -> StickUpdate
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.
Sourcepub fn disconnect(&mut self, id: GamepadId) -> bool
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ActivePad
impl RefUnwindSafe for ActivePad
impl Send for ActivePad
impl Sync for ActivePad
impl Unpin for ActivePad
impl UnsafeUnpin for ActivePad
impl UnwindSafe for ActivePad
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more