1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-06 14:52:33 +00:00
trezor-firmware/core/embed/rust/src/ui/model_t1/event.rs
Martin Milata 4d60c10330 feat(core/rust): add support for T1 UI
[no changelog]
2021-11-24 15:36:34 +01:00

30 lines
719 B
Rust

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