summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave DeLong2015-02-06 09:46:34 -0800
committerDave DeLong2015-02-06 09:46:34 -0800
commit80a9663506c3ed9b861b6ae6fd88a1e13d31ee55 (patch)
tree3d4694ba3deb88d398253473513c8542d6c85199
parent6e52b1f4753d8363c4ced6dd779ac92716e49fb0 (diff)
parentd5e6ab5bad050d21d93781a5e4e8c6e60ca449e6 (diff)
downloadDDHotKey-80a9663506c3ed9b861b6ae6fd88a1e13d31ee55.tar.bz2
Merge pull request #7 from nilennoct/Fix-crash-using-non-unicode-layouts
Fix crash using non-unicode layouts
-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) {