From 6561685af88f5256e18ead84eb4c9d1860d6a8ba Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:34:13 +0100 Subject: [PATCH] Fix MouseEvent for usbhidd --- usbhidd/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usbhidd/src/main.rs b/usbhidd/src/main.rs index 8e11c70aed..259c3f323a 100644 --- a/usbhidd/src/main.rs +++ b/usbhidd/src/main.rs @@ -454,8 +454,11 @@ fn main() { binary_view.read_u8(16).expect("Failed to read array item") as u16 | (binary_view.read_u8(24).expect("Failed to read array item") as u16) << 8; - let x = ((raw_x as u32) * display_width) / 32767; - let y = ((raw_y as u32) * display_height) / 32767; + // ps2d uses 0..=65535 as range, while usb uses 0..=32767. orbital + // expects the former range, so multiply by two here to translate + // the usb coordinates to what orbital expects. + let x = raw_x * 2; + let y = raw_y * 2; log::trace!("Touchscreen {}, {} => {}, {}", raw_x, raw_y, x, y); if x != 0 || y != 0 {