sweetacid_evdev/
constants.rs

1/// Event types supported by the device.
2///
3/// This is implemented as a newtype around the u16 "type" field of `libc::input_event`.
4#[derive(Copy, Clone, PartialEq, Eq)]
5pub struct EventType(pub u16);
6
7evdev_enum!(
8    EventType,
9    Array,
10    /// A bookkeeping event. Usually not important to applications.
11    SYNCHRONIZATION = 0x00,
12    /// A key changed state. A key, or button, is usually a momentary switch (in the circuit sense). It has two
13    /// states: down, or up. There are events for when keys are pressed (become down) and
14    /// released (become up). There are also "key repeats", where multiple events are sent
15    /// while a key is down.
16    KEY = 0x01,
17    /// Movement on a relative axis. There is no absolute coordinate frame, just the fact that
18    /// there was a change of a certain amount of units. Used for things like mouse movement or
19    /// scroll wheels.
20    RELATIVE = 0x02,
21    /// Movement on an absolute axis. Used for things such as touch events and joysticks.
22    ABSOLUTE = 0x03,
23    /// Miscellaneous events that don't fall into other categories. I'm not quite sure when
24    /// these happen or what they correspond to.
25    MISC = 0x04,
26    /// Change in a switch value. Switches are boolean conditions and usually correspond to a
27    /// toggle switch of some kind in hardware.
28    SWITCH = 0x05,
29    /// An LED was toggled.
30    LED = 0x11,
31    /// A sound was made.
32    SOUND = 0x12,
33    /// There are no events of this type, to my knowledge, but represents metadata about key
34    /// repeat configuration.
35    REPEAT = 0x14,
36    /// I believe there are no events of this type, but rather this is used to represent that
37    /// the device can create haptic effects.
38    FORCEFEEDBACK = 0x15,
39    /// I think this is unused?
40    POWER = 0x16,
41    /// A force feedback effect's state changed.
42    FORCEFEEDBACKSTATUS = 0x17,
43);
44
45impl EventType {
46    pub(crate) const COUNT: usize = libc::EV_CNT;
47}
48
49/// A "synchronization" message type published by the kernel into the events stream.
50#[derive(Copy, Clone, PartialEq, Eq)]
51pub struct Synchronization(pub u16);
52
53evdev_enum!(
54    Synchronization,
55    /// Used to mark the end of a single atomic "reading" from the device.
56    SYN_REPORT = 0,
57    /// Appears to be unused.
58    SYN_CONFIG = 1,
59    /// "Used to synchronize and separate touch events"
60    SYN_MT_REPORT = 2,
61    /// Ring buffer filled, events were dropped.
62    SYN_DROPPED = 3,
63);
64
65/// Device properties.
66#[derive(Copy, Clone, PartialEq, Eq)]
67pub struct PropType(pub u16);
68
69evdev_enum!(
70    PropType,
71    Array,
72    /// This input device needs a pointer ("cursor") for the user to know its state.
73    POINTER = 0x00,
74    /// "direct input devices", according to the header.
75    DIRECT = 0x01,
76    /// "has button(s) under pad", according to the header.
77    BUTTONPAD = 0x02,
78    /// Touch rectangle only (I think this means that if there are multiple touches, then the
79    /// bounding rectangle of all the touches is returned, not each touch).
80    SEMI_MT = 0x03,
81    /// "softbuttons at top of pad", according to the header.
82    TOPBUTTONPAD = 0x04,
83    /// Is a pointing stick ("nub" etc, https://xkcd.com/243/)
84    POINTING_STICK = 0x05,
85    /// Has an accelerometer. Probably reports relative events in that case?
86    ACCELEROMETER = 0x06,
87);
88
89impl PropType {
90    pub(crate) const COUNT: usize = libc::INPUT_PROP_CNT;
91}
92
93/// A type of relative axis measurement, typically produced by mice.
94#[derive(Copy, Clone, PartialEq, Eq)]
95pub struct RelativeAxisType(pub u16);
96
97evdev_enum!(
98    RelativeAxisType,
99    Array,
100    REL_X = 0x00,
101    REL_Y = 0x01,
102    REL_Z = 0x02,
103    REL_RX = 0x03,
104    REL_RY = 0x04,
105    REL_RZ = 0x05,
106    REL_HWHEEL = 0x06,
107    REL_DIAL = 0x07,
108    REL_WHEEL = 0x08,
109    REL_MISC = 0x09,
110    REL_RESERVED = 0x0a,
111    REL_WHEEL_HI_RES = 0x0b,
112    REL_HWHEEL_HI_RES = 0x0c,
113);
114
115impl RelativeAxisType {
116    pub(crate) const COUNT: usize = libc::REL_CNT;
117}
118
119/// A type of absolute axis measurement, typically used for touch events and joysticks.
120#[derive(Copy, Clone, PartialEq, Eq)]
121pub struct AbsoluteAxisType(pub u16);
122
123evdev_enum!(
124    AbsoluteAxisType,
125    Array,
126    ABS_X = 0x00,
127    ABS_Y = 0x01,
128    ABS_Z = 0x02,
129    ABS_RX = 0x03,
130    ABS_RY = 0x04,
131    ABS_RZ = 0x05,
132    ABS_THROTTLE = 0x06,
133    ABS_RUDDER = 0x07,
134    ABS_WHEEL = 0x08,
135    ABS_GAS = 0x09,
136    ABS_BRAKE = 0x0a,
137    ABS_HAT0X = 0x10,
138    ABS_HAT0Y = 0x11,
139    ABS_HAT1X = 0x12,
140    ABS_HAT1Y = 0x13,
141    ABS_HAT2X = 0x14,
142    ABS_HAT2Y = 0x15,
143    ABS_HAT3X = 0x16,
144    ABS_HAT3Y = 0x17,
145    ABS_PRESSURE = 0x18,
146    ABS_DISTANCE = 0x19,
147    ABS_TILT_X = 0x1a,
148    ABS_TILT_Y = 0x1b,
149    ABS_TOOL_WIDTH = 0x1c,
150    ABS_VOLUME = 0x20,
151    ABS_MISC = 0x28,
152    /// "MT slot being modified"
153    ABS_MT_SLOT = 0x2f,
154    /// "Major axis of touching ellipse"
155    ABS_MT_TOUCH_MAJOR = 0x30,
156    /// "Minor axis (omit if circular)"
157    ABS_MT_TOUCH_MINOR = 0x31,
158    /// "Major axis of approaching ellipse"
159    ABS_MT_WIDTH_MAJOR = 0x32,
160    /// "Minor axis (omit if circular)"
161    ABS_MT_WIDTH_MINOR = 0x33,
162    /// "Ellipse orientation"
163    ABS_MT_ORIENTATION = 0x34,
164    /// "Center X touch position"
165    ABS_MT_POSITION_X = 0x35,
166    /// "Center Y touch position"
167    ABS_MT_POSITION_Y = 0x36,
168    /// "Type of touching device"
169    ABS_MT_TOOL_TYPE = 0x37,
170    /// "Group a set of packets as a blob"
171    ABS_MT_BLOB_ID = 0x38,
172    /// "Unique ID of the initiated contact"
173    ABS_MT_TRACKING_ID = 0x39,
174    /// "Pressure on contact area"
175    ABS_MT_PRESSURE = 0x3a,
176    /// "Contact over distance"
177    ABS_MT_DISTANCE = 0x3b,
178    /// "Center X tool position"
179    ABS_MT_TOOL_X = 0x3c,
180    /// "Center Y tool position"
181    ABS_MT_TOOL_Y = 0x3d,
182);
183
184impl AbsoluteAxisType {
185    pub(crate) const COUNT: usize = libc::ABS_CNT;
186}
187
188/// An event type corresponding to a physical or virtual switch.
189#[derive(Copy, Clone, PartialEq, Eq)]
190pub struct SwitchType(pub u16);
191
192evdev_enum!(
193    SwitchType,
194    Array,
195    /// "set = lid shut"
196    SW_LID = 0x00,
197    /// "set = tablet mode"
198    SW_TABLET_MODE = 0x01,
199    /// "set = inserted"
200    SW_HEADPHONE_INSERT = 0x02,
201    /// "rfkill master switch, type 'any'"
202    SW_RFKILL_ALL = 0x03,
203    /// "set = inserted"
204    SW_MICROPHONE_INSERT = 0x04,
205    /// "set = plugged into doc"
206    SW_DOCK = 0x05,
207    /// "set = inserted"
208    SW_LINEOUT_INSERT = 0x06,
209    /// "set = mechanical switch set"
210    SW_JACK_PHYSICAL_INSERT = 0x07,
211    /// "set  = inserted"
212    SW_VIDEOOUT_INSERT = 0x08,
213    /// "set = lens covered"
214    SW_CAMERA_LENS_COVER = 0x09,
215    /// "set = keypad slide out"
216    SW_KEYPAD_SLIDE = 0x0a,
217    /// "set = front proximity sensor active"
218    SW_FRONT_PROXIMITY = 0x0b,
219    /// "set = rotate locked/disabled"
220    SW_ROTATE_LOCK = 0x0c,
221    /// "set = inserted"
222    SW_LINEIN_INSERT = 0x0d,
223    /// "set = device disabled"
224    SW_MUTE_DEVICE = 0x0e,
225    /// "set = pen inserted"
226    SW_PEN_INSERTED = 0x0f,
227    /// "set = cover closed"
228    SW_MACHINE_COVER = 0x10,
229);
230
231impl SwitchType {
232    pub(crate) const COUNT: usize = libc::SW_CNT;
233}
234
235/// LEDs specified by USB HID.
236#[derive(Copy, Clone, PartialEq, Eq)]
237pub struct LedType(pub u16);
238
239evdev_enum!(
240    LedType,
241    Array,
242    LED_NUML = 0x00,
243    LED_CAPSL = 0x01,
244    LED_SCROLLL = 0x02,
245    LED_COMPOSE = 0x03,
246    LED_KANA = 0x04,
247    /// "Stand-by"
248    LED_SLEEP = 0x05,
249    LED_SUSPEND = 0x06,
250    LED_MUTE = 0x07,
251    /// "Generic indicator"
252    LED_MISC = 0x08,
253    /// "Message waiting"
254    LED_MAIL = 0x09,
255    /// "External power connected"
256    LED_CHARGING = 0x0a,
257);
258
259impl LedType {
260    pub(crate) const COUNT: usize = libc::LED_CNT;
261}
262
263/// Various miscellaneous event types.
264#[derive(Copy, Clone, PartialEq, Eq)]
265pub struct MiscType(pub u16);
266
267evdev_enum!(
268    MiscType,
269    Array,
270    /// Serial number, only exported for tablets ("Transducer Serial Number")
271    MSC_SERIAL = 0x00,
272    /// Only used by the PowerMate driver, right now.
273    MSC_PULSELED = 0x01,
274    /// Completely unused.
275    MSC_GESTURE = 0x02,
276    /// "Raw" event, rarely used.
277    MSC_RAW = 0x03,
278    /// Key scancode
279    MSC_SCAN = 0x04,
280    /// Completely unused.
281    MSC_TIMESTAMP = 0x05,
282);
283
284impl MiscType {
285    pub(crate) const COUNT: usize = libc::MSC_CNT;
286}
287
288// pub enum FFStatusDataIndex {
289//     FF_STATUS_STOPPED = 0x00,
290//     FF_STATUS_PLAYING = 0x01,
291// }
292
293// #[derive(Copy, Clone, Copy, Clone)]
294// pub enum FFEffect {
295//     FF_RUMBLE = 0x50,
296//     FF_PERIODIC = 0x51,
297//     FF_CONSTANT = 0x52,
298//     FF_SPRING = 0x53,
299//     FF_FRICTION = 0x54,
300//     FF_DAMPER = 0x55,
301//     FF_INERTIA = 0x56,
302//     FF_RAMP = 0x57,
303//     FF_SQUARE = 0x58,
304//     FF_TRIANGLE = 0x59,
305//     FF_SINE = 0x5a,
306//     FF_SAW_UP = 0x5b,
307//     FF_SAW_DOWN = 0x5c,
308//     FF_CUSTOM = 0x5d,
309//     FF_GAIN = 0x60,
310//     FF_AUTOCENTER = 0x61,
311// }
312
313// impl FFEffect {
314//     // Needs to be a multiple of 8
315//     pub const COUNT: usize = libc::FF_CNT;
316// }
317
318// #[derive(Copy, Clone, PartialEq, Eq)]
319// pub struct RepeatType(pub u16);
320
321// evdev_enum!(RepeatType, REP_DELAY = 0x00, REP_PERIOD = 0x01,);
322
323// impl RepeatType {
324//     pub(crate) const COUNT: usize = libc::REP_CNT;
325// }
326
327/// A type associated with simple sounds, such as beeps or tones.
328#[derive(Copy, Clone, PartialEq, Eq)]
329pub struct SoundType(pub u16);
330
331evdev_enum!(
332    SoundType,
333    Array,
334    SND_CLICK = 0x00,
335    SND_BELL = 0x01,
336    SND_TONE = 0x02,
337);
338
339impl SoundType {
340    pub(crate) const COUNT: usize = libc::SND_CNT;
341}