| Summary: | Voice to text feature on Android repeats some text via SDL_TEXTINPUT | ||
|---|---|---|---|
| Product: | SDL | Reporter: | philhassey <phil> |
| Component: | events | Assignee: | Sylvain <sylvain.becker> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | gabomdq, icculus, phil |
| Version: | 2.0.1 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | patch | ||
|
Description
philhassey
2013-11-23 14:38:00 UTC
Gabriel, is this something you can reproduce? If it's an easy fix, I'd like to get it into 2.0.4. --ryan. Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though! I give a try on a different version (Android 5.1.1) and it seems to work correctly: one SDL_TEXTINPUT event for the whole sentence. But, I noticed the variable "newCursorPosition" is not used. https://hg.libsdl.org/SDL/file/4276937a9792/android-project/src/org/libsdl/app/SDLActivity.java#l1664 https://hg.libsdl.org/SDL/file/6120f75935f9/src/core/android/SDL_android.c#l554 Android doc: https://developer.android.com/reference/android/view/inputmethod/InputConnection.html#commitText(java.lang.CharSequence,%20int) Maybe there could be some corner case where we should use the "newCursorPosition" ? On an Android Nexus10, with Android 4.2.2, I have reproduced the issue. Saying : "1 2 3", I got the input : commitText:__12__ newCursorPosition=1 deleteSurroundingText beforeLength=1 afterLength=0 commitText:__ __ newCursorPosition=1 commitText:__2__ newCursorPosition=1 commitText:__ 3__ newCursorPosition=1 deleteSurroundingText beforeLength=5 afterLength=0 commitText:__1 2 3__ newCursorPosition=1 I think you can have several SDL_TEXTINPUT events (eg redundant commitText()), but in between, you have also a few "backspaces" (deleteSurroundingText()). I you sum up all commiText()s and deleteSurroundinText()s, you have the correct sentence in the end. But, currently, I think deleteSurroundinText() is broken because it would only send 1 backspace whereas 5 backspaces are need in the example. Also, it uses "sendKeyEvent()" which do both a commitText() and a onNativeKeyDown(). (backspace would be duplicated). Created attachment 2895 [details]
patch
Small patch for this issue. I tested it and it seems to work.
- it can send several backspaces (instead of only 1).
- it calls directly "sendKeyEvent()" instead of "super.sendKeyEvent()".
otherwise, it would go through the android internals, calling again "onKey()".
and then the "backspace" would arrive after the next "commitText()".
Fixed, thanks! https://hg.libsdl.org/SDL/rev/323fc605104f |