pub fn usage_id_to_make_code(usage_id: u16) -> i16 {
if (usage_id as usize) < USAGE_ID_TABLE.len() {
return USAGE_ID_TABLE[usage_id as usize];
} else if (181..=183).contains(&usage_id) {
let table: [i16; 3] = [ 25, 16, 36 ];
return table[(usage_id - 181) as usize];
} else if usage_id == 205 {
return 34;
} else if (224..=234).contains(&usage_id) {
let table: [i16; 11] = [ 29, 42, 56, 91, 29, 54, 56, 92, -2, 48, 46 ];
return table[(usage_id - 224) as usize];
}
-1
}
const USAGE_ID_TABLE: [i16; 149] = [
-1, 255, 252, -3, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49,
24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 28, 1, 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53,
58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 55, 70, 29, 82, 71, 73,
83, 79, 81, 77, 75, 80, 72, 69, 53, 55, 74, 78, 28, 79, 80, 81, 75, 76, 77,
71, 72, 73, 82, 83, 86, 93, 94, 89, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 118, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
94, 95, 99, -3, 126, -3, 115, 112, 125, 121, 123, 92, -3, -3, -3, 242,
241, 120, 119, 118
];
pub fn vk_to_usage_id(vk: u8) -> u16 {
match vk as u16 {
0x08 => 42, 0x09 => 43, 0x0D => 40, 0x10 => 225, 0x11 => 224, 0x12 => 226, 0x13 => 72, 0x14 => 57, 0x1B => 41, 0x20 => 44, 0x21 => 75, 0x22 => 78, 0x23 => 77, 0x24 => 74, 0x25 => 80, 0x26 => 82, 0x27 => 79, 0x28 => 81, 0x2D => 76, 0x2E => 73, 0x30..=0x39 => (vk - 0x30) as u16 + 30 - 1,
0x41..=0x5A => (vk - 0x41) as u16 + 4,
0x5B => 227, 0x5C => 231, 0x70..=0x7B => (vk - 0x70) as u16 + 58,
_ => 0, }
}
pub fn is_extended_key(vk: u8) -> bool {
matches!(vk as u16,
0x21..=0x28 | 0x2D | 0x2E | 0x5B | 0x5C )
}