#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct StylusAngle<T> {
pub azimuth: T,
pub altitude: T,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub enum TouchPhase {
Started,
Moved, Ended,
Cancelled,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct Touch {
pub phase: TouchPhase,
pub position: glam::Vec2,
pub stylus_angle: Option<StylusAngle<f32>>,
pub pressure: f32,
pub major_radius: f32,
pub interval: f32,
}
impl Touch {
pub fn touch_start(position: glam::Vec2) -> Self {
Self::new(position, TouchPhase::Started)
}
pub fn touch_move(position: glam::Vec2) -> Self {
Self::new(position, TouchPhase::Moved)
}
pub fn touch_end(position: glam::Vec2) -> Self {
Self::new(position, TouchPhase::Ended)
}
fn new(position: glam::Vec2, phase: TouchPhase) -> Self {
Touch {
position,
phase,
stylus_angle: None,
pressure: 0.0,
major_radius: 0.0,
interval: 0.0,
}
}
}