From 895991fee3d7a84b45182e1a16ce1bf18cbf6868 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 25 Jan 2019 14:22:25 +0100 Subject: [PATCH] Translate keycodes for keys 0-9 --- src/interrupts.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/interrupts.rs b/src/interrupts.rs index 1763bcbd..5b939910 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -60,6 +60,23 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: &mut Exceptio let port = Port::new(0x60); let scancode: u8 = unsafe { port.read() }; - print!("{}", scancode); + + // new + let key = match scancode { + 0x02 => Some('1'), + 0x03 => Some('2'), + 0x04 => Some('3'), + 0x05 => Some('4'), + 0x06 => Some('5'), + 0x07 => Some('6'), + 0x08 => Some('7'), + 0x09 => Some('8'), + 0x0a => Some('9'), + 0x0b => Some('0'), + _ => None, + }; + if let Some(key) = key { + print!("{}", key); + } unsafe { PICS.lock().notify_end_of_interrupt(KEYBOARD_INTERRUPT_ID) } }