Struct gamepad::ButtonState
source · pub struct ButtonState { /* private fields */ }
Implementations§
source§impl ButtonState
impl ButtonState
pub fn new(is_pressed: bool, was_pressed: bool) -> Self
pub fn is_pressed(&self) -> bool
sourcepub fn is_just_pressed(&self) -> bool
pub fn is_just_pressed(&self) -> bool
Examples found in repository?
examples/gamepad.rs (line 13)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
pub fn main() {
let mut engine = GamepadEngine::new();
loop {
engine.update().unwrap();
for gamepad in engine.gamepads() {
for (key, button) in gamepad.buttons() {
if button.is_just_pressed() {
println!("Just Pressed: {:?}", key);
}
}
for (_, joystick) in gamepad.joysticks() {
println!("{:?}", joystick);
}
}
std::thread::sleep(Duration::from_millis(16));
}
}
pub fn is_just_released(&self) -> bool
Trait Implementations§
source§impl Clone for ButtonState
impl Clone for ButtonState
source§fn clone(&self) -> ButtonState
fn clone(&self) -> ButtonState
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ButtonState
impl Debug for ButtonState
source§impl Default for ButtonState
impl Default for ButtonState
source§fn default() -> ButtonState
fn default() -> ButtonState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for ButtonState
impl Send for ButtonState
impl Sync for ButtonState
impl Unpin for ButtonState
impl UnwindSafe for ButtonState
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