(nibble: u8)
| 8 | /// |
| 9 | use no_std_compat::prelude::v1::*; |
| 10 | fn 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 | } |
| 33 | fn transform_u32_to_keycodes(x: u32) -> [KeyCode; 8] { |
| 34 | [ |
| 35 | nibble_to_keycode(((x >> (32 - 4)) & 0xf) as u8), |
no outgoing calls
no test coverage detected