Fixed duplicate key press/release events on iOS

When a hardware keyboard is attached, it can take over 100 ms for the keyboard event to generate text input. In that case we want to record that we recently received a keyboard event so we don't synthesize duplicate virtual key press/release events for the input text.
This commit is contained in:
Sam Lantinga
2023-08-02 01:08:00 -07:00
parent a8abe612ed
commit 648de4f9b8
3 changed files with 30 additions and 11 deletions

View File

@@ -485,8 +485,8 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
size_t deleteLength = SDL_utf8strlen([[committedText substringFromIndex:matchLength] UTF8String]);
while (deleteLength > 0) {
/* Send distinct down and up events for each backspace action */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
SDL_SendVirtualKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
SDL_SendVirtualKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
--deleteLength;
}
}