Struct ev3dev_lang_rust::Ev3Button
source · [−]pub struct Ev3Button { /* private fields */ }Expand description
Ev3 brick button handler. Opens the corresponding /dev/input file handlers.
This implementation depends on the availability of the EVIOCGKEY ioctl to be able to read the button state buffer. See Linux kernel source in /include/uapi/linux/input.h for details.
use ev3dev_lang_rust::Ev3Button;
use std::thread;
use std::time::Duration;
let button = Ev3Button::new()?;
loop {
button.process();
println!("Is 'up' pressed: {}", button.is_up());
println!("Pressed buttons: {:?}", button.get_pressed_buttons());
thread::sleep(Duration::from_millis(100));
}Implementations
sourceimpl Ev3Button
impl Ev3Button
sourcepub fn new() -> Ev3Result<Self>
pub fn new() -> Ev3Result<Self>
Ev3 brick button handler. Opens the corresponding /dev/input file handlers.
sourcepub fn process(&self)
pub fn process(&self)
Check for currently pressed buttons. If the new state differs from the old state, call the appropriate button event handlers.
Get all pressed buttons by name.
sourcepub fn is_backspace(&self) -> bool
pub fn is_backspace(&self) -> bool
Check if ‘backspace’ button is pressed.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Ev3Button
impl !Send for Ev3Button
impl !Sync for Ev3Button
impl Unpin for Ev3Button
impl !UnwindSafe for Ev3Button
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more