Skip to content
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 support #2308

Closed
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ wasm-bindgen-futures = "0.4"
js-sys = "0.3"

[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = { version = "0.2" }
ndk-glue = { version = "0.3" }

[dev-dependencies]
futures-lite = "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ bevy_winit = { path = "../bevy_winit", optional = true, version = "0.5.0" }
bevy_gilrs = { path = "../bevy_gilrs", optional = true, version = "0.5.0" }

[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = {version = "0.2", features = ["logger"]}
ndk-glue = {version = "0.3", features = ["logger"]}
22 changes: 21 additions & 1 deletion crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ pub fn winit_runner_with(mut app: App, mut event_loop: EventLoop<()>) {
.get_resource::<WinitConfig>()
.map_or(false, |config| config.return_from_run);

let mut suspended = cfg!(target_os = "android");

let event_handler = move |event: Event<()>,
event_loop: &EventLoopWindowTarget<()>,
control_flow: &mut ControlFlow| {
Expand Down Expand Up @@ -481,8 +483,25 @@ pub fn winit_runner_with(mut app: App, mut event_loop: EventLoop<()>) {
event_loop,
&mut create_window_event_reader,
);
app.update();
if !suspended {
app.update();
}
}
event::Event::Resumed => {
suspended = false;
#[cfg(target_os = "android")]
{
let mut window_created_events = app
.world
.get_resource_mut::<Events<WindowCreated>>()
.unwrap();

window_created_events.send(WindowCreated {
id: bevy_window::WindowId::primary(),
});
}
}
event::Event::Suspended => suspended = true,
_ => (),
}
};
Expand Down Expand Up @@ -510,6 +529,7 @@ fn handle_create_window_events(
&create_window_event.descriptor,
);
windows.add(window);
#[cfg(not(target_os = "android"))]
window_created_events.send(WindowCreated {
id: create_window_event.id,
});
Expand Down
4 changes: 2 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ skip = [
{ name = "getrandom", version = "0.1" },
{ name = "libm", version = "0.1" },
{ name = "mach", version = "0.2" },
{ name = "ndk", version = "0.2" },
{ name = "ndk-glue", version = "0.2" },
{ name = "ndk", version = "0.3" },
{ name = "ndk-glue", version = "0.3" },
TheRawMeatball marked this conversation as resolved.
Show resolved Hide resolved
{ name = "num_enum", version = "0.4" },
{ name = "num_enum_derive", version = "0.4" },
{ name = "rand", version = "0.7" },
Expand Down