From eaa3d9d5b3937aa1fafe0e260a8b2805c0751977 Mon Sep 17 00:00:00 2001 From: Ferdinand Schober Date: Tue, 9 Jul 2024 18:58:01 +0200 Subject: [PATCH] fix windows + rename to dx/dy everywhere --- input-capture/src/windows.rs | 5 +++-- input-emulation/src/wlroots.rs | 6 +----- input-event/src/lib.rs | 6 +----- input-event/src/proto.rs | 12 ++++-------- src/emulation_test.rs | 6 +++--- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/input-capture/src/windows.rs b/input-capture/src/windows.rs index 9c92501..9a506c4 100644 --- a/input-capture/src/windows.rs +++ b/input-capture/src/windows.rs @@ -145,10 +145,11 @@ fn to_mouse_event(wparam: WPARAM, lparam: LPARAM) -> Option { let (x, y) = (mouse_low_level.pt.x, mouse_low_level.pt.y); let (ex, ey) = ENTRY_POINT; let (dx, dy) = (x - ex, y - ey); + let (dx, dy) = (dx as f64, dy as f64); Some(PointerEvent::Motion { time: 0, - relative_x: dx as f64, - relative_y: dy as f64, + dx: dx as f64, + dy: dy as f64, }) }, WPARAM(p) if p == WM_MOUSEWHEEL as usize => Some(PointerEvent::AxisDiscrete120 { diff --git a/input-emulation/src/wlroots.rs b/input-emulation/src/wlroots.rs index 0abb61e..7d545c8 100644 --- a/input-emulation/src/wlroots.rs +++ b/input-emulation/src/wlroots.rs @@ -177,11 +177,7 @@ impl VirtualInput { match event { Event::Pointer(e) => { match e { - PointerEvent::Motion { - time, - dx: relative_x, - dy: relative_y, - } => self.pointer.motion(time, relative_x, relative_y), + PointerEvent::Motion { time, dx, dy } => self.pointer.motion(time, dx, dy), PointerEvent::Button { time, button, diff --git a/input-event/src/lib.rs b/input-event/src/lib.rs index 5d9bf0b..c66c214 100644 --- a/input-event/src/lib.rs +++ b/input-event/src/lib.rs @@ -67,11 +67,7 @@ pub enum Event { impl Display for PointerEvent { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - PointerEvent::Motion { - time: _, - dx: relative_x, - dy: relative_y, - } => write!(f, "motion({relative_x},{relative_y})"), + PointerEvent::Motion { time: _, dx, dy } => write!(f, "motion({dx},{dy})"), PointerEvent::Button { time: _, button, diff --git a/input-event/src/proto.rs b/input-event/src/proto.rs index 0ac4aca..7397569 100644 --- a/input-event/src/proto.rs +++ b/input-event/src/proto.rs @@ -127,15 +127,11 @@ impl From<&PointerEvent> for Vec { fn from(event: &PointerEvent) -> Self { let id = vec![event.event_type() as u8]; let data = match event { - PointerEvent::Motion { - time, - dx: relative_x, - dy: relative_y, - } => { + PointerEvent::Motion { time, dx, dy } => { let time = time.to_be_bytes(); - let relative_x = relative_x.to_be_bytes(); - let relative_y = relative_y.to_be_bytes(); - [&time[..], &relative_x[..], &relative_y[..]].concat() + let dx = dx.to_be_bytes(); + let dy = dy.to_be_bytes(); + [&time[..], &dx[..], &dy[..]].concat() } PointerEvent::Button { time, diff --git a/src/emulation_test.rs b/src/emulation_test.rs index 64d1346..f146f6b 100644 --- a/src/emulation_test.rs +++ b/src/emulation_test.rs @@ -37,11 +37,11 @@ async fn input_emulation_test(config: Config) -> Result<()> { if new_offset != offset { let relative_motion = (new_offset.0 - offset.0, new_offset.1 - offset.1); offset = new_offset; - let (relative_x, relative_y) = (relative_motion.0 as f64, relative_motion.1 as f64); + let (dx, dy) = (relative_motion.0 as f64, relative_motion.1 as f64); let event = Event::Pointer(PointerEvent::Motion { time: 0, - dx: relative_x, - dy: relative_y, + dx: dx, + dy: dy, }); emulation.consume(event, 0).await?; }