android: Add mapping from NDK Keycode to VirtualKeyCode#2226
android: Add mapping from NDK Keycode to VirtualKeyCode#2226msiglreith merged 2 commits intorust-windowing:masterfrom
Conversation
71276de to
5b7c233
Compare
1d35f8e to
ea442b0
Compare
ea442b0 to
2f65259
Compare
|
I think this is now reviewable. I have left quite a few |
msiglreith
left a comment
There was a problem hiding this comment.
thanks! the less clear cases are fine in my eyes
| Keycode::MoveEnd => Some(VirtualKeyCode::End), | ||
| Keycode::Insert => Some(VirtualKeyCode::Insert), | ||
|
|
||
| Keycode::Del => Some(VirtualKeyCode::Back), // Backspace (above Enter) |
There was a problem hiding this comment.
Started playing about with these codes, and it seems you haven't implemented a mapping for KeyCode::Back which would be needed to handle a graceful app exit (or going to the previous page) when the user presses it. The implementation for VirtualKeyCode::Back reads:
Lines 962 to 964 in f04fa5d
So I don't think we should add a new Back VirtualKeyCode and rename existing uses to Backspace, as that's really hard to notice for end-users upgrading their winit. Perhaps we can piggyback NavigateBackward but android already supports that as KeyCode::NavigatePrevious:
Keycode::Back => Some(VirtualKeyCode::NavigateBackward),How do you think we should go forward?
When working on https://github.com/torokati44/ruffle-android, I discovered that all keypress events arrive with their scancode set to
0, and their keycode set toNone. Which I found less than useful.The NDK docs for AKeyEvent_getScanCode mention that "These values are not reliable and vary from device to device.".
So I guess always setting them to
0is acceptable from their end.Tested this on Android 12, with a keyboard connected to my computer, through wired
adband https://github.com/Genymobile/scrcpy/, and it seemed to work fine.AFAICT This fixes #1867.
CHANGELOG.mdif knowledge of this change could be valuable to usersUpdated documentation to reflect any user-facing changes, including notes of platform-specific behaviorCreated or updated an example program if it would help users understand this functionalityUpdated feature matrix, if new features were added or implemented