mirror of
https://github.com/htrefil/rkvm.git
synced 2025-01-30 20:34:13 +01:00
Remove Event::Sync
This commit is contained in:
parent
90d2f2d88d
commit
06d640cd20
2 changed files with 17 additions and 13 deletions
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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(())
|
||||
|
|
Loading…
Add table
Reference in a new issue