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.