summaryrefslogtreecommitdiffstats
path: root/rsnix/src/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--rsnix/src/fs.rs37
1 files changed, 13 insertions, 24 deletions
diff --git a/rsnix/src/fs.rs b/rsnix/src/fs.rs
index 0b7a772..5fc6d7a 100644
--- a/rsnix/src/fs.rs
+++ b/rsnix/src/fs.rs
@@ -713,34 +713,23 @@ fn dev_text(dev: CharDevice, _pos: u64) -> String {
713 } 713 }
714} 714}
715 715
716/// Render `/dev/mouse`: drain every pending PS/2 event (up to 32) into one 716/// Render `/dev/mouse`: the current cursor state (position + buttons).
717/// line each, so `cat /dev/mouse` shows the movement that happened since 717/// The cursor task owns the PS/2 ring, so this is a position device —
718/// the last read. Falls back to a clear message when there is no device or 718/// the GUI-correct semantic — rather than an event drain.
719/// nothing pending.
720fn mouse_text() -> String { 719fn mouse_text() -> String {
721 if !crate::ps2::mouse_present() { 720 if !crate::ps2::mouse_present() {
722 return String::from("mouse: no PS/2 mouse\n"); 721 return String::from("mouse: no PS/2 mouse\n");
723 } 722 }
724 let mut s = String::new(); 723 let (x, y) = crate::gop::cursor_pos();
725 for _ in 0..32 { 724 let b = crate::gop::cursor_buttons();
726 let Some(ev) = crate::ps2::try_poll_mouse() else { 725 alloc::format!(
727 break; 726 "x={} y={} buttons={}{}{}\n",
728 }; 727 x,
729 let mut b = String::new(); 728 y,
730 b.push(if ev.left { 'L' } else { '-' }); 729 if b & 1 != 0 { 'L' } else { '-' },
731 b.push(if ev.right { 'R' } else { '-' }); 730 if b & 2 != 0 { 'R' } else { '-' },
732 b.push(if ev.middle { 'M' } else { '-' }); 731 if b & 4 != 0 { 'M' } else { '-' }
733 s.push_str(&alloc::format!( 732 )
734 "dx={:+} dy={:+} buttons={}\n",
735 ev.dx,
736 ev.dy,
737 b
738 ));
739 }
740 if s.is_empty() {
741 s.push_str("mouse: no events\n");
742 }
743 s
744} 733}
745 734
746// --- self-test ------------------------------------------------------------ 735// --- self-test ------------------------------------------------------------