[][src]Struct ev3dev_lang_rust::Ev3Button

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));
}

Methods

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

impl Clone for Ev3Button[src]

impl Debug for Ev3Button[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.