Skip to content

Commit 6a0197c

Browse files
MarijnS95rib
authored andcommitted
Upgrade to ndk-sys 0.6.0 and ndk 0.9.0
The next breaking `ndk` release puts a lot of emphasis in improving `enum`s to finally be marked `non_exhaustive`, and carry possible future values in `__Unknown(i32)` variants. This removes the lossy conversions that previously required `android-activity` to redefine its types, which could all be removed again. The `repr()` types have also been updated, as `enum` constants in C are translated to `u32` by default in `bindgen` even though they're commonly passed as `int` to every API function that consumes them.
1 parent e5b8242 commit 6a0197c

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

android-activity/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ log = "0.4"
3333
jni-sys = "0.3"
3434
cesu8 = "1"
3535
jni = "0.21"
36-
ndk-sys = "0.5.0"
37-
ndk = { version = "0.8.0", default-features = false }
36+
ndk-sys = "0.6.0"
37+
ndk = { version = "0.9.0", default-features = false }
3838
ndk-context = "0.1"
3939
android-properties = "0.2"
4040
num_enum = "0.7"

android-activity/src/native_activity/input.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,8 @@ impl<'a> PointerImpl<'a> {
262262
#[inline]
263263
pub fn axis_value(&self, axis: Axis) -> f32 {
264264
let value: u32 = axis.into();
265-
if let Ok(ndk_axis) = value.try_into() {
266-
self.ndk_pointer.axis_value(ndk_axis)
267-
} else {
268-
// FIXME: We should also be able to query `Axis::__Unknown(u32)` values
269-
// that can't currently be queried via the `ndk` `Pointer` API
270-
0.0f32
271-
}
265+
let value = value as i32;
266+
self.ndk_pointer.axis_value(value.into())
272267
}
273268

274269
#[inline]
@@ -283,7 +278,8 @@ impl<'a> PointerImpl<'a> {
283278

284279
#[inline]
285280
pub fn tool_type(&self) -> ToolType {
286-
let value: u32 = self.ndk_pointer.tool_type().into();
281+
let value: i32 = self.ndk_pointer.tool_type().into();
282+
let value = value as u32;
287283
value.into()
288284
}
289285
}

android-activity/src/native_activity/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ impl<'a> InputIteratorInner<'a> {
507507
ndk::event::InputEvent::KeyEvent(e) => {
508508
input::InputEvent::KeyEvent(input::KeyEvent::new(e))
509509
}
510+
_ => todo!("NDK added a new type"),
510511
};
511512

512513
// `finish_event` needs to be called for each event otherwise

examples/agdk-mainloop/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ edition = "2021"
99
log = "0.4"
1010
android_logger = "0.11.0"
1111
android-activity = { path="../../android-activity", features = ["game-activity"] }
12-
ndk-sys = "0.5.0"
13-
ndk = "0.8.0"
12+
ndk-sys = "0.6.0"
13+
ndk = "0.9.0"
1414

1515
[lib]
1616
name="main"

examples/na-mainloop/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ edition = "2021"
99
log = "0.4"
1010
android_logger = "0.11.0"
1111
android-activity = { path="../../android-activity", features = [ "native-activity" ] }
12-
ndk-sys = "0.5.0"
13-
ndk = "0.8.0"
12+
ndk-sys = "0.6.0"
13+
ndk = "0.9.0"
1414

1515
[lib]
1616
#name="na_mainloop"

0 commit comments

Comments
 (0)