[][src]Struct button_tracker::ButtonTracker

pub struct ButtonTracker { /* fields omitted */ }

Master struct for the button controller. Consumes button data from any source (though most commonly window event loop generated press events) and tracks them in an update loop friendly form.

Implementations

impl ButtonTracker[src]

pub fn new() -> ButtonTracker[src]

Creates a new ButtonTracker.

pub fn update(&mut self)[src]

Copies the current input state into the last known button state. Call this in your update loop logic, once per update.

pub fn register_press(&mut self, button: &Button)[src]

Tracks that a button is currently pressed. The most common way to do so is passing in Button contents from PressEvents generated from your relevant window class.

pub fn register_release(&mut self, button: &Button)[src]

Tracks that a button is currently un-pressed (or notes that a previously pressed button is now not pressed). The most common way to do so is passing in Button contents from ReleaseEvents generated from your relevant window class.

pub fn current_pressed(&self, button: &Button) -> bool[src]

Checks if a button is pressed as of the current update. Will return false if a button has never been registered as pressed.

pub fn last_pressed(&self, button: &Button) -> bool[src]

Checks if a button is pressed as of the last update. Will return false if a button has never been registered as pressed.

pub fn pressed_state(
    &self,
    button: &Button,
    last_state: bool,
    current_state: bool
) -> bool
[src]

Checks for a combination of a button press/release across the current and last update. Most useful for determining whether a button was just pressed or released.

Trait Implementations

impl Clone for ButtonTracker[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.