From 959d50d9117a0ed3f280bf7d5bfbffd1fa1a5740 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Mon, 5 Feb 2024 04:18:51 +0100 Subject: PS/2 Keyboard controller: read and decode key --- src/lib.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 80d0146..95a9455 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,11 +5,11 @@ mod arch; mod io; mod machine; +use arch::x86_64::interrupt::pic_8259; +use arch::x86_64::interrupt::pic_8259::PicDeviceInt; use core::panic::PanicInfo; use machine::cgascr::CGAScreen; use machine::interrupt; -use arch::x86_64::interrupt::pic_8259; -use arch::x86_64::interrupt::pic_8259::PicDeviceInt; #[cfg(not(test))] #[panic_handler] @@ -28,9 +28,17 @@ pub extern "C" fn _entry() -> ! { println!(" `-.-' \\ )-`( , o o)"); println!(" `- \\`_`\"'-"); println!("it works!"); - + // testing interrupt/PIC - pic_8259::allow(PicDeviceInt::KEYBOARD); - interrupt::interrupt_enable(); - loop {} + // pic_8259::allow(PicDeviceInt::KEYBOARD); + // interrupt::interrupt_enable(); + // + // busy loop query keyboard + loop { + // let code = io::KBCTL_GLOBAL.lock().simple_read(); + io::KBCTL_GLOBAL.lock().fetch_key(); + if let Some(k) = io::KBCTL_GLOBAL.lock().consume_key() { + println! {"caught key: {:?}", k} + } + } } -- cgit v1.2.3-70-g09d2