Skip to content

Asking for more KeyAction events when using android keyboard. #4067

@mvvvv

Description

@mvvvv

Description

This issue also concerns the PR rust-mobile/android-activity#178 from @jancespivo

With Openxr/StereoKit-rust, as I can't use neither Window::set_ime_allowed nor app.show_soft_input(), I tested the Android keyboard launched via JNI on the Meta Quest2. It works exactly like any Android device.
https://github.com/mvvvv/StereoKit-rust/blob/master/src/tools/os_api.rs#L191

Winit blocks many characters including accented characters which it replaces completely with a backspace and erases the character typed previously. I made a short video: https://youtu.be/os8cucfF3D8

The problem is that I can only rely on event::ElementState::Pressed and event::ElementState::Released which are the only events retained (

let state = match key.action() {
) when in the log I can see the events I need:

12-30 15:16:17.601 23830 23830 W ViewRootImpl[NativeActivity]: Dropping event (no window focus):KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DEL, scanCode=0, metaState=0, flags=0x0, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, source=0x0, displayId=0 }
12-30 15:16:17.601 23830 23830 W ViewRootImpl[NativeActivity]: Cancelling event (no window focus):KeyEvent { action=ACTION_UP, keyCode=KEYCODE_DEL, scanCode=0, metaState=0, flags=0x20, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, source=0x0, displayId=0 }
12-30 15:16:17.601 23830 23830 W ViewRootImpl[NativeActivity]: Cancelling event (no window focus):KeyEvent { action=ACTION_UP, keyCode=KEYCODE_DEL, scanCode=0, metaState=0, flags=0x20, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, source=0x0, displayId=0 }
12-30 15:16:17.602 23830 23830 W ViewRootImpl[NativeActivity]: Dropping event (no window focus):KeyEvent { action=ACTION_MULTIPLE, keyCode=KEYCODE_UNKNOWN, scanCode=0, characters="ò", metaState=0, flags=0x0, repeatCount=0, eventTime=19026369, downTime=19026369, deviceId=-1, source=0x101, displayId=-1 }
12-30 15:16:17.605 23830 23882 D SK_rust_Demos: !!!KeyboardInput: KeyEvent { physical_key: Code(Backspace), logical_key: Named(Backspace), text: None, location: Standard, state: Released, repeat: false, platform_specific: KeyEventExtra }

Having access to ACTION_MULTIPLE event seems to be the only way to get enhanced characters(here ò), smileys and utf8 characters.

Device and Android version

Meta Quest 2 Horizon OS v72 (android 12.1)

Winit version

0.30.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - androidAffects the Android backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions