Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make windows key parsing logic better #619

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/event/sys/windows/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ fn parse_key_event_record(key_event: &KeyEventRecord) -> Option<KeyEvent> {
&& !modifiers.contains(KeyModifiers::ALT)
{
// we need to do some parsing
character = match character_raw as u8 {
c @ b'\x01'..=b'\x1A' => (c as u8 - 0x1 + b'a') as char,
c @ b'\x1C'..=b'\x1F' => (c as u8 - 0x1C + b'4') as char,
_ => return None,
// Control character will take the ASCII code produced by the key and bitwise AND
// it with 31, forcing bits 6 and bits 7 to zero.
// So we can make a bitwise OR back to see what's the raw control character.
let c = character_raw as u8;
if c <= b'\x1F' {
character = (c | b'\x40') as char;
} else {
return None;
}
}

Expand Down