Created
January 5, 2012 13:26
-
-
Save curthard89/1565244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UniChar)characterForVirtualKeyCode:(NSInteger)keyCode | |
{ | |
/************** | |
THIS REQUIRES THE CARBON FRAMEWORK! | |
***************/ | |
UInt32 deadKeyState = 0; | |
UniCharCount actualCount = 0; | |
UniChar baseChar; | |
TISInputSourceRef sourceRef = TISCopyCurrentKeyboardLayoutInputSource(); | |
CFDataRef keyLayoutPtr = (CFDataRef)TISGetInputSourceProperty( sourceRef, kTISPropertyUnicodeKeyLayoutData ); | |
CFRelease( sourceRef ); | |
UCKeyTranslate( (UCKeyboardLayout *)CFDataGetBytePtr( keyLayoutPtr ), keyCode, kUCKeyActionDown, 0, | |
LMGetKbdLast(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualCount, &baseChar ); | |
return baseChar; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment