#[repr(u8)]
#[derive(Copy, Clone, PartialEq)]
pub(crate) enum KeyCode {
None = 0,
F1 = 1,
F2 = 2,
F3 = 3,
F4 = 4,
F5 = 5,
F6 = 6,
F7 = 7,
F8 = 8,
F9 = 9,
F10 = 10,
F11 = 11,
F12 = 12,
Enter = 13,
Escape = 14,
Insert = 15,
Delete = 16,
Backspace = 17,
Tab = 18,
Left = 19,
Up = 20,
Down = 21,
Right = 22,
PageUp = 23,
PageDown = 24,
Home = 25,
End = 26,
Space = 27,
A = 28,
B = 29,
C = 30,
D = 31,
E = 32,
F = 33,
G = 34,
H = 35,
I = 36,
J = 37,
K = 38,
L = 39,
M = 40,
N = 41,
O = 42,
P = 43,
Q = 44,
R = 45,
S = 46,
T = 47,
U = 48,
V = 49,
W = 50,
X = 51,
Y = 52,
Z = 53,
N0 = 54,
N1 = 55,
N2 = 56,
N3 = 57,
N4 = 58,
N5 = 59,
N6 = 60,
N7 = 61,
N8 = 62,
N9 = 63,
}
static HASH_TO_ALIGNAMENT: [Option<KeyCode>; 537] = [
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F12),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::V),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::M),
None,
None,
None,
Some(KeyCode::PageDown),
None,
None,
None,
Some(KeyCode::Home),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::P),
None,
Some(KeyCode::Enter),
Some(KeyCode::N9),
Some(KeyCode::Enter),
None,
None,
None,
None,
None,
Some(KeyCode::O),
None,
None,
Some(KeyCode::N4),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F2),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F9),
None,
None,
None,
Some(KeyCode::Insert),
None,
None,
None,
None,
Some(KeyCode::R),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::I),
None,
None,
Some(KeyCode::N6),
None,
None,
None,
None,
None,
None,
Some(KeyCode::D),
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F4),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Space),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::K),
None,
None,
Some(KeyCode::N0),
Some(KeyCode::Backspace),
None,
None,
None,
None,
Some(KeyCode::Right),
Some(KeyCode::F),
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F6),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::PageUp),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::U),
None,
None,
Some(KeyCode::N2),
None,
None,
Some(KeyCode::Delete),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F11),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::X),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::W),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::B),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F1),
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Z),
None,
Some(KeyCode::Up),
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Q),
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::PageDown),
None,
Some(KeyCode::L),
None,
None,
Some(KeyCode::N5),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F3),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Escape),
None,
None,
None,
None,
None,
Some(KeyCode::S),
None,
None,
Some(KeyCode::N8),
None,
None,
None,
None,
None,
None,
Some(KeyCode::N),
None,
None,
Some(KeyCode::N7),
None,
None,
None,
Some(KeyCode::Tab),
None,
None,
Some(KeyCode::E),
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::F5),
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Escape),
Some(KeyCode::F8),
None,
Some(KeyCode::Backspace),
None,
None,
Some(KeyCode::F1),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::H),
None,
Some(KeyCode::None),
Some(KeyCode::N1),
None,
None,
None,
None,
None,
None,
Some(KeyCode::G),
None,
Some(KeyCode::End),
None,
None,
None,
None,
None,
Some(KeyCode::F7),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Delete),
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Insert),
None,
None,
None,
Some(KeyCode::J),
None,
None,
Some(KeyCode::N3),
Some(KeyCode::PageUp),
None,
None,
None,
None,
None,
Some(KeyCode::A),
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Left),
None,
None,
None,
Some(KeyCode::F10),
None,
None,
None,
Some(KeyCode::Down),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::Y),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::T),
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(KeyCode::C),
None,
None,
];
static HASH_COLISION_VALIDATOR: [u64; 537] = [
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xDD5C4818FF6A08FE,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63EB4C86020609,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E04C8601F358,
0x0,
0x0,
0x0,
0x62FF10F27635B93E,
0x0,
0x0,
0x0,
0x402D1BCC7E6F9D6E,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63ED4C8602096F,
0x0,
0xBE7898BF4C4EEAAD,
0xAF63B44C8601A894,
0xC5C7B983377CAD5F,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E24C8601F6BE,
0x0,
0x0,
0xAF63A94C860195E3,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x8988E07B5422D51,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x8988307B5421AA0,
0x0,
0x0,
0x0,
0x2BA002192BD4CD57,
0x0,
0x0,
0x0,
0x0,
0xAF63EF4C86020CD5,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E44C8601FA24,
0x0,
0x0,
0xAF63AB4C86019949,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63D94C8601E773,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x8989007B54230B7,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x436CF28AB247E3E5,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E64C8601FD8A,
0x0,
0x0,
0xAF63AD4C86019CAF,
0x70498C02C43FE96C,
0x0,
0x0,
0x0,
0x0,
0x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x0,
0x0,
0x0,
0x0,
0xC300FE18F061BABE,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63EE4C86020B22,
0x0,
0x0,
0xAF63B54C8601AA47,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E34C8601F871,
0x0,
0x0,
0xAF63AA4C86019796,
0x0,
0x0,
0x0,
0x56D7AE194448AA0C,
0x0,
0x0,
0xAF63D84C8601E5C0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x8988F07B5422F04,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x32F90844A302D946,
0x8988407B5421C53,
0x0,
0x9A46FF9BAA276602,
0x0,
0x0,
0xCBF29CE484222325,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E54C8601FBD7,
0x0,
0x3C0D17BAD169557B,
0xAF63AC4C86019AFC,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63DA4C8601E926,
0x0,
0xC2F00318F053500A,
0x0,
0x0,
0x0,
0x0,
0x0,
0x8989107B542326A,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xF3FE6B5FDB85D50A,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x7271C68759916228,
0x0,
0x0,
0x0,
0xAF63E74C8601FF3D,
0x0,
0x0,
0xAF63AE4C86019E62,
0xD116290DCF7F8025,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63DC4C8601EC8C,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x24B070ADA2041CB0,
0x0,
0x0,
0x0,
0xDD5C4618FF6A0598,
0x0,
0x0,
0x0,
0xDC04126761BB7455,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63F44C86021554,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63E94C860202A3,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0xAF63DE4C8601EFF2,
0x0,
0x0,
];
impl KeyCode {
pub(super) fn from_hash(hash: u64) -> Option<KeyCode> {
let entry_index = (hash % 537) as usize;
if HASH_COLISION_VALIDATOR[entry_index] != hash {
return None;
}
HASH_TO_ALIGNAMENT[entry_index]
}
pub fn get_name(&self) -> &'static str {
match self {
KeyCode::None => "None",
KeyCode::F1 => "F1",
KeyCode::F2 => "F2",
KeyCode::F3 => "F3",
KeyCode::F4 => "F4",
KeyCode::F5 => "F5",
KeyCode::F6 => "F6",
KeyCode::F7 => "F7",
KeyCode::F8 => "F8",
KeyCode::F9 => "F9",
KeyCode::F10 => "F10",
KeyCode::F11 => "F11",
KeyCode::F12 => "F12",
KeyCode::Enter => "Enter",
KeyCode::Escape => "Escape",
KeyCode::Insert => "Insert",
KeyCode::Delete => "Delete",
KeyCode::Backspace => "Backspace",
KeyCode::Tab => "Tab",
KeyCode::Left => "Left",
KeyCode::Up => "Up",
KeyCode::Down => "Down",
KeyCode::Right => "Right",
KeyCode::PageUp => "PageUp",
KeyCode::PageDown => "PageDown",
KeyCode::Home => "Home",
KeyCode::End => "End",
KeyCode::Space => "Space",
KeyCode::A => "A",
KeyCode::B => "B",
KeyCode::C => "C",
KeyCode::D => "D",
KeyCode::E => "E",
KeyCode::F => "F",
KeyCode::G => "G",
KeyCode::H => "H",
KeyCode::I => "I",
KeyCode::J => "J",
KeyCode::K => "K",
KeyCode::L => "L",
KeyCode::M => "M",
KeyCode::N => "N",
KeyCode::O => "O",
KeyCode::P => "P",
KeyCode::Q => "Q",
KeyCode::R => "R",
KeyCode::S => "S",
KeyCode::T => "T",
KeyCode::U => "U",
KeyCode::V => "V",
KeyCode::W => "W",
KeyCode::X => "X",
KeyCode::Y => "Y",
KeyCode::Z => "Z",
KeyCode::N0 => "N0",
KeyCode::N1 => "N1",
KeyCode::N2 => "N2",
KeyCode::N3 => "N3",
KeyCode::N4 => "N4",
KeyCode::N5 => "N5",
KeyCode::N6 => "N6",
KeyCode::N7 => "N7",
KeyCode::N8 => "N8",
KeyCode::N9 => "N9",
}
}
}