diff --git a/src/ps2.rs b/src/ps2.rs index 908d918..17743f5 100644 --- a/src/ps2.rs +++ b/src/ps2.rs @@ -323,11 +323,16 @@ impl Ps2Controller { /// Push a scancode byte to the keyboard queue (called from UI) pub fn push_kb(&self, key: KeyCode, pressed: bool) { - if !self.running.load(Ordering::Relaxed) { return; } + if !self.running.load(Ordering::Relaxed) { + eprintln!("PS2: push_kb({:?}, {}) DROPPED — not running", key, pressed); + return; + } let mut state = self.state.lock(); if !state.scanning_enabled { + eprintln!("PS2: push_kb({:?}, {}) DROPPED — scanning disabled", key, pressed); return; } + eprintln!("PS2: push_kb({:?}, {}) — scanning set={}, queue_len={}", key, pressed, state.scancode_set, state.rx_queue.len()); match state.scancode_set { 1 => { @@ -732,11 +737,16 @@ impl Ps2Controller { /// queue is congested (≥8 pending mouse packets) and the tail has the /// same button state. pub fn push_mouse_packet(&self, b0: u8, b1: u8, b2: u8) { - if !self.running.load(Ordering::Relaxed) { return; } + if !self.running.load(Ordering::Relaxed) { + eprintln!("PS2: mouse packet DROPPED — not running"); + return; + } let mut state = self.state.lock(); if !state.mouse_enabled { + eprintln!("PS2: mouse packet DROPPED — mouse disabled"); return; } + eprintln!("PS2: mouse packet b0={:02x} b1={:02x} b2={:02x} queue_len={}", b0, b1, b2, state.rx_queue.len()); let mouse_packets = state.mouse_queue_bytes / 3; let coalesced = if mouse_packets >= 8 { let len = state.rx_queue.len(); diff --git a/src/ui.rs b/src/ui.rs index c8e619b..53d9c4b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -557,6 +557,16 @@ impl Ui { } _ => (), }, + // When CursorGrabMode::Locked is active, winit sends raw mouse + // motion as DeviceEvent instead of CursorMoved. This is the + // primary motion source on Wayland and for trackpads on X11. + Event::DeviceEvent { event: winit::event::DeviceEvent::MouseMotion { delta }, .. } => { + if mouse_grabbed { + let mut md = mouse_delta.lock(); + md.accum.0 += delta.0 / scale as f64; + md.accum.1 += delta.1 / scale as f64; + } + }, _ => (), } }).unwrap();