Fix arrow keys
This commit is contained in:
parent
bf202a42ba
commit
903b2d7ead
@ -89,23 +89,37 @@ enum InputKey {
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn keyboard_handler(_stack_frame: InterruptStackFrame) {
|
||||
let scancode = unsafe { inb(0x60) };
|
||||
println!("{:x?}", scancode);
|
||||
'key_block: {
|
||||
let scancode = unsafe { inb(0x60) };
|
||||
let key = match scancode {
|
||||
0x11 => Some(InputKey::Up), // W
|
||||
0x1E => Some(InputKey::Left), // A
|
||||
0x1F => Some(InputKey::Down), // S
|
||||
0x20 => Some(InputKey::Right), // D
|
||||
|
||||
let key = match scancode {
|
||||
0x11 => Some(InputKey::Up),
|
||||
0x1E => Some(InputKey::Left),
|
||||
0x1F => Some(InputKey::Down),
|
||||
0x20 => Some(InputKey::Right),
|
||||
0xE0 => {
|
||||
let scancode = unsafe { inb(0x60) };
|
||||
println!("e {:x?}", scancode);
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
// Extended codes
|
||||
0xE0 => {
|
||||
let scancode = unsafe { inb(0x60) };
|
||||
match scancode {
|
||||
0x48 => Some(InputKey::Up), // Up arrow
|
||||
0x4B => Some(InputKey::Left), // Left arrow
|
||||
0x50 => Some(InputKey::Down), // Down arrow
|
||||
0x4D => Some(InputKey::Right), // Right arrow
|
||||
_ => break 'key_block, // Ignore unknown codes
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore unrecognized keycodes.
|
||||
//
|
||||
// Note that this does NOT return to None!
|
||||
// If we do that, "release" keycodes will
|
||||
// immediately clear "press" keycodes.
|
||||
_ => break 'key_block,
|
||||
};
|
||||
|
||||
*LAST_INPUT.lock() = key;
|
||||
}
|
||||
|
||||
*LAST_INPUT.lock() = key;
|
||||
PIC.lock().send_eoi(InterruptIndex::Keyboard.as_u8());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user