diff --git a/input/src/event.rs b/input/src/event.rs index 7b3861f..9f15ab6 100644 --- a/input/src/event.rs +++ b/input/src/event.rs @@ -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, }; diff --git a/input/src/event_writer.rs b/input/src/event_writer.rs index 6451266..2035b44 100644 --- a/input/src/event_writer.rs +++ b/input/src/event_writer.rs @@ -54,17 +54,24 @@ 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 ret = unsafe { - glue::libevdev_uinput_write_event( - self.uinput as *const _, - event.type_ as _, - event.code as _, - event.value, - ) - }; + let events = [ + (event.type_, event.code, event.value), + (glue::EV_SYN as _, glue::SYN_REPORT as _, 0), // Include EV_SYN. + ]; - if ret < 0 { - return Err(Error::from_raw_os_error(-ret)); + for (r#type, code, value) in events.iter().cloned() { + 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(())