SDL
SDL copied to clipboard
Android: text input not working correctly on SDL 2.24.0?
As of SDL 2.24.0, when opening the virtual keyboard using SDL_StartTextInput()
, pressing a single key does nothing until I select a word from the dictionary.
Also, any previous chars in the input field disappear when adding a new word from a dictionary, so if the new word is larger than the old word, the old one disappears.
I believe this was caused by 37a517dc36b7ba8f703c82a408bef6e44e5786ba, which also seems to fix some other bugs.
However, in my case, since the IDE input does not provide its own text input window (only the virtual keyboard is shown), and the actual text input field is the one displayed and rendered by the game itself, this makes it impossible to properly type on android.
For reference, I tested on a Samsung Galaxy S10 and a Samsung Galaxy Tab A.
I admit I'm not sure if I'm doing something wrong, but Android input has always worked like this since at least SDL 2.0.10, so I'm a bit confused now.
I can reproduce this I think, at least I am seeing a difference, I now have to insert key-enter-key-enter-... on my Android keyboard, before each key would be directly sent without the need to hit enter, so it worked better with the in-game text input widgets. In my case I had to upgrade because users were hitting #5322, which has been fixed. Since it's in the Android java project I am reverting this specific commit on our side (thanks for pointing it!), I feel the right way for us to work with the intended behavior in SDL would be to support IME, but we haven't been able to go there yet.
I managed to fix my problem by properly handling the SDL_TEXTEDITING
event, so this may not be an android issue after all.
@crudelios was it the commit here: https://github.com/Keriew/augustus/commit/4e03c87f10411845b6cd8eb578df65f777bda937 ? I am curious why the handling had to be Android exclusive instead of being the same for all systems.
Yes that's the one.
Well, the only reason it's an android exclusive is because "if it ain't broken, don't fix it". Things seem to work fine everywhere else without that event, and since I don't really have time to test if it breaks input on other systems, I just added the event where it's needed.
Thank you for answering. I think I may adopt a similar strategy. :)
@ericoporto Although I fixed the issue on my end I'll leave this open until you try to fix it.
If you do, then this is definitely not a bug and the issue can be closed.
I updated the Android text input to work more the way you expect, where you get text in progress and backspaces as it's updated. This may or may not work well with the various IMEs, so I'll leave this open for feedback.
Thanks, I'll test!
I'm wondering though, is it possible (by using a hint or something) no not automatically send backspace inputs?
On my current implementation I'm capable of handling the backspaces myself, taking into account the actual characters the game has written instead of relying on what sdl/android thinks has been the actual in-game input.
Please scratch my last comment, upon testing things work perfectly now and I can see the SDL_TEXTEDITING
event is no longer used.
I tested it both on regular ascii english language keyboard and on a Japanese keyboard and things seem to be working fine.
Great, thank you!
Is there any way to revert this change or support both methods? I really need the previous behavior for backwards compatibility.
I understand the method and we could create an API to work with it , but we also need the previous method for games assuming the keyboard would work like it in a non-IME desktop - we have 20 years old games we are compatible...
For these, since there is no "Show keyboard", text edit is the way to get the keyboard to show and password input is the way to get instant feedback on the game.