From caaa106d8037ea8052111e7e96f38cbb20d47163 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 24 Feb 2020 11:49:40 -0400 Subject: [PATCH] add capslock key support when darwin --- hook/darwin/hook_c.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hook/darwin/hook_c.h b/hook/darwin/hook_c.h index b717bcf..646cf1c 100644 --- a/hook/darwin/hook_c.h +++ b/hook/darwin/hook_c.h @@ -582,15 +582,17 @@ static inline void process_modifier_changed(uint64_t timestamp, CGEventRef event process_key_released(timestamp, event_ref); } } - /* FIXME This should produce a modifier mask for the caps lock key! else if (keycode == kVK_CapsLock) { - // Process as a key pressed event. - process_key_pressed(timestamp, event_ref); - - // Set the caps-lock flag for release. - caps_down = true; + if (current_modifiers & MASK_CAPS_LOCK) { + // Process as a key pressed event. + unset_modifier_mask(MASK_CAPS_LOCK); + process_key_released(timestamp, event_ref); + } else { + // Process as a key released event. + set_modifier_mask(MASK_CAPS_LOCK); + process_key_pressed(timestamp, event_ref); + } } - */ } /* These events are totally undocumented for the CGEvent type, but are required to grab media and caps-lock keys.