Struct ev3dev_lang_rust::Ev3Button [−][src]
pub struct Ev3Button { /* fields omitted */ }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
impl Ev3Button[src]
impl Ev3Button[src]pub fn new() -> Ev3Result<Self>[src]
Ev3 brick button handler. Opens the corresponding /dev/input file handlers.
pub fn process(&self)[src]
Check for currenly pressed buttons. If the new state differs from the old state, call the appropriate button event handlers.
pub fn get_pressed_buttons(&self) -> HashSet<String>[src]
Get all pressed buttons by name.
pub fn is_up(&self) -> bool[src]
Check if ‘up’ button is pressed.
pub fn is_down(&self) -> bool[src]
Check if ‘down’ button is pressed.
pub fn is_left(&self) -> bool[src]
Check if ‘left’ button is pressed.
pub fn is_right(&self) -> bool[src]
Check if ‘right’ button is pressed.
pub fn is_enter(&self) -> bool[src]
Check if ‘enter’ button is pressed.
pub fn is_backspace(&self) -> bool[src]
Check if ‘backspace’ button is pressed.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Ev3Button
impl !RefUnwindSafe for Ev3Buttonimpl !UnwindSafe for Ev3Button
impl !UnwindSafe for Ev3Button