This key is a dead key, as you can see if you try it yourself or look at a keyboard viewer with an active German layout.
On a Mac, the way to enter the actual dead key character without composing it with another character is to press the space bar after it. So try: Disable kUCKeyTranslateNoDeadKeysBit
, and if UCKeyTranslate
sets the dead key state, translate the space after it.
EDIT (added by user)
Just for future people, here is a fixed code with the right solution.
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr); if(keyboardLayout) { UInt32 deadKeyState = 0; UniCharCount maxStringLength = 255; UniCharCount actualStringLength = 0; UniChar unicodeString[maxStringLength]; OSStatus status = UCKeyTranslate(keyboardLayout, keyCode, kUCKeyActionDown, 0, LMGetKbdType(), 0, &deadKeyState, maxStringLength, &actualStringLength, unicodeString); if (actualStringLength == 0 && deadKeyState) { status = UCKeyTranslate(keyboardLayout, kVK_Space, kUCKeyActionDown, 0, LMGetKbdType(), 0, &deadKeyState, maxStringLength, &actualStringLength, unicodeString); } if(actualStringLength > 0 && status == noErr) return [[NSString stringWithCharacters:unicodeString length:(NSUInteger)actualStringLength] uppercaseString]; }
Peter Hosey Nov 25 2018-11-11T00: 00Z
source share