pub struct GamepadManager { /* private fields */ }Expand description
Cross-platform gamepad state. One per App — the OS exposes a single
per-process controller subscription, not per-window.
Implementations§
Source§impl GamepadManager
impl GamepadManager
pub fn new() -> Self
Sourcepub fn state(&self, id: GamepadId) -> Option<GamepadState>
pub fn state(&self, id: GamepadId) -> Option<GamepadState>
Latest state for id, or None if that pad was never seen.
Sourcepub fn primary(&self) -> Option<GamepadState>
pub fn primary(&self) -> Option<GamepadState>
The first currently-connected pad — the common single-controller case, so a callback doesn’t have to track ids.
Sourcepub fn gamepads(&self) -> &[GamepadState]
pub fn gamepads(&self) -> &[GamepadState]
Every pad slot seen this session (connected or not).
Sourcepub fn set_state(&mut self, state: GamepadState) -> bool
pub fn set_state(&mut self, state: GamepadState) -> bool
Apply a state the backend delivered (upsert by id). Returns true
if it advanced (bit-pattern different from the previous slot), so an
idle controller doesn’t make every frame look “changed”.
Sourcepub fn clear_pending_event(&mut self)
pub fn clear_pending_event(&mut self)
Clear the pending-event flag. The dll calls this after the event pass
has collected the GamepadInput event.
Trait Implementations§
Source§impl Clone for GamepadManager
impl Clone for GamepadManager
Source§fn clone(&self) -> GamepadManager
fn clone(&self) -> GamepadManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GamepadManager
impl Debug for GamepadManager
Source§impl Default for GamepadManager
impl Default for GamepadManager
Source§fn default() -> GamepadManager
fn default() -> GamepadManager
Source§impl EventProvider for GamepadManager
impl EventProvider for GamepadManager
Source§fn get_pending_events(&self, timestamp: Instant) -> Vec<SyntheticEvent>
fn get_pending_events(&self, timestamp: Instant) -> Vec<SyntheticEvent>
Yield a window-level GamepadInput event when a pad’s state advanced
since the last drain (target = root; read it via
CallbackInfo::get_primary_gamepad / get_gamepad_state).
Source§impl PartialEq for GamepadManager
impl PartialEq for GamepadManager
Source§fn eq(&self, other: &GamepadManager) -> bool
fn eq(&self, other: &GamepadManager) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for GamepadManager
Auto Trait Implementations§
impl Freeze for GamepadManager
impl RefUnwindSafe for GamepadManager
impl Send for GamepadManager
impl Sync for GamepadManager
impl Unpin for GamepadManager
impl UnsafeUnpin for GamepadManager
impl UnwindSafe for GamepadManager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more