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

25 lines
607 B
Rust

use core::convert::TryInto;
use crate::{error, ui::geometry::Point};
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum TouchEvent {
TouchStart(Point),
TouchMove(Point),
TouchEnd(Point),
}
impl TouchEvent {
pub fn new(event: u32, x: u32, y: u32) -> Result<Self, error::Error> {
let point = Point::new(x.try_into()?, y.try_into()?);
let result = match event {
1 => Self::TouchStart(point),
2 => Self::TouchMove(point),
4 => Self::TouchEnd(point),
_ => return Err(error::Error::OutOfRange),
};
Ok(result)
}
}