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

Function ascii_to_keycode

src/lib.rs:405–413  ·  view source on GitHub ↗
(c: char, ascii_offset: u8, keycode_offset: KeyCode)

Source from the content-addressed store, hash-verified

403 }
404}
405fn 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]

Callers

nothing calls this directly

Calls 1

to_u32Method · 0.80

Tested by

no test coverage detected