(c: char, ascii_offset: u8, keycode_offset: KeyCode)
| 403 | } |
| 404 | } |
| 405 | fn ascii_to_keycode(c: char, ascii_offset: u8, keycode_offset: KeyCode) -> KeyCode { |
| 406 | let mut ascii = [0 as u8]; // buffer |
| 407 | c.encode_utf8(&mut ascii); |
| 408 | let keycode: u32 = keycode_offset.to_u32(); |
| 409 | let keycode = keycode as u8; |
| 410 | let keycode = keycode + (ascii[0] - ascii_offset); |
| 411 | let keycode: KeyCode = keycode.try_into().unwrap(); |
| 412 | keycode |
| 413 | } |
| 414 | //so the tests 'just work'. |
| 415 | #[cfg(test)] |
| 416 | #[macro_use] |