[−][src]Struct ev3dev_lang_rust::Ev3Button
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,