Expand description
Input event types and enumerations.
All device event iterators will yield InputEvent, the base event type.
Events carry the following information:
- Timestamp (
InputEvent::time): The time at which the event has been inserted into the kernel buffer. The default time source is the system’s real-time clock, which is also used bySystemTime::now. It can be changed by callingEvdev::set_clockid. - Event Type (
InputEvent::event_type): The broad category of event. TheEventTypedetermines which of the event wrappers listed below is responsible. - Event Code (
InputEvent::raw_code): Au16identifying the button, axis, or other object affected by the event. This is typically wrapped in a type likeSyn,Key,AbsorReland accessed from a specific event wrapper. - Event Value (
InputEvent::raw_value): Ani32describing what happened to the object identified by the code. This can be the new state of anAbsaxis, an incremental movement of aRelaxis, the new state (pressed/released/repeated) of aKeyorSwitch, or some other value.
InputEvent::kind can be used to obtain an EventKind, which can be conveniently matched
on to handle the different types of events.
Devices may emit a variety of different types of events, which are all wrapped by the following Rust types in this module:
SynEventKeyEventRelEventAbsEventSwitchEventMiscEventLedEventRepeatEventSoundEventUinputEventForceFeedbackEvent
All of these event types can be converted to EventKind and InputEvent via From and
Into, and can be Dereferenced to obtain the InputEvent they wrap.
§Serde support
If the serde feature is enabled, implementations of Serialize and Deserialize will be
provided for the following types:
For human-readable formats, the serde representation will use the evdev constant name if the
value has one (eg. KEY_F1, ABS_Y, …), and the raw u16 code if it does not.
Deserialization from a human-readable format will accept either.
Note that this means that when a new key or axis name is added in a later version of this crate,
older versions will not be able to deserialize it.
evdevil guarantees only old->new compatibility between non-breaking versions, not new->old.
Note also that some values have multiple names.
For example, Key::BTN_TRIGGER_HAPPY is the same value as Key::BTN_TRIGGER_HAPPY1.
Deserialization will accept either name, but serialization has to pick a single name, which is
typically the first one with a given value, but is not generally guaranteed to be any specific
constant name.
For non-human-readable formats, the raw numeric code is always used, and formats that aren’t self-describing (like postcard) are supported. There is also no compatibility concern in case new key or axis names are added in later versions.
Structs§
- Abs
- An absolute axis identifier.
- AbsEvent
- An absolute axis change.
- Event
Type - Types of
InputEvents - Force
Feedback Event - Starts or stops previously uploaded force-feedback effects.
- Input
Event - An input event received from or sent to an evdev.
- Key
- An evdev key or button identifier.
- KeyEvent
- A key press/release/repeat event.
- KeyState
- State of a
Key, stored as the value of aKeyEvent. - Led
- A device LED or other indicator.
- LedEvent
- Reports or changes the state of device LEDs.
- Misc
- A miscellaneous event type (
MSC_*). - Misc
Event - Miscellaneous management events.
- MtTool
Type - Multi-touch contact tool.
- Rel
- A relative axis identifier.
- RelEvent
- A relative axis change.
- Repeat
- Autorepeat setting.
- Repeat
Event - The key repeat settings have been changed.
- Sound
- A sound effect.
- Sound
Event - Plays simple sounds on the device.
- Switch
- A binary switch (
SW_*). - Switch
Event - A switch state change.
- Syn
- Synchronization event types.
- SynEvent
- A synchronization event.
- Uinput
Code - Event codes for
UinputEvent. - Uinput
Event - Internal events sent to
UinputDevices.
Enums§
- Event
Kind - Enumeration of event types.
- Force
Feedback Code - Code of a
ForceFeedbackEvent.