Skip to main content

denise_evdev/
codes.rs

1//! The subset of `linux/input-event-codes.h` this backend needs.
2//!
3//! Spelled out rather than pulled from a binding crate so the translation layer
4//! stays platform-independent and testable off Linux.
5
6/// Event types.
7pub mod ev {
8    /// Frame separator.
9    pub const SYN: u16 = 0x00;
10    /// Keys and buttons.
11    pub const KEY: u16 = 0x01;
12    /// Relative axes.
13    pub const REL: u16 = 0x02;
14    /// Absolute axes.
15    pub const ABS: u16 = 0x03;
16}
17
18/// `EV_SYN` codes.
19pub mod syn {
20    /// End of an event frame.
21    pub const REPORT: u16 = 0;
22    /// The kernel dropped events; state must be resynchronised.
23    pub const DROPPED: u16 = 3;
24}
25
26/// `EV_REL` codes.
27pub mod rel {
28    /// Horizontal motion.
29    pub const X: u16 = 0x00;
30    /// Vertical motion.
31    pub const Y: u16 = 0x01;
32    /// Horizontal wheel, in detents.
33    pub const HWHEEL: u16 = 0x06;
34    /// Vertical wheel, in detents.
35    pub const WHEEL: u16 = 0x08;
36}
37
38/// `EV_ABS` codes.
39pub mod abs {
40    /// Absolute horizontal position.
41    pub const X: u16 = 0x00;
42    /// Absolute vertical position.
43    pub const Y: u16 = 0x01;
44    /// Selects the multitouch slot subsequent events apply to.
45    pub const MT_SLOT: u16 = 0x2f;
46    /// Contact horizontal position.
47    pub const MT_POSITION_X: u16 = 0x35;
48    /// Contact vertical position.
49    pub const MT_POSITION_Y: u16 = 0x36;
50    /// Contact identity; `-1` ends the contact in this slot.
51    pub const MT_TRACKING_ID: u16 = 0x39;
52}
53
54/// `EV_KEY` codes for buttons.
55pub mod btn {
56    /// Primary pointer button.
57    pub const LEFT: u16 = 0x110;
58    /// Secondary pointer button.
59    pub const RIGHT: u16 = 0x111;
60    /// Middle pointer button.
61    pub const MIDDLE: u16 = 0x112;
62    /// A contact is present. Single-touch panels report this instead of slots.
63    pub const TOUCH: u16 = 0x14a;
64    /// One finger is on a touchpad. What a touchpad has and a pen tablet lacks.
65    pub const TOOL_FINGER: u16 = 0x145;
66    /// A pen is in range. What a pen tablet has.
67    pub const TOOL_PEN: u16 = 0x140;
68    /// Five fingers are down.
69    pub const TOOL_QUINTTAP: u16 = 0x148;
70    /// Two fingers are down.
71    pub const TOOL_DOUBLETAP: u16 = 0x14d;
72    /// Three fingers are down.
73    pub const TOOL_TRIPLETAP: u16 = 0x14e;
74    /// Four fingers are down.
75    pub const TOOL_QUADTAP: u16 = 0x14f;
76}
77
78/// `EV_KEY` values.
79pub mod key_value {
80    /// Released.
81    pub const UP: i32 = 0;
82    /// Pressed.
83    pub const DOWN: i32 = 1;
84    /// Held long enough to auto-repeat.
85    pub const REPEAT: i32 = 2;
86}