Interrupts aren't working anymore
This commit is contained in:
64
src/keymap.rs
Normal file
64
src/keymap.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
pub enum KeyType {
|
||||
Ascii(char),
|
||||
// Special, // F1, Home, etc.
|
||||
Modifier, // Shift, Ctrl
|
||||
Unknown,
|
||||
}
|
||||
|
||||
pub const fn map_keycode(code: u16, shift: bool) -> KeyType {
|
||||
match code {
|
||||
// Numbers row
|
||||
2..=11 => {
|
||||
let val = if shift {
|
||||
[')', '!', '@', '#', '$', '%', '^', '&', '*', '('][(code - 2) as usize]
|
||||
} else {
|
||||
(code as u8 - 2 + b'1') as char
|
||||
};
|
||||
if code == 11 && !shift {
|
||||
KeyType::Ascii('0')
|
||||
} else {
|
||||
KeyType::Ascii(val)
|
||||
}
|
||||
}
|
||||
|
||||
// Letters (Simplified QWERTY)
|
||||
16 => KeyType::Ascii(if shift { 'Q' } else { 'q' }),
|
||||
17 => KeyType::Ascii(if shift { 'W' } else { 'w' }),
|
||||
18 => KeyType::Ascii(if shift { 'E' } else { 'e' }),
|
||||
19 => KeyType::Ascii(if shift { 'R' } else { 'r' }),
|
||||
20 => KeyType::Ascii(if shift { 'T' } else { 't' }),
|
||||
21 => KeyType::Ascii(if shift { 'Y' } else { 'y' }),
|
||||
22 => KeyType::Ascii(if shift { 'U' } else { 'u' }),
|
||||
23 => KeyType::Ascii(if shift { 'I' } else { 'i' }),
|
||||
24 => KeyType::Ascii(if shift { 'O' } else { 'o' }),
|
||||
25 => KeyType::Ascii(if shift { 'P' } else { 'p' }),
|
||||
30 => KeyType::Ascii(if shift { 'A' } else { 'a' }),
|
||||
31 => KeyType::Ascii(if shift { 'S' } else { 's' }),
|
||||
32 => KeyType::Ascii(if shift { 'D' } else { 'd' }),
|
||||
33 => KeyType::Ascii(if shift { 'F' } else { 'f' }),
|
||||
34 => KeyType::Ascii(if shift { 'G' } else { 'g' }),
|
||||
35 => KeyType::Ascii(if shift { 'H' } else { 'h' }),
|
||||
36 => KeyType::Ascii(if shift { 'J' } else { 'j' }),
|
||||
37 => KeyType::Ascii(if shift { 'K' } else { 'k' }),
|
||||
38 => KeyType::Ascii(if shift { 'L' } else { 'l' }),
|
||||
44 => KeyType::Ascii(if shift { 'Z' } else { 'z' }),
|
||||
45 => KeyType::Ascii(if shift { 'X' } else { 'x' }),
|
||||
46 => KeyType::Ascii(if shift { 'C' } else { 'c' }),
|
||||
47 => KeyType::Ascii(if shift { 'V' } else { 'v' }),
|
||||
48 => KeyType::Ascii(if shift { 'B' } else { 'b' }),
|
||||
49 => KeyType::Ascii(if shift { 'N' } else { 'n' }),
|
||||
50 => KeyType::Ascii(if shift { 'M' } else { 'm' }),
|
||||
|
||||
// Control
|
||||
28 => KeyType::Ascii('\n'),
|
||||
57 => KeyType::Ascii(' '),
|
||||
14 => KeyType::Ascii('\x08'), // Backspace
|
||||
1 => KeyType::Ascii('\x1b'), // Escape
|
||||
|
||||
// Modifiers
|
||||
42 | 54 => KeyType::Modifier, // LShift, RShift
|
||||
29 | 97 => KeyType::Modifier, // LCtrl, RCtrl
|
||||
|
||||
_ => KeyType::Unknown,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user