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

View file

@ -54,17 +54,24 @@ impl EventWriter {
// As far as tokio is concerned, the FD never becomes ready for writing, so just write it normally. // 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, // 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. // so it shouldn't be an issue.
let ret = unsafe { let events = [
glue::libevdev_uinput_write_event( (event.type_, event.code, event.value),
self.uinput as *const _, (glue::EV_SYN as _, glue::SYN_REPORT as _, 0), // Include EV_SYN.
event.type_ as _, ];
event.code as _,
event.value,
)
};
if ret < 0 { for (r#type, code, value) in events.iter().cloned() {
return Err(Error::from_raw_os_error(-ret)); let ret = unsafe {
glue::libevdev_uinput_write_event(
self.uinput as *const _,
r#type as _,
code as _,
value,
)
};
if ret < 0 {
return Err(Error::from_raw_os_error(-ret));
}
} }
Ok(()) Ok(())