diff --git a/SquirrelInputController.m b/SquirrelInputController.m index 02f0ef8a4..8e758cd40 100644 --- a/SquirrelInputController.m +++ b/SquirrelInputController.m @@ -120,6 +120,13 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender release_mask = modifiers & OSX_ALT_MASK ? 0 : kReleaseMask; [self processKey:rime_keycode modifiers:(rime_modifiers | release_mask)]; } + if (changes & OSX_FN_MASK) { + if (!keyCodeAvailable) { + rime_keycode = XK_Hyper_L; + } + release_mask = modifiers & OSX_FN_MASK ? 0 : kReleaseMask; + [self processKey:rime_keycode modifiers:(rime_modifiers | release_mask)]; + } if (changes & OSX_COMMAND_MASK) { if (!keyCodeAvailable) { rime_keycode = XK_Super_L; @@ -150,6 +157,11 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender modifiers & OSX_CAPITAL_MASK); if (rime_keycode) { int rime_modifiers = osx_modifiers_to_rime_modifiers(modifiers); + // revert non-modifier function keys' FunctionKeyMask (FwdDel, Navigations, F1..F19) + if ((keyCode <= 0xff && keyCode >= 0x60) || keyCode == 0x50 || keyCode == 0x4f || + keyCode == 0x47 || keyCode == 0x40) { + rime_modifiers ^= kHyperMask; + } handled = [self processKey:rime_keycode modifiers:rime_modifiers]; [self rimeUpdate]; } diff --git a/macos_keycode.h b/macos_keycode.h index 839bc7605..05b85f990 100644 --- a/macos_keycode.h +++ b/macos_keycode.h @@ -9,6 +9,7 @@ #define OSX_CTRL_MASK 1 << 18 #define OSX_ALT_MASK 1 << 19 #define OSX_COMMAND_MASK 1 << 20 +#define OSX_FN_MASK 1 << 23 // key codes // diff --git a/macos_keycode.m b/macos_keycode.m index fc7f428a9..a4437a324 100644 --- a/macos_keycode.m +++ b/macos_keycode.m @@ -17,6 +17,8 @@ int osx_modifiers_to_rime_modifiers(unsigned long modifiers) ret |= kAltMask; if (modifiers & OSX_COMMAND_MASK) ret |= kSuperMask; + if (modifiers & OSX_FN_MASK) + ret |= kHyperMask; return ret; }