summaryrefslogtreecommitdiffstats
path: root/DDHotKeyUtilities.m
diff options
context:
space:
mode:
Diffstat (limited to 'DDHotKeyUtilities.m')
-rw-r--r--DDHotKeyUtilities.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/DDHotKeyUtilities.m b/DDHotKeyUtilities.m
index 4c44ac1..f298a43 100644
--- a/DDHotKeyUtilities.m
+++ b/DDHotKeyUtilities.m
@@ -97,6 +97,14 @@ NSString *DDStringFromKeyCode(unsigned short keyCode, NSUInteger modifiers) {
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
+
+ // Fix crash using non-unicode layouts, such as Chinese or Japanese.
+ if (!uchr) {
+ CFRelease(currentKeyboard);
+ currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource();
+ uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
+ }
+
const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
if (keyboardLayout) {