MCPcopy Index your code
hub / github.com/TyberiusPrime/KeyToKey / send_string

Method send_string

src/lib.rs:383–403  ·  view source on GitHub ↗

send a utf-8 string to the host all characters are converted into unicode input!

(&mut self, s: &str)

Source from the content-addressed store, hash-verified

381 /// send a utf-8 string to the host
382 /// all characters are converted into unicode input!
383 fn send_string(&mut self, s: &str) {
384 for c in s.chars() {
385 /* the problem with this approach: it is dependant on the shift/caps lock state
386 match c {
387 'a'..='z' => {self.send_keys(&[ascii_to_keycode(c, 97, KeyCode::A)]); self.send_empty()},
388 '1'..='9' => {self.send_keys(&[ascii_to_keycode(c, 49, KeyCode::Kb1)]); self.send_empty()},
389 '0' => {self.send_keys(&[KeyCode::Kb0]); self.send_empty()},
390 'A'..='Z' => {self.send_keys(&[ascii_to_keycode(c, 65, KeyCode::A), KeyCode::LShift]); self.send_empty()},
391 _ => self.send_unicode(c),
392 }
393 */
394 //probably best to unicode everything
395 self.send_unicode(c);
396
397 // option: send simple ones directly?
398 /*
399 if 'a' <= c && c <= 'z' {
400 }
401 */
402 }
403 }
404}
405fn ascii_to_keycode(c: char, ascii_offset: u8, keycode_offset: KeyCode) -> KeyCode {
406 let mut ascii = [0 as u8]; // buffer

Callers 4

on_triggerMethod · 0.80
process_keysMethod · 0.80
process_keysMethod · 0.80

Implementers 1

test_helpers.rssrc/test_helpers.rs

Calls 1

send_unicodeMethod · 0.80

Tested by

no test coverage detected