pub struct InputEvent(/* private fields */);Expand description
An input event received from or sent to an evdev.
Use InputEvent::kind to convert it to a matchable enum.
Implementations§
Source§impl InputEvent
impl InputEvent
Sourcepub const fn new(ty: EventType, raw_code: u16, raw_value: i32) -> Self
pub const fn new(ty: EventType, raw_code: u16, raw_value: i32) -> Self
Creates an InputEvent from raw values.
The timestamp of the event will be set to 0.
Sourcepub const fn zeroed() -> Self
pub const fn zeroed() -> Self
Creates an InputEvent with all fields zeroed out.
Useful as a dummy or filler value that will be overwritten with a “real” event soon.
This results in a Syn::REPORT event.
Sourcepub fn with_time(self, time: SystemTime) -> Self
pub fn with_time(self, time: SystemTime) -> Self
Changes the timestamp of self to the given SystemTime.
Note: InputEvent uses a timeval to store the timestamp, which has microsecond
resolution, while SystemTime can represent nanoseconds on Unix.
The value will be truncated or rounded to fit in the timeval.
Sourcepub fn time(&self) -> SystemTime
pub fn time(&self) -> SystemTime
Returns the timestamp stored in the event.
The clock source used to generate event timestamps can be changed by calling
Evdev::set_clockid.
Sourcepub fn kind(&self) -> EventKind
pub fn kind(&self) -> EventKind
Returns the EventKind this InputEvent encodes.
EventKind is a matchable, type-safe enum which is intended to be the primary way most
applications examine input events.
EventKind is #[non_exhaustive], so matching on it requires a wildcard arm that will
catch any events that don’t have a specific EventKind variant.
Future versions of evdevil might add new variants to catch those events.
Sourcepub fn event_type(&self) -> EventType
pub fn event_type(&self) -> EventType
Returns the EventType of this event.
Sourcepub fn raw_code(&self) -> u16
pub fn raw_code(&self) -> u16
Returns the raw event code field.
The code of an InputEvent generally describes what entity the event is about.
Depending on the type of event, it can describe a key, axis, sound, LED, or other entity.
Sourcepub fn raw_value(&self) -> i32
pub fn raw_value(&self) -> i32
Returns the raw event value field.
The value of an InputEvent describes the new state of the key, axis, LED, or other
entity.
Trait Implementations§
Source§impl Clone for InputEvent
impl Clone for InputEvent
Source§fn clone(&self) -> InputEvent
fn clone(&self) -> InputEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more