-
Notifications
You must be signed in to change notification settings - Fork 930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ReceivedCharacter
on Android
#2305
Comments
Just in case there might be an XY problem here I was wondering - are you more just looking to have decent support for text input on Android, which should support full unicode input (e.g. via https://developer.android.com/games/agdk/add-support-for-text-input which was mentioned in the linked thread) or maybe more specifically want Something related that I noticed recently was that in Java the KeyEvent API does actually have a |
Yeah my wording is not 100% as I'm new in the space. The end goal would be to have the virtual keyboard character a user presses to be sent as |
I think the main difference I'd expect is that for text input on Android it's usually via a virtual keyboard and so then I guess the trickier part is dealing with adjusting your game/UI to fit any current text box in the visible space above the keyboard and then responding to higher-level input method events. That makes text input handling more like handling IMEs on other platforms, instead of responding to lower-level keyevents - which mainly make sense with physical input devices. E.g. quoting from the KeyEvent docs:
So I suppose I was curious to try and gauge a bit more about your higher-level use case - e.g. if you care more about physical keyboards + input devices then I can see how that could be practically supported via It might make sense that Winit should also support a higher-level portable IME API that caters to soft keyboard input on Android (hopefully supporting all the features of https://developer.android.com/games/agdk/add-support-for-text-input) . I think there has been some work on IME support in general for desktop window systems but I'm not sure atm how well that maps to Android. Comparable wayland protocol: |
The IME api was merged and text-input-v3 is implemented on Wayland. Basically you have |
Taking a bit more of a look at this; the two main things I'm uncertain about currently are:
I've added a more detailed comment here: #1497 |
I have no idea wrt on-screen-keyboards on android and briefly familiar with Wayland onces, and those don't require any changes in winit at all to work from what I know right now. Though, that might change in the future. |
Yeah, simple onscreen keyboards handled in a Wayland compositor can probably just be implemented to look like regular keyboard input (i.e. like a physical keyboard), transparent to the application since input is proxied via the compositor. Android on screen keyboards are more comparable to desktop IMEs except that you don't use Android has a separate mechanism for reporting changes to 'insets' that let the app know when an onscreen keyboard is visible, which isn't currently a concept that exists in Winit. I'm guessing that the current interface can be used to bootstrap some basic IME/on-screen-keyboard support on Android by basically reporting that there is never any selection - and hopefully most IMEs will handle that gracefully, I'm not really sure atm. Other details will be with deciding how to request for the IME/on-screen-keyboard to show and hide. Android has a few different states to account for users being able to forcibly enable an IME UI - I think for accessibility needs - and so there's some distinction for applications to be able to say "really hide the IME" vs "hide the IME if the user hasn't forcibly shown an IME". |
The sole reason I asked for the While Regarding the IME position, not sure if that is part of this issue. Handling of the UI and placement of the IME is in my view a separate issue. |
yip, makes sense
To clarify a bit; GameActivity batches input events and apps are generally expected to pull them in sync with their rendering updates. This is more about avoiding lots of redundant mainloop wake ups and assuming that games will be waking up regularly to redraw. (so more of a game-centric optimization that shouldn't really affect input handling in terms of text vs characters)
Right this is what the Winit "IME" API is basically about. The terminology is borrowed from how desktops traditionally support text input for languages like Chinese and Japanese where you typically compose characters with an overlayed UI showing language-specific completions. On Android though an on-screen-keyboard is also an input method in much the same way as a desktop input method. These input methods work by intercepting the physical inputs and send you strings of text instead of characters and they also track a special "compose" region that is like a tentative/partial completion for whatever the user is currently typing. The stuff about IME position is just because I was starting to think about how to support the Winit IME abstraction on Android to support on-screen-keyboards properly but one of the notable differences between the IME abstraction on Android and what you typically have for desktop window systems is that on desktops the application is responsible for telling the IME where in their window input is happening (e.g. the position of the focused text entry) so that it can place it's UI for showing character completions next to the text entry. On Android though the IME UI is the on-screen-keyboard which is in a fixed location. |
Thanks for clarifying, I will have a look at the current IME efforts!
This is what had me a bit confused since I didn't consider that IME UI position is not always determined by the "operating system", like on Android. Sounds like something that is needed in the future, at least for completeness. Though I feel that it deserves its own specific issue. Maybe create one about adding support for placement of IME UI? |
Hello!
On Android the
ReceivedCharacter
event is not implemented. This could be due to the fact that there does not appear to be any way to get the unicode character using NDK as it stands today. So any key pressed using the virtual keyboard will have to rely on the keycode and metadata state which limits the number of characters supported to A-Z, 0-9 and some special characters.The issues was mentioned in this thread but I feelt this deserves its own issue. Maybe its something I missed, and it is possible to get the unicode character?
I created a fork that does a lot of the work for our (Embark) use-case for now, but its a bit hacky and limited in its functionality there for not something that I feel should be merged to
winit
.The text was updated successfully, but these errors were encountered: