pub struct ButtonTracker { /* private fields */ }
Expand description
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§
Source§impl ButtonTracker
impl ButtonTracker
Sourcepub fn new() -> ButtonTracker
pub fn new() -> ButtonTracker
Creates a new ButtonTracker.
Sourcepub fn update(&mut self)
pub fn update(&mut self)
Copies the current input state into the last known button state. Call this in your update loop logic, once per update.
Sourcepub fn register_press(&mut self, button: &Button)
pub fn register_press(&mut self, button: &Button)
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.
Sourcepub fn register_release(&mut self, button: &Button)
pub fn register_release(&mut self, button: &Button)
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.
Sourcepub fn current_pressed(&self, button: &Button) -> bool
pub fn current_pressed(&self, button: &Button) -> bool
Checks if a button is pressed as of the current update. Will return false if a button has never been registered as pressed.
Sourcepub fn last_pressed(&self, button: &Button) -> bool
pub fn last_pressed(&self, button: &Button) -> bool
Checks if a button is pressed as of the last update. Will return false if a button has never been registered as pressed.
Trait Implementations§
Source§impl Clone for ButtonTracker
impl Clone for ButtonTracker
Source§fn clone(&self) -> ButtonTracker
fn clone(&self) -> ButtonTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more