diff --git a/kernel/src/arch/x86_64/driver/keyboard.rs b/kernel/src/arch/x86_64/driver/keyboard.rs index fd26204..9a29cf2 100644 --- a/kernel/src/arch/x86_64/driver/keyboard.rs +++ b/kernel/src/arch/x86_64/driver/keyboard.rs @@ -18,14 +18,18 @@ pub fn receive() -> Option { } let mut keyboard = KEYBOARD.lock(); - let port = Port::::new(0x60); + let data_port = Port::::new(0x60); + let status_port = Port::::new(0x64); - let scancode = 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) => return Some(character), - DecodedKey::RawKey(_key) => {}, // TODO: handle RawKey from keyboard + // Output buffer status = 1 + if unsafe { status_port.read() } & (1 << 0) != 0 { + let scancode = unsafe { data_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) => return Some(character), + DecodedKey::RawKey(_key) => {}, // TODO: handle RawKey from keyboard + } } } }