MCPcopy Create free account
hub / github.com/TyberiusPrime/KeyToKey / nibble_to_keycode

Function nibble_to_keycode

src/handlers/debug_handlers.rs:10–32  ·  view source on GitHub ↗
(nibble: u8)

Source from the content-addressed store, hash-verified

8///
9use no_std_compat::prelude::v1::*;
10fn nibble_to_keycode(nibble: u8) -> KeyCode {
11 match nibble {
12 0 => KeyCode::Kb0,
13 1 => KeyCode::Kb1,
14 2 => KeyCode::Kb2,
15 3 => KeyCode::Kb3,
16 4 => KeyCode::Kb4,
17 5 => KeyCode::Kb5,
18 6 => KeyCode::Kb6,
19 7 => KeyCode::Kb7,
20 8 => KeyCode::Kb8,
21 9 => KeyCode::Kb9,
22 0xA => KeyCode::A,
23 0xB => KeyCode::B,
24 0xC => KeyCode::C,
25 0xD => KeyCode::D,
26 0xE => KeyCode::E,
27 0xF => KeyCode::F,
28 _ => {
29 panic!("nibble larger than 0xF");
30 }
31 }
32}
33fn transform_u32_to_keycodes(x: u32) -> [KeyCode; 8] {
34 [
35 nibble_to_keycode(((x >> (32 - 4)) & 0xf) as u8),

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected