Remove Event::Sync

This commit is contained in:
htrefil 2020-10-29 20:04:29 +01:00
parent 90d2f2d88d
commit 06d640cd20
2 changed files with 17 additions and 13 deletions

View file

@ -12,7 +12,6 @@ pub enum Event {
MouseScroll { delta: i32 },
MouseMove { axis: Axis, delta: i32 },
Key { direction: Direction, kind: KeyKind },
Sync,
}
impl Event {
@ -35,7 +34,6 @@ impl Event {
direction: Direction::Down,
kind,
} => (glue::EV_KEY as _, kind.to_raw(), 1),
Event::Sync => (glue::EV_SYN as _, glue::SYN_REPORT as _, 0),
};
input_event {
@ -68,7 +66,6 @@ impl Event {
direction: Direction::Down,
kind: KeyKind::from_raw(code as _)?,
},
(glue::EV_SYN, glue::SYN_REPORT, _) => Event::Sync,
_ => return None,
};

View file

@ -54,18 +54,25 @@ impl EventWriter {
// As far as tokio is concerned, the FD never becomes ready for writing, so just write it normally.
// If an error happens, it will be propagated to caller and the FD is opened in nonblocking mode anyway,
// so it shouldn't be an issue.
let events = [
(event.type_, event.code, event.value),
(glue::EV_SYN as _, glue::SYN_REPORT as _, 0), // Include EV_SYN.
];
for (r#type, code, value) in events.iter().cloned() {
let ret = unsafe {
glue::libevdev_uinput_write_event(
self.uinput as *const _,
event.type_ as _,
event.code as _,
event.value,
r#type as _,
code as _,
value,
)
};
if ret < 0 {
return Err(Error::from_raw_os_error(-ret));
}
}
Ok(())
}