Struct ev3dev_lang_rust::Ev3Button[][src]

pub struct Ev3Button { /* fields omitted */ }
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

Ev3 brick button handler. Opens the corresponding /dev/input file handlers.

Check for currenly pressed buttons. If the new state differs from the old state, call the appropriate button event handlers.

Get all pressed buttons by name.

Check if ‘up’ button is pressed.

Check if ‘down’ button is pressed.

Check if ‘left’ button is pressed.

Check if ‘right’ button is pressed.

Check if ‘enter’ button is pressed.

Check if ‘backspace’ button is pressed.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.