keyboard config

This commit is contained in:
charlesbvll 2021-07-22 16:20:23 +02:00
parent de86827da5
commit c8b71f2294
3 changed files with 26 additions and 2 deletions

View File

@ -10,6 +10,7 @@ spin = "0.5.2"
x86_64 = "0.14.2" x86_64 = "0.14.2"
uart_16550 = "0.2.0" uart_16550 = "0.2.0"
pic8259 = "0.10.1" pic8259 = "0.10.1"
pc-keyboard = "0.5.0"
[dependencies.lazy_static] [dependencies.lazy_static]
version = "1.0" version = "1.0"

View File

@ -40,7 +40,29 @@ extern "x86-interrupt" fn timer_interrupt_handler(
extern "x86-interrupt" fn keyboard_interrupt_handler( extern "x86-interrupt" fn keyboard_interrupt_handler(
_stack_frame: InterruptStackFrame) _stack_frame: InterruptStackFrame)
{ {
print!("k"); use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
use spin::Mutex;
use x86_64::instructions::port::Port;
lazy_static! {
static ref KEYBOARD: Mutex<Keyboard<layouts::Us104Key, ScancodeSet1>> =
Mutex::new(Keyboard::new(layouts::Us104Key, ScancodeSet1,
HandleControl::Ignore)
);
}
let mut keyboard = KEYBOARD.lock();
let mut port = Port::new(0x60);
let scancode: u8 = unsafe { port.read() };
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
if let Some(key) = keyboard.process_keyevent(key_event) {
match key {
DecodedKey::Unicode(character) => print!("{}", character),
DecodedKey::RawKey(key) => print!("{:?}", key),
}
}
}
unsafe { unsafe {
PICS.lock() PICS.lock()
@ -48,6 +70,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(
} }
} }
pub fn init_idt() { pub fn init_idt() {
IDT.load(); IDT.load();
} }

View File

@ -11,7 +11,7 @@ use rust_os::println;
pub extern "C" fn _start() -> ! { pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!"); println!("Hello World{}", "!");
rust_os::init(); // new rust_os::init();
// as before // as before
#[cfg(test)] #[cfg(test)]