Implement control and navigation in ps2 driver

This commit is contained in:
Jeremy Soller 2016-09-28 21:59:51 -06:00
parent b3d980b9ac
commit 02b5f34165

View file

@ -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 {