Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ps2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading