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

Parse more missing Key / Code values #2044

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ time = "0.3.0"
cfg-if = "1.0.0"
instant = { version = "0.1.6", features = ["wasm-bindgen"] }
anyhow = "1.0.32"
keyboard-types = { version = "0.5.0", default_features = false }
keyboard-types = { version = "0.6.2", default_features = false }

# Optional dependencies
image = { version = "0.23.12", optional = true, default_features = false }
Expand Down
36 changes: 24 additions & 12 deletions druid-shell/src/backend/gtk/keycodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ pub fn raw_key_to_key(raw: RawKey) -> Option<Key> {
F10 => Key::F10,
F11 => Key::F11,
F12 => Key::F12,
Tools | F13 => Key::F13,
F14 | Launch5 => Key::F14,
F15 | Launch6 => Key::F15,
F16 | Launch7 => Key::F16,
F17 | Launch8 => Key::F17,
F18 | Launch9 => Key::F18,
F19 => Key::F19,
F20 => Key::F20,
F21 => Key::F21,
F22 => Key::F22,
F23 => Key::F23,
F24 => Key::F24,
// not available in keyboard-types
// Tools | F13 => Key::F13,
// F14 | Launch5 => Key::F14,
// F15 | Launch6 => Key::F15,
// F16 | Launch7 => Key::F16,
// F17 | Launch8 => Key::F17,
// F18 | Launch9 => Key::F18,
// F19 => Key::F19,
// F20 => Key::F20,
// F21 => Key::F21,
// F22 => Key::F22,
// F23 => Key::F23,
// F24 => Key::F24,
// Calculator => Key::LaunchCalculator,
// MyComputer | Explorer => Key::LaunchMyComputer,
// ISO_Level3_Latch => Key::AltGraphLatch,
Expand Down Expand Up @@ -257,6 +257,18 @@ pub fn key_to_raw_key(src: &Key) -> Option<RawKey> {
Key::F10 => F10,
Key::F11 => F11,
Key::F12 => F12,
Key::F13 => F13,
Key::F14 => F14,
Key::F15 => F15,
Key::F16 => F16,
Key::F17 => F17,
Key::F18 => F18,
Key::F19 => F19,
Key::F20 => F20,
Key::F21 => F21,
Key::F22 => F22,
Key::F23 => F23,
Key::F24 => F24,

Key::PrintScreen => Print,
Key::ScrollLock => Scroll_Lock,
Expand Down
38 changes: 24 additions & 14 deletions druid-shell/src/backend/mac/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,13 @@ fn key_code_to_code(key_code: u16) -> Code {
0x37 => Code::MetaLeft,
0x38 => Code::ShiftLeft,
0x39 => Code::CapsLock,
// Note: in the linked source doc, this is "OSLeft"
0x3a => Code::AltLeft,
0x3b => Code::ControlLeft,
0x3c => Code::ShiftRight,
// Note: in the linked source doc, this is "OSRight"
0x3d => Code::AltRight,
0x3e => Code::ControlRight,
0x3f => Code::Fn, // No events fired
//0x40 => Code::F17,
0x3f => Code::Fn,
0x40 => Code::F17,
0x41 => Code::NumpadDecimal,
0x43 => Code::NumpadMultiply,
0x45 => Code::NumpadAdd,
Expand All @@ -122,8 +120,8 @@ fn key_code_to_code(key_code: u16) -> Code {
0x4b => Code::NumpadDivide,
0x4c => Code::NumpadEnter,
0x4e => Code::NumpadSubtract,
//0x4f => Code::F18,
//0x50 => Code::F19,
0x4f => Code::F18,
0x50 => Code::F19,
0x51 => Code::NumpadEqual,
0x52 => Code::Numpad0,
0x53 => Code::Numpad1,
Expand All @@ -133,7 +131,7 @@ fn key_code_to_code(key_code: u16) -> Code {
0x57 => Code::Numpad5,
0x58 => Code::Numpad6,
0x59 => Code::Numpad7,
//0x5a => Code::F20,
0x5a => Code::F20,
0x5b => Code::Numpad8,
0x5c => Code::Numpad9,
0x5d => Code::IntlYen,
Expand All @@ -148,16 +146,16 @@ fn key_code_to_code(key_code: u16) -> Code {
0x66 => Code::Lang2,
0x67 => Code::F11,
0x68 => Code::Lang1,
// Note: this is listed as F13, but in testing with a standard
// USB kb, this the code produced by PrtSc.
0x69 => Code::PrintScreen,
//0x6a => Code::F16,
//0x6b => Code::F14,
0x69 => Code::F13,
0x6a => Code::F16,
0x6b => Code::F14,
0x6d => Code::F10,
0x6e => Code::ContextMenu,
0x6f => Code::F12,
//0x71 => Code::F15,
0x72 => Code::Help,
0x71 => Code::F15,
// Apple hasn't been producing any keyboards with `Help` anymore since
// 2007. So this can be considered Insert instead.
0x72 => Code::Insert,
0x73 => Code::Home,
0x74 => Code::PageUp,
0x75 => Code::Delete,
Expand Down Expand Up @@ -206,6 +204,18 @@ fn code_to_key(code: Code) -> Option<KbKey> {
Code::F10 => KbKey::F10,
Code::F11 => KbKey::F11,
Code::F12 => KbKey::F12,
Code::F13 => KbKey::F13,
Code::F14 => KbKey::F14,
Code::F15 => KbKey::F15,
Code::F16 => KbKey::F16,
Code::F17 => KbKey::F17,
Code::F18 => KbKey::F18,
Code::F19 => KbKey::F19,
Code::F20 => KbKey::F20,
Code::F21 => KbKey::F21,
Code::F22 => KbKey::F22,
Code::F23 => KbKey::F23,
Code::F24 => KbKey::F24,
Code::Pause => KbKey::Pause,
Code::ScrollLock => KbKey::ScrollLock,
Code::PrintScreen => KbKey::PrintScreen,
Expand Down
16 changes: 8 additions & 8 deletions druid-shell/src/backend/mac/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ impl HotKey {
KbKey::F10 => "\u{F70D}",
KbKey::F11 => "\u{F70E}",
KbKey::F12 => "\u{F70F}",
//KbKey::F13 => "\u{F710}",
//KbKey::F14 => "\u{F711}",
//KbKey::F15 => "\u{F712}",
//KbKey::F16 => "\u{F713}",
//KbKey::F17 => "\u{F714}",
//KbKey::F18 => "\u{F715}",
//KbKey::F19 => "\u{F716}",
//KbKey::F20 => "\u{F717}",
KbKey::F13 => "\u{F710}",
KbKey::F14 => "\u{F711}",
KbKey::F15 => "\u{F712}",
KbKey::F16 => "\u{F713}",
KbKey::F17 => "\u{F714}",
KbKey::F18 => "\u{F715}",
KbKey::F19 => "\u{F716}",
KbKey::F20 => "\u{F717}",
_ => {
eprintln!("no key equivalent for {:?}", self);
""
Expand Down
39 changes: 39 additions & 0 deletions druid-shell/src/backend/shared/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,13 @@ pub fn hardware_keycode_to_code(hw_keycode: u16) -> Code {
0x0059 => Code::Numpad3,
0x005A => Code::Numpad0,
0x005B => Code::NumpadDecimal,
0x005D => Code::Lang5,
0x005E => Code::IntlBackslash,
0x005F => Code::F11,
0x0060 => Code::F12,
0x0061 => Code::IntlRo,
0x0062 => Code::Lang3,
0x0063 => Code::Lang4,
0x0064 => Code::Convert,
0x0065 => Code::KanaMode,
0x0066 => Code::NonConvert,
Expand All @@ -171,8 +174,10 @@ pub fn hardware_keycode_to_code(hw_keycode: u16) -> Code {
0x0079 => Code::AudioVolumeMute,
0x007A => Code::AudioVolumeDown,
0x007B => Code::AudioVolumeUp,
0x007C => Code::Power,
0x007D => Code::NumpadEqual,
0x007F => Code::Pause,
0x0080 => Code::ShowAllWindows,
0x0081 => Code::NumpadComma,
0x0082 => Code::Lang1,
0x0083 => Code::Lang2,
Expand All @@ -192,6 +197,7 @@ pub fn hardware_keycode_to_code(hw_keycode: u16) -> Code {
0x0091 => Code::Cut,
0x0092 => Code::Help,
0x0094 => Code::LaunchApp2,
0x0096 => Code::Sleep,
0x0097 => Code::WakeUp,
0x0098 => Code::LaunchApp1,
// key to right of volume controls on T430s produces 0x9C
Expand All @@ -205,10 +211,43 @@ pub fn hardware_keycode_to_code(hw_keycode: u16) -> Code {
0x00AC => Code::MediaPlayPause,
0x00AD => Code::MediaTrackPrevious,
0x00AE => Code::MediaStop,
0x00AF => Code::MediaRecord,
0x00B0 => Code::MediaRewind,
0x00B3 => Code::MediaSelect,
0x00B4 => Code::BrowserHome,
0x00B5 => Code::BrowserRefresh,
0x00BB => Code::NumpadParenLeft,
0x00BC => Code::NumpadParenRight,
0x00BF => Code::F13,
0x00C0 => Code::F14,
0x00C1 => Code::F15,
0x00C2 => Code::F16,
0x00C3 => Code::F17,
0x00C4 => Code::F18,
0x00C5 => Code::F19,
0x00C6 => Code::F20,
0x00C7 => Code::F21,
0x00C8 => Code::F22,
0x00C9 => Code::F23,
0x00CA => Code::F24,
0x00D1 => Code::MediaPause,
0x00D7 => Code::MediaPlay,
0x00D8 => Code::MediaFastForward,
0x00E1 => Code::BrowserSearch,
0x00E8 => Code::BrightnessDown,
0x00E9 => Code::BrightnessUp,
0x00EB => Code::DisplayToggleIntExt,
0x00EF => Code::MailSend,
0x00F0 => Code::MailReply,
0x00F1 => Code::MailForward,
0x0100 => Code::MicrophoneMuteToggle,
0x017C => Code::ZoomToggle,
0x024B => Code::LaunchControlPanel,
0x024C => Code::SelectTask,
0x024D => Code::LaunchScreenSaver,
0x024F => Code::LaunchAssistant,
0x0250 => Code::KeyboardLayoutSelect,
0x0281 => Code::PrivacyScreenToggle,
_ => Code::Unidentified,
}
}
Loading