Open MarijnS95 opened 2 months ago
Will rebase this as soon as #164 is in!
There have repeatedly been issues with directly exposing
ndk
input types in the android-activity API due to differences betweenGameActivity
andNativeActivity
We discussed this before, and as highlighted in this PR that those compatibility issues weren't brought up "upstream" at the ndk
crate before, nor really seem to exist when I put the effort in comparing these enums to replace them. If anything the ndk
already has more variants for some enums, and has a change scheduled to add anything that's still missing.
E.g. for a while the Winit Android backend wouldn't work with the game-activity backend because of stuff like this: https://github.com/rust-windowing/winit/blob/918430979f8219648daade44796c00893e42fdd8/src/platform_impl/android/mod.rs#L404
We've since fixed that, which is specifically why this PR is open now so I don't think it's fair to dredge that back up.
Since the input API is so central to the
android-activity
crate then in the past it's also been convenient to not be too tightly coupled to thendk
crate here, so I could make input API changes without being blocked on there being a newndk
release.
Again, there are little to no differences at this time. I'm keeping the struct
s on your side and only replacing the enum
s and bitflag
s anyway.
Maybe if there are some missing variants it's a good time to look at using shared types from the
ndk
crate if they can now be shared across both backends.
That's exactly what this PR did :)
I think the main thing that seems to be missing atm are some CHANGELOG notes about the breaking changes. For completeness that should probably include a note about the
repr
changes
Fixed.
As documented in
// XXX
comments, and discussed before, the copy-pastedinput
types exist because thendk
crate "wasn't set up" to allow changes toenum
s in a non-semver-breaking way (in particular, they were not marked#[non_exhaustive]
). This issue was not reported upstream, and it took me to useandroid-activity
before realizing so and fixing it in https://github.com/rust-mobile/ndk/pull/459. Also, after comparing the copy-paste here against thendk
types, no new variants were ever added, completely defeating the purpose (even though new types were added to the ustream headers and will be added to tendk
crate).Hence, remove all the open-coded types again and reexport them from the
ndk
crate. Upstream not only made allenum
s#[non_exhaustive]
, but also fixes therepr
types to not use theu32
default for untyped enum constants, but in most casesi32
when all function signatures take a signed argument.