You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/embed/rust/src/ui/model_t1/event.rs

30 lines
719 B

use crate::error;
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum T1Button {
Left,
Right,
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum ButtonEvent {
ButtonPressed(T1Button),
ButtonReleased(T1Button),
}
impl ButtonEvent {
pub fn new(event: u32, button: u32, _unused: u32) -> Result<Self, error::Error> {
let button = match button {
0 => T1Button::Left,
1 => T1Button::Right,
_ => return Err(error::Error::OutOfRange),
};
let result = match event {
1 => Self::ButtonPressed(button),
2 => Self::ButtonReleased(button),
_ => return Err(error::Error::OutOfRange),
};
Ok(result)
}
}