-
Notifications
You must be signed in to change notification settings - Fork 909
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
android: Add mapping from NDK Keycode to VirtualKeyCode #2226
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
/// The Backspace key, right over Enter. | |
// TODO: rename | |
Back, |
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
0
is acceptable from their end.Tested this on Android 12, with a keyboard connected to my computer, through wired
adb
and https://github.com/Genymobile/scrcpy/, and it seemed to work fine.AFAICT This fixes #1867.
CHANGELOG.md
if 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