Fix #109630: Grave and Single Quote keys not being detected on MacOS
The `UCKeyTranslate` function was being used wrong. The `deadKeyState` param should use `kUCKeyTranslateNoDeadKeysMask` instead of `kUCKeyTranslateNoDeadKeysBit` (optionally could also use `(1 << kUCKeyTranslateNoDeadKeysBit`)). This commit also dispenses with accessing the keyAction, as this is not crucial for determining the key. Comments have also been added to better describe the code. Pull Request: https://projects.blender.org/blender/blender/pulls/109987
This commit is contained in:
parent
b7a119c785
commit
75658109be
|
@ -77,7 +77,7 @@ static GHOST_TButton convertButton(int button)
|
|||
* \param recvChar: the character ignoring modifiers (except for shift)
|
||||
* \return Ghost key code
|
||||
*/
|
||||
static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
|
||||
static GHOST_TKey convertKey(int rawCode, unichar recvChar)
|
||||
{
|
||||
// printf("\nrecvchar %c 0x%x",recvChar,recvChar);
|
||||
switch (rawCode) {
|
||||
|
@ -238,7 +238,10 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
|
|||
return GHOST_kKeyUpPage;
|
||||
case kVK_PageDown:
|
||||
return GHOST_kKeyDownPage;
|
||||
#if 0 /* TODO: why are these commented? */
|
||||
#if 0
|
||||
/* These constants with "ANSI" in the name are labeled according to the key position on an
|
||||
* ANSI-standard US keyboard. Therefore they may not match the physical key label on other
|
||||
* keyboard layouts. */
|
||||
case kVK_ANSI_Minus: return GHOST_kKeyMinus;
|
||||
case kVK_ANSI_Equal: return GHOST_kKeyEqual;
|
||||
case kVK_ANSI_Comma: return GHOST_kKeyComma;
|
||||
|
@ -284,10 +287,10 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
|
|||
|
||||
UCKeyTranslate((UCKeyboardLayout *)CFDataGetBytePtr(uchrHandle),
|
||||
rawCode,
|
||||
keyAction,
|
||||
kUCKeyActionDown,
|
||||
0,
|
||||
LMGetKbdType(),
|
||||
kUCKeyTranslateNoDeadKeysBit,
|
||||
kUCKeyTranslateNoDeadKeysMask,
|
||||
&deadKeyState,
|
||||
1,
|
||||
&actualStrLength,
|
||||
|
@ -1830,18 +1833,13 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||
|
||||
case NSEventTypeKeyDown:
|
||||
case NSEventTypeKeyUp:
|
||||
/* Returns an empty string for dead keys. */
|
||||
charsIgnoringModifiers = [event charactersIgnoringModifiers];
|
||||
if ([charsIgnoringModifiers length] > 0) {
|
||||
keyCode = convertKey([event keyCode],
|
||||
[charsIgnoringModifiers characterAtIndex:0],
|
||||
[event type] == NSEventTypeKeyDown ? kUCKeyActionDown :
|
||||
kUCKeyActionUp);
|
||||
keyCode = convertKey([event keyCode], [charsIgnoringModifiers characterAtIndex:0]);
|
||||
}
|
||||
else {
|
||||
keyCode = convertKey([event keyCode],
|
||||
0,
|
||||
[event type] == NSEventTypeKeyDown ? kUCKeyActionDown :
|
||||
kUCKeyActionUp);
|
||||
keyCode = convertKey([event keyCode], 0);
|
||||
}
|
||||
|
||||
characters = [event characters];
|
||||
|
|
Loading…
Reference in New Issue