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