Commit 1e519c75 authored by Jeremy Soller's avatar Jeremy Soller

Implement control and navigation in ps2 driver

parent 13b64da0
......@@ -9,6 +9,7 @@ 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 ctrl = false;
let mut lshift = false;
let mut rshift = false;
loop {
......@@ -27,14 +28,52 @@ pub fn keyboard() {
(data, true)
};
if scancode == 0x2A {
if scancode == 0x1D {
ctrl = pressed;
} else 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' {
input.write(&[c as u8]).expect("ps2d: failed to write input");
match scancode {
0x47 => { // Home
input.write(b"\x1B[H").unwrap();
},
0x48 => { // Up
input.write(b"\x1B[A").unwrap();
},
0x49 => { // Page up
input.write(b"\x1B[5~").unwrap();
},
0x4B => { // Left
input.write(b"\x1B[D").unwrap();
},
0x4D => { // Right
input.write(b"\x1B[C").unwrap();
},
0x4F => { // End
input.write(b"\x1B[F").unwrap();
},
0x50 => { // Down
input.write(b"\x1B[B").unwrap();
},
0x51 => { // Page down
input.write(b"\x1B[6~").unwrap();
},
_ => {
let c = if ctrl {
match keymap::get_char(scancode, false) {
c @ 'a' ... 'z' => (c as u8 - b'a' + b'\x01') as char,
c => c
}
} else {
keymap::get_char(scancode, lshift || rshift)
};
if c != '\0' {
input.write(&[c as u8]).unwrap();
}
}
}
}
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment