Add wnohang, make PS/2 driver write input to display scheme, which then passes it to the shell
This commit is contained in:
parent
046236c10f
commit
76b0c7eeea
1 changed files with 151 additions and 96 deletions
|
|
@ -5,9 +5,12 @@ use std::thread;
|
|||
|
||||
use keymap;
|
||||
|
||||
pub fn keyboard() {
|
||||
pub fn keyboard() {
|
||||
let mut file = File::open("irq:1").expect("ps2d: failed to open irq:1");
|
||||
let mut input = File::open("display:input").expect("ps2d: failed to open display:input");
|
||||
|
||||
let mut lshift = false;
|
||||
let mut rshift = false;
|
||||
loop {
|
||||
let mut irqs = [0; 8];
|
||||
if file.read(&mut irqs).expect("ps2d: failed to read irq:1") >= mem::size_of::<usize>() {
|
||||
|
|
@ -16,17 +19,25 @@ pub fn keyboard() {
|
|||
asm!("in al, dx" : "={al}"(data) : "{dx}"(0x60) : : "intel", "volatile");
|
||||
}
|
||||
|
||||
file.write(&irqs).expect("ps2d: failed to write irq:1");
|
||||
|
||||
let (scancode, pressed) = if data >= 0x80 {
|
||||
(data - 0x80, false)
|
||||
} else {
|
||||
(data, true)
|
||||
};
|
||||
|
||||
if pressed {
|
||||
print!("{}", keymap::get_char(scancode));
|
||||
if scancode == 0x2A {
|
||||
lshift = pressed;
|
||||
} else if scancode == 0x36 {
|
||||
rshift = pressed;
|
||||
} else if pressed {
|
||||
let c = keymap::get_char(scancode, lshift || rshift);
|
||||
if c != '\0' {
|
||||
print!("{}", c);
|
||||
input.write(&[c as u8]).expect("ps2d: failed to write input");
|
||||
}
|
||||
}
|
||||
|
||||
file.write(&irqs).expect("ps2d: failed to write irq:1");
|
||||
} else {
|
||||
thread::yield_now();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue