keyboard config
This commit is contained in:
parent
de86827da5
commit
c8b71f2294
@ -10,6 +10,7 @@ spin = "0.5.2"
|
||||
x86_64 = "0.14.2"
|
||||
uart_16550 = "0.2.0"
|
||||
pic8259 = "0.10.1"
|
||||
pc-keyboard = "0.5.0"
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
|
||||
@ -40,7 +40,29 @@ extern "x86-interrupt" fn timer_interrupt_handler(
|
||||
extern "x86-interrupt" fn keyboard_interrupt_handler(
|
||||
_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 {
|
||||
PICS.lock()
|
||||
@ -48,6 +70,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn init_idt() {
|
||||
IDT.load();
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ use rust_os::println;
|
||||
pub extern "C" fn _start() -> ! {
|
||||
println!("Hello World{}", "!");
|
||||
|
||||
rust_os::init(); // new
|
||||
rust_os::init();
|
||||
|
||||
// as before
|
||||
#[cfg(test)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user