MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / hid_text_for_key

Function hid_text_for_key

packages/server/src/android.rs:2277–2338  ·  view source on GitHub ↗
(hid: u16, modifiers: u32)

Source from the content-addressed store, hash-verified

2275}
2276
2277fn hid_text_for_key(hid: u16, modifiers: u32) -> Option<String> {
2278 if modifiers & (MODIFIER_CONTROL | MODIFIER_OPTION | MODIFIER_COMMAND) != 0 {
2279 return None;
2280 }
2281
2282 let shifted = modifiers & MODIFIER_SHIFT != 0;
2283 let caps_locked = modifiers & MODIFIER_CAPS_LOCK != 0;
2284
2285 if (4..=29).contains(&hid) {
2286 let offset = (hid - 4) as u8;
2287 let base = if shifted ^ caps_locked { b'A' } else { b'a' };
2288 return Some(char::from(base + offset).to_string());
2289 }
2290
2291 let text = match (hid, shifted) {
2292 (30, false) => "1",
2293 (30, true) => "!",
2294 (31, false) => "2",
2295 (31, true) => "@",
2296 (32, false) => "3",
2297 (32, true) => "#",
2298 (33, false) => "4",
2299 (33, true) => "$",
2300 (34, false) => "5",
2301 (34, true) => "%",
2302 (35, false) => "6",
2303 (35, true) => "^",
2304 (36, false) => "7",
2305 (36, true) => "&",
2306 (37, false) => "8",
2307 (37, true) => "*",
2308 (38, false) => "9",
2309 (38, true) => "(",
2310 (39, false) => "0",
2311 (39, true) => ")",
2312 (44, _) => " ",
2313 (45, false) => "-",
2314 (45, true) => "_",
2315 (46, false) => "=",
2316 (46, true) => "+",
2317 (47, false) => "[",
2318 (47, true) => "{",
2319 (48, false) => "]",
2320 (48, true) => "}",
2321 (49, false) => "\\",
2322 (49, true) => "|",
2323 (51, false) => ";",
2324 (51, true) => ":",
2325 (52, false) => "'",
2326 (52, true) => "\"",
2327 (53, false) => "`",
2328 (53, true) => "~",
2329 (54, false) => ",",
2330 (54, true) => "<",
2331 (55, false) => ".",
2332 (55, true) => ">",
2333 (56, false) => "/",
2334 (56, true) => "?",

Callers 1

send_keyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected