Commit Graph

301 Commits

Author SHA1 Message Date
Robert Bragg c0f3fa6754 Check $ANDROID_GAMES_SDK for GameActivity source
For convenience, when updating to new GameActivity versions, this makes
it possible to build against the out-of-tree `android-games-sdk` repo.

This also updates `generate-bindings.sh` to point at $ANDROID_GAMES_SDK
if set.

E.g.

```
git clone git@github.com:rust-mobile/android-games-sdk.git \
    --branch android-activity-4.0.0
export ANDROID_GAMES_SDK=$PWD/android-games-sdk

./generate-bindings.sh
cargo build --features=game-activity --target=aarch64-linux-android
```
2025-04-01 15:41:51 +01:00
Robert Bragg 42af0cccfa examples/agdk-mainloop: pull in games-activity:4.0.0 2025-04-01 15:41:51 +01:00
Robert Bragg 5d7616e30e examples/agdk-mainloop: Use Gradle 8.4 (compatible with Java 21) 2025-04-01 15:41:51 +01:00
Robert Bragg 3755ed7e7a game-activity: build fixes for rust-bindgen 0.71 ffi API 2025-04-01 15:41:51 +01:00
Robert Bragg 5367c865e3 Re-generate bindings with rust-bindgen 0.71.1 2025-04-01 15:41:51 +01:00
William Casarin eacddd744a bindgen: update paths
Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:51 +01:00
Robert Bragg 36832feacf Add import-games-sdk.sh and import some APP_CMD_ changes for 4.0.0
This replaces `copy-files` + `file_list.txt` (subjective simplification)

This imports the SDK from commit 1b544f896646b29e798c5be0a151a488906797f7, from:
https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0
2025-04-01 15:41:51 +01:00
Robert Bragg 88714f0b6a Add CHANGELOG.md entry for GameActivity bump to 4.0.0 2025-04-01 15:41:49 +01:00
William Casarin 85eb7274f4 android-game-sdk-rs: bump v2.0.2 -> v4.0.0
Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:33 +01:00
William Casarin 49f2b86424 switch to android-game-sdk-rs grafted repo at v2.0.2
Also includes our patches on top (branch android-activity-2.0.2). This
is mainly to test to make sure everything is still working. We will
switch to the android-activity-4.0.0 branch when we're done

Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:33 +01:00
William Casarin 976e9d06af tree: remove local copy of v2.0.2 android-games-sdk
We are going to use a submodule so that it is easier to track and rebase
our local changes onto new versions of android-games-sdk

Signed-off-by: William Casarin <jb55@jb55.com>
2025-04-01 15:41:33 +01:00
Robert Bragg ac2e17e977 Re-export 'ndk' and 'ndk_sys' crates
Since we expose `ndk` types in the public API it makes sense to
re-export these APIs so users of android-activity can defer to these
without needing to manually sync the versions for explicit dependencies.
2025-04-01 15:38:44 +01:00
Robert Bragg db3ea3386f Bump rust-version to 1.73.0
There was a fix for the definition of the `stat` struct on Android in
1.73, and even though it's unlikely to affect many applications it still
seems worthwhile to draw a line under this and ensure that all
android-activity based applications will have that fix.

Rust 1.73 was released October 2023, which is still well over a year old
and very conservative.

This updates `generate-bindings.sh` to pass `--rust-target 1.73.0` so we
avoid generating bindings that require a more recent compiler.

(This doesn't actually regenerate the bindings but does ensure that
future updates will be constrained to generate code that is backwards
compatible with 1.73.)
2025-04-01 15:29:59 +01:00
Marijn Suijten 51d05d48c8 input: Replace open-coded types with ndk::event definitions (#163) 2025-01-27 18:12:06 +01:00
Marijn Suijten fe171bc532 Fix various codebase rots (stale CI, new Rust lints, broken MSRV checks by transitive dependency upgrades) (#164)
* game_activity/ffi: Drop cfg for inexistant `target_arch = "armv7"`

[Rust 1.80 from July 25th 2024] points out that `armv7` is not a known,
valid value for the `target_arch` cfg variable.  This is confirmed by
the docs not listing it either:
https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch

Hence drop this entirely, and rely purely on `target_arch = "arm"`.

[Rust 1.80 from July 25th 2024]: https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html

* Fix `unexpected-cfgs` by adding `api-level-30` feature and removing `test`

Some code copied from the NDK carried over the respective `feature`
`cfg` guards, without ever adding the feature to the `[features]` list
in `Cargo.toml`.  Now that Rust detects these mishaps, we can fix it
by removing `test` (bindings don't seem to be run-tested) and reexpose
`ConfigurationRef::screen_round()` which was behind a previously
unsettable `feature = "api-level-30"`.

Also remove `unsafe impl Send/Sync for ConfigurationRef` since the
upstream `ndk` already declares `Configuration` to be `Send` and `Sync`,
and `RwLock` and `Arc` carry that through.

* native_activity: Fix clippy lints around `NativeActivityGlue` not `SendSync` and unwritten `redraw_needed` field

* CI: Remove deprecated/unmaintained `actions-rs` toolchain setup

The `actions-rs` containers haven't been maintained and updated for
years and don't need to: GitHub's actions environment already comes
fully loaded with a complete `stable` Rust installation with the
standard tools (in this case `rustfmt`).  Remove the remaining toolchain
setup (which was already replaced with `hecrj/setup-rust-action`
elsewhere) to get rid of ancient Node 12 deprecation warnings.

* Bump dependency patch-versions to fix `-Zminimal-versions` and MSRV check

Use `-Zminimal-versions` in our MSRV check.  This not only ensures
our minimum version bounds are actually solid and tested (even if
they may be a bit conservative at times, i.e. we could allow older
versions except for the crates that are bumped in this patch which were
explicitly build-tested), it also allows us to use this as a base for
the MSRV test, and preempt us from failing it whenever a (transitive!)
dependency bumps its MSRV beyond ours in a *semver-compatible* release.

* Elide redundant `impl` block lifetimes following stricter Rust 1.83 lint

Rust now points out that `impl<'a> (Trait for) Struct<'a>` is
superfluous whenever `'a` is not used anywhere else in the `impl` block.
2025-01-27 17:14:13 +01:00
Robert Bragg 0d299300f4 Merge pull request #158 from rust-mobile/release-0.6.0
Release 0.6.0
v0.6.0
2024-04-26 17:23:04 +01:00
Robert Bragg 0a87a84c57 Release 0.6.0 2024-04-26 17:16:38 +01:00
SkyGrel19 7bd3ba6dde native-activity: Check for null saved_state_in pointer
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: #153
2024-04-26 16:37:42 +01:00
Marijn Suijten 6a0197c28f 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.
2024-04-26 16:36:38 +01:00
Robert Bragg e5b8242ff2 Bump MSRV to 1.69.0 considering we can't build cargo ndk with 1.68
cargo ndk will fail to build with 1.68 due to a toml_edit dep.

Technically android-activity itself should still build with 1.68
but it's simpler to synchronize the `rust-version` with the minimum
version that we actually test in CI (where we need to build cargo ndk)
2024-04-26 16:11:36 +01:00
Robert Bragg c9faa9c44e Merge pull request #151 from rust-mobile/release-0.5.2
Release 0.5.2
v0.5.2
2024-01-30 13:09:08 +00:00
Robert Bragg 4b9b8d754b Force cargo-ndk to only be built with stable toolchain
This fixes CI builds with rust 0.68 because cargo ndk depends on
cargo platform which depends on 0.70.
2024-01-30 12:42:36 +00:00
Robert Bragg 526d39c1f3 Release 0.5.2 2024-01-30 12:15:21 +00:00
Robert Bragg 4ffa3ac2e1 Merge pull request #147 from ArthurCose/motion-event-mask
native-activity/input: OR with `EVENT_ACTION_MASK` when extracting action
2024-01-30 12:05:30 +00:00
Robert Bragg 967882f3d9 Merge pull request #149 from rust-mobile/release-0.5.1
Release 0.5.1
v0.5.1
2023-12-20 22:11:18 +00:00
Robert Bragg 35e080baf0 Release 0.5.1 2023-12-20 22:03:15 +00:00
Robert Bragg 5cb67a2b89 Remove ndk dev-dependency added in #142
Although this crate has some examples that depend on the ndk, they
aren't regular Cargo examples, they are completely standalone apps
that depend on dev-dependencies.
2023-12-20 17:12:25 +00:00
Arthur Cosentino 672360c5e6 Fix multitouch MotionActions processing as unknown in native activities 2023-12-13 09:05:59 -05:00
Robert Bragg 9fce890219 Merge pull request #143 from rust-mobile/readme-update-versions
README: Update crate version in `Cargo.toml` example
2023-11-20 16:13:38 +00:00
Robert Bragg 2deec162b5 Merge pull request #145 from fornwall/android-main-thread-name
Name spawned threads
2023-11-20 16:10:27 +00:00
Fredrik Fornwall eeeb80209f Fix error after merge conflict 2023-11-20 15:36:04 +01:00
Fredrik Fornwall 6c3583dc24 Merge branch 'main' into android-main-thread-name 2023-11-20 14:35:37 +01:00
Robert Bragg bfd8bfd04c Merge pull request #133 from rust-mobile/marijn/bail-log-thread-on-read_line-error
Stop log-forwarding thread on IO errors
2023-11-20 13:24:23 +00:00
Marijn Suijten af341897a2 Generalize log-forwarding setup and stop thread on IO errors
When `read_line()` starts returning `Err` the current `if let Ok`
condition ignores those, likely causing the `loop` to spin indefinitely
while this function keeps returning errors.

Note that we don't currently store the join handle for this thread
anywhere, so won't see the error surface either (just like how the join
handle for the main thread is never checked).  Perhaps we should call
`log::error!()` to make the user aware that their IO logging has
mysteriously terminated.
2023-11-20 14:15:54 +01:00
Marijn Suijten a84722ff23 Clean up a let-else that is possible in Rust 1.68 2023-11-20 13:30:29 +01:00
Fredrik Fornwall d9af67008a Rename threads 2023-11-20 12:48:37 +01:00
Fredrik Fornwall c2f467c174 Name spawned threads
Name spawned threads to make things more clear during debugging and
profiling.
2023-11-18 19:20:15 +01:00
Marijn Suijten e14d2c1deb README: Fix MSRV badge 2023-11-04 22:40:15 +01:00
Marijn Suijten 100d5bc1d4 README: Update crate version in Cargo.toml example 2023-10-28 20:25:08 +02:00
Thierry Berger 98aef99419 Disable ndk default features to remove raw-window-handle 0.6 (#142)
The `ndk` crate enables `raw-window-handle 0.6` by default (because of
https://github.com/rust-mobile/ndk/pull/434#issuecomment-1752089087)
which might not be used by consumers of the `android-activity` crate
at all, or might (still) be a mismatching version. Even if the `rwh_0x`
features are additive, figuring that out leads to cryptic errors and it
is best to turn off these defaults completely and leave it to the user
to turn it back on in their own `[dependencies]` section if desired.
2023-10-25 23:15:21 +02:00
Robert Bragg a7114c807f Merge pull request #137 from rust-mobile/release-0.5.0
Release 0.5.0
v0.5.0
2023-10-17 00:17:12 +01:00
Robert Bragg a7dc90d9bb Release 0.5.0 2023-10-17 00:03:48 +01:00
Robert Bragg 6af4d61227 Remove redundant examples/na-mainloop/.idea directory 2023-10-17 00:03:48 +01:00
Robert Bragg 6e036c99e4 Update CHANGELOG 2023-10-17 00:03:48 +01:00
Robert Bragg 2a917ca5c4 Expose MotionEvent::action_button() state
This exposes the button associated with a button press or release
action.
2023-10-17 00:03:03 +01:00
Robert Bragg add58dbb2e native-activity: Fix copy&paste mistake in MotionEvent::action() 2023-10-17 00:03:03 +01:00
dependabot[bot] d16cb79350 build(deps): bump hecrj/setup-rust-action from 1 to 2
Bumps [hecrj/setup-rust-action](https://github.com/hecrj/setup-rust-action) from 1 to 2.
- [Release notes](https://github.com/hecrj/setup-rust-action/releases)
- [Commits](https://github.com/hecrj/setup-rust-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: hecrj/setup-rust-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 22:55:13 +01:00
Robert Bragg b590ec5484 Set workspace.resolver = "2" and avoid cargo warning 2023-10-16 21:29:01 +01:00
Robert Bragg 74d9669854 Document that AndroidApp is cheaply clonable
Fixes: #125
2023-10-16 20:44:51 +01:00
Robert Bragg a92237fab4 Add non_exhaustive to input enums
This change was meant to be squashed into #131 before landing
2023-10-16 20:31:32 +01:00