From 5e6e6bdd84c22147bff7c19471e86861e6391b6c Mon Sep 17 00:00:00 2001 From: Tom Crouch Date: Mon, 13 May 2024 22:38:41 +0100 Subject: [PATCH 1/3] Add function keys 13-20 --- src/macos/keycodes.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/macos/keycodes.rs b/src/macos/keycodes.rs index eeb6f98e..9dc2e98d 100644 --- a/src/macos/keycodes.rs +++ b/src/macos/keycodes.rs @@ -24,6 +24,14 @@ const F6: CGKeyCode = 97; const F7: CGKeyCode = 98; const F8: CGKeyCode = 100; const F9: CGKeyCode = 101; +const F13: CGKeyCode = 105; +const F14: CGKeyCode = 107; +const F15: CGKeyCode = 113; +const F16: CGKeyCode = 106; +const F17: CGKeyCode = 64; +const F18: CGKeyCode = 79; +const F19: CGKeyCode = 80; +const F20: CGKeyCode = 90; const FUNCTION: CGKeyCode = 63; const LEFT_ARROW: CGKeyCode = 123; const META_LEFT: CGKeyCode = 55; @@ -105,6 +113,14 @@ pub fn code_from_key(key: Key) -> Option { Key::F7 => Some(F7), Key::F8 => Some(F8), Key::F9 => Some(F9), + Key::F13 => Some(F13), + Key::F14 => Some(F14), + Key::F15 => Some(F15), + Key::F16 => Some(F16), + Key::F17 => Some(F17), + Key::F18 => Some(F18), + Key::F19 => Some(F19), + Key::F20 => Some(F20), Key::LeftArrow => Some(LEFT_ARROW), Key::MetaLeft => Some(META_LEFT), Key::MetaRight => Some(META_RIGHT), @@ -189,6 +205,14 @@ pub fn key_from_code(code: CGKeyCode) -> Key { F7 => Key::F7, F8 => Key::F8, F9 => Key::F9, + F13 => Key::F13, + F14 => Key::F14, + F15 => Key::F15, + F16 => Key::F16, + F17 => Key::F17, + F18 => Key::F18, + F19 => Key::F19, + F20 => Key::F20, LEFT_ARROW => Key::LeftArrow, META_LEFT => Key::MetaLeft, META_RIGHT => Key::MetaRight, From 24d1712bdbd0233aa45b2b47666837fa2a6a2deb Mon Sep 17 00:00:00 2001 From: Tom Crouch Date: Mon, 13 May 2024 23:04:38 +0100 Subject: [PATCH 2/3] Add support for keypad keys --- src/macos/keycodes.rs | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/macos/keycodes.rs b/src/macos/keycodes.rs index 9dc2e98d..89e96bc3 100644 --- a/src/macos/keycodes.rs +++ b/src/macos/keycodes.rs @@ -90,6 +90,21 @@ const KEY_M: CGKeyCode = 46; const COMMA: CGKeyCode = 43; const DOT: CGKeyCode = 47; const SLASH: CGKeyCode = 44; +const KP_RETURN: CGKeyCode = 76; +const KP_MINUS: CGKeyCode = 78; +const KP_PLUS: CGKeyCode = 69; +const KP_MULTIPLY: CGKeyCode = 67; +const KP_DIVIDE: CGKeyCode = 75; +const KP0: CGKeyCode = 82; +const KP1: CGKeyCode = 83; +const KP2: CGKeyCode = 84; +const KP3: CGKeyCode = 85; +const KP4: CGKeyCode = 86; +const KP5: CGKeyCode = 87; +const KP6: CGKeyCode = 88; +const KP7: CGKeyCode = 89; +const KP8: CGKeyCode = 91; +const KP9: CGKeyCode = 92; pub fn code_from_key(key: Key) -> Option { match key { @@ -178,6 +193,21 @@ pub fn code_from_key(key: Key) -> Option { Key::Comma => Some(COMMA), Key::Dot => Some(DOT), Key::Slash => Some(SLASH), + Key::Kp1 => Some(KP1), + Key::Kp2 => Some(KP2), + Key::Kp3 => Some(KP3), + Key::Kp4 => Some(KP4), + Key::Kp5 => Some(KP5), + Key::Kp6 => Some(KP6), + Key::Kp7 => Some(KP7), + Key::Kp8 => Some(KP8), + Key::Kp9 => Some(KP9), + Key::Kp0 => Some(KP0), + Key::KpReturn => Some(KP_RETURN), + Key::KpMinus => Some(KP_MINUS), + Key::KpPlus => Some(KP_PLUS), + Key::KpMultiply => Some(KP_MULTIPLY), + Key::KpDivide => Some(KP_DIVIDE), Key::Function => Some(FUNCTION), Key::Unknown(code) => code.try_into().ok(), _ => None, @@ -270,6 +300,21 @@ pub fn key_from_code(code: CGKeyCode) -> Key { COMMA => Key::Comma, DOT => Key::Dot, SLASH => Key::Slash, + KP1 => Key::Kp1, + KP2 => Key::Kp2, + KP3 => Key::Kp3, + KP4 => Key::Kp4, + KP5 => Key::Kp5, + KP6 => Key::Kp6, + KP7 => Key::Kp7, + KP8 => Key::Kp8, + KP9 => Key::Kp9, + KP0 => Key::Kp0, + KP_RETURN => Key::KpReturn, + KP_MINUS => Key::KpMinus, + KP_PLUS => Key::KpPlus, + KP_MULTIPLY => Key::KpMultiply, + KP_DIVIDE => Key::KpDivide, FUNCTION => Key::Function, code => Key::Unknown(code.into()), } From 0840ac97de848aee0ea798a1216bd4e0f32c578e Mon Sep 17 00:00:00 2001 From: Tom Crouch Date: Tue, 14 May 2024 16:09:13 +0100 Subject: [PATCH 3/3] Add missing entry for right control key --- src/macos/keycodes.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/macos/keycodes.rs b/src/macos/keycodes.rs index 89e96bc3..0fe9ad36 100644 --- a/src/macos/keycodes.rs +++ b/src/macos/keycodes.rs @@ -221,6 +221,7 @@ pub fn key_from_code(code: CGKeyCode) -> Key { BACKSPACE => Key::Backspace, CAPS_LOCK => Key::CapsLock, CONTROL_LEFT => Key::ControlLeft, + CONTROL_RIGHT => Key::ControlRight, DOWN_ARROW => Key::DownArrow, ESCAPE => Key::Escape, F1 => Key::F1,