Struct button_tracker::ButtonController [−][src]
pub struct ButtonController { /* 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.
Methods
impl ButtonController[src]
impl ButtonControllerpub fn new() -> ButtonController[src]
pub fn new() -> ButtonControllerCreates a new ButtonController.
pub fn update(&mut self)[src]
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.
pub fn register_press(&mut self, button: &Button)[src]
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.
pub fn register_release(&mut self, button: &Button)[src]
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.
pub fn current_pressed(&mut self, button: &Button) -> bool[src]
pub fn current_pressed(&mut self, button: &Button) -> boolChecks 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(&mut self, button: &Button) -> bool[src]
pub fn last_pressed(&mut self, button: &Button) -> boolChecks 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(
&mut self,
button: &Button,
last_state: bool,
current_state: bool
) -> bool[src]
pub fn pressed_state(
&mut self,
button: &Button,
last_state: bool,
current_state: bool
) -> boolChecks 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 ButtonController[src]
impl Clone for ButtonControllerfn clone(&self) -> ButtonController[src]
fn clone(&self) -> ButtonControllerReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
Auto Trait Implementations
impl Send for ButtonController
impl Send for ButtonControllerimpl Sync for ButtonController
impl Sync for ButtonController