-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathpointer.rs
More file actions
65 lines (51 loc) · 1.4 KB
/
Copy pathpointer.rs
File metadata and controls
65 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Handle pointer events.
pub mod button;
pub mod mouse;
pub mod tablet;
pub mod touch;
mod event;
pub use event::Event;
/// The kind of device that produced a pointer event.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Kind {
/// A mouse.
Mouse,
/// A finger touching a screen.
Touch(touch::Finger),
/// A tablet tool.
TabletTool(tablet::Kind),
/// An unknown pointer device.
Unknown,
}
/// The device and associated data that produced a pointer event.
#[derive(Debug, Clone, PartialEq)]
pub enum Source {
/// A mouse.
Mouse,
/// A finger touching a screen.
Touch {
/// The identifier of the finger.
finger_id: touch::Finger,
/// The force of the touch, if reported by the device.
force: Option<touch::Force>,
},
/// A tablet tool.
TabletTool {
/// The kind of tablet tool.
kind: tablet::Kind,
/// Data describing how the tool is held and used.
data: tablet::Data,
},
/// An unknown pointer device.
Unknown,
}
impl From<Source> for crate::pointer::Kind {
fn from(source: Source) -> Self {
match source {
Source::Mouse => Self::Mouse,
Source::Touch { finger_id, .. } => Self::Touch(finger_id),
Source::TabletTool { kind, .. } => Self::TabletTool(kind),
Source::Unknown => Self::Unknown,
}
}
}