Add support for Unicode text input

This commit is contained in:
Cameron Gutman 2021-08-10 01:01:51 -05:00
parent 68e6690e55
commit e80a4fd2b1
2 changed files with 16 additions and 5 deletions

View File

@ -52,7 +52,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
TemporarySettings* settings = [[[DataManager alloc] init] getSettings];
keyInputField = [[UITextField alloc] initWithFrame:CGRectZero];
[keyInputField setKeyboardType:UIKeyboardTypeASCIICapable];
[keyInputField setKeyboardType:UIKeyboardTypeDefault];
[keyInputField setAutocorrectionType:UITextAutocorrectionTypeNo];
[keyInputField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[keyInputField setSpellCheckingType:UITextSpellCheckingTypeNo];
@ -503,13 +503,24 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
LiSendKeyboardEvent(0x08, KEY_ACTION_UP, 0);
} else {
// Character 0 will be our known sentinel value
// Check if any characters exist which can't be represented in a basic key event
for (int i = 1; i < [inputText length]; i++) {
struct KeyEvent event = [KeyboardSupport translateKeyEvent:[inputText characterAtIndex:i] withModifierFlags:0];
if (event.keycode == 0) {
// If we don't know the code, don't send anything.
Log(LOG_W, @"Unknown key code: [%c]", [inputText characterAtIndex:i]);
continue;
// We found an unknown key, so send the entire string as UTF-8
const char* utf8String = [inputText UTF8String];
// Skip the first character which is our sentinel
LiSendUtf8TextEvent(utf8String + 1, (int)strlen(utf8String) - 1);
return;
}
}
// We didn't find any unknown characters, so send them all as basic key events
for (int i = 1; i < [inputText length]; i++) {
struct KeyEvent event = [KeyboardSupport translateKeyEvent:[inputText characterAtIndex:i] withModifierFlags:0];
assert(event.keycode != 0);
[self sendLowLevelEvent:event];
}
}

@ -1 +1 @@
Subproject commit fa892c53344f76846b27d37cde1b904d745d42b1
Subproject commit a290ec032b6a068a56461bbe4b60798b68a319d5