forked from bartvdbraak/blender
OSX: dalai's patch for utf8 support, todo: uppercase chars not working yet
This commit is contained in:
parent
fe30dcbfb6
commit
36017e2af9
@ -1655,7 +1655,16 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||||||
return GHOST_kFailure;
|
return GHOST_kFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
char utf8_buf[6]= {'\0'}; /* TODO, unicode input */
|
/* unicode input - not entirely supported yet
|
||||||
|
* but we are getting the right byte, Blender is not drawing it though
|
||||||
|
* also some languages may need special treatment:
|
||||||
|
- Japanese: romanji is used as input, and every 2 letters OSX converts the text
|
||||||
|
to Hiragana/Katakana.
|
||||||
|
- Korean: one add one letter at a time, and then the OSX join them in the equivalent
|
||||||
|
combined letter.
|
||||||
|
*/
|
||||||
|
char utf8_buf[6]= {'\0'};
|
||||||
|
|
||||||
switch ([event type]) {
|
switch ([event type]) {
|
||||||
|
|
||||||
case NSKeyDown:
|
case NSKeyDown:
|
||||||
@ -1669,7 +1678,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||||||
keyCode = convertKey([event keyCode],0,
|
keyCode = convertKey([event keyCode],0,
|
||||||
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
|
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
|
||||||
|
|
||||||
|
/* ascii */
|
||||||
characters = [event characters];
|
characters = [event characters];
|
||||||
if ([characters length]>0) { //Check for dead keys
|
if ([characters length]>0) { //Check for dead keys
|
||||||
//Convert characters to iso latin 1 encoding
|
//Convert characters to iso latin 1 encoding
|
||||||
@ -1682,15 +1691,31 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||||||
else
|
else
|
||||||
ascii= 0;
|
ascii= 0;
|
||||||
|
|
||||||
|
/* unicode */
|
||||||
|
if ([characters length]>0) {
|
||||||
|
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
if ([convertedCharacters length]>0) {
|
||||||
|
utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
|
||||||
|
utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
|
||||||
|
utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
|
||||||
|
utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
|
||||||
|
utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
|
||||||
|
utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
utf8_buf[0] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
|
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
|
||||||
break; //Cmd-Q is directly handled by Cocoa
|
break; //Cmd-Q is directly handled by Cocoa
|
||||||
|
|
||||||
if ([event type] == NSKeyDown) {
|
if ([event type] == NSKeyDown) {
|
||||||
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
|
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
|
||||||
//printf("\nKey down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
|
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
||||||
} else {
|
} else {
|
||||||
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
|
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
|
||||||
//printf("\nKey up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
|
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user