1#[repr(C)]
2#[derive(Copy, Clone, Debug)]
3pub struct StylusAngle<T> {
4 pub azimuth: T,
5 pub altitude: T,
6}
7
8#[repr(C)]
9#[derive(Copy, Clone, Debug)]
10pub enum TouchPhase {
11 Started,
12 Moved, Ended,
14 Cancelled,
15}
16
17#[repr(C)]
18#[derive(Copy, Clone, Debug)]
19pub struct Touch {
20 pub phase: TouchPhase,
21 pub position: glam::Vec2,
22 pub stylus_angle: Option<StylusAngle<f32>>,
24 pub pressure: f32,
25 pub major_radius: f32,
27 pub interval: f32,
29}
30
31impl Touch {
32 pub fn touch_start(position: glam::Vec2) -> Self {
33 Self::new(position, TouchPhase::Started)
34 }
35
36 pub fn touch_move(position: glam::Vec2) -> Self {
37 Self::new(position, TouchPhase::Moved)
38 }
39
40 pub fn touch_end(position: glam::Vec2) -> Self {
41 Self::new(position, TouchPhase::Ended)
42 }
43
44 fn new(position: glam::Vec2, phase: TouchPhase) -> Self {
45 Touch {
46 position,
47 phase,
48 stylus_angle: None,
49 pressure: 0.0,
50 major_radius: 0.0,
51 interval: 0.0,
52 }
53 }
54}