From e80a4fd2b149b987232a709dd8d244c7097ef4de Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 10 Aug 2021 01:01:51 -0500 Subject: [PATCH] Add support for Unicode text input --- Limelight/Input/StreamView.m | 19 +++++++++++++++---- moonlight-common/moonlight-common-c | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index e93d007..c39f20f 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -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]; } } diff --git a/moonlight-common/moonlight-common-c b/moonlight-common/moonlight-common-c index fa892c5..a290ec0 160000 --- a/moonlight-common/moonlight-common-c +++ b/moonlight-common/moonlight-common-c @@ -1 +1 @@ -Subproject commit fa892c53344f76846b27d37cde1b904d745d42b1 +Subproject commit a290ec032b6a068a56461bbe4b60798b68a319d5