mirror of
https://github.com/rust-mobile/android-activity.git
synced 2026-07-04 05:47:26 +00:00
Import android-games-sdk changes for 4.0.0
This imports the SDK from commit 090732c3ca7d8b47ed39e028081d685e4097db7f, from: https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0 This imports a patch to revert the recent addition of a `_rust_glue_on_create_hook` in favour of fixing the Rust wrapper for `GameActivity_onCreate` which is more consistent with the `ANativeActivity_onCreate` entrypoint that we have in the `native-activity` backend. This also: - Fixes a related rerun-if-changed path in build.rs - Removes the reference to _rust_glue_on_create_hook src/game_activity/mod.rs
This commit is contained in:
+1
-1
@@ -322,7 +322,7 @@ typedef void GameActivity_createFunc(GameActivity* activity, void* savedState,
|
||||
* "android.app.func_name" string meta-data in your manifest to use a different
|
||||
* function.
|
||||
*/
|
||||
extern GameActivity_createFunc GameActivity_onCreate_C;
|
||||
extern GameActivity_createFunc GameActivity_onCreate;
|
||||
|
||||
/**
|
||||
* Finish the given activity. Its finish() method will be called, causing it
|
||||
|
||||
-10
@@ -514,16 +514,6 @@ void android_app_clear_motion_events(struct android_input_buffer* inputBuffer);
|
||||
*/
|
||||
void android_app_clear_key_events(struct android_input_buffer* inputBuffer);
|
||||
|
||||
/**
|
||||
* A hook that is called within Activity.onCreate, before the android_main
|
||||
* thread has been spawned.
|
||||
*
|
||||
* This gives the Rust glue code a chance to perform any necessary
|
||||
* initialization that needs to run from the Java main/UI thread, before the
|
||||
* android_main thread is started.
|
||||
*/
|
||||
extern void _rust_glue_on_create_hook(struct android_app* app);
|
||||
|
||||
/**
|
||||
* This is a springboard into the Rust glue layer that wraps calling the
|
||||
* main entry for the app itself.
|
||||
|
||||
+1
-1
@@ -538,7 +538,7 @@ static jlong initializeNativeCode_native(
|
||||
// read configuration for the first time
|
||||
readConfigurationValues(code, javaConfig);
|
||||
|
||||
GameActivity_onCreate_C(code, rawSavedState, rawSavedSize);
|
||||
GameActivity_onCreate(code, rawSavedState, rawSavedSize);
|
||||
|
||||
code->gameTextInput = GameTextInput_init(env, 0);
|
||||
GameTextInput_setEventCallback(code->gameTextInput,
|
||||
|
||||
+3
-6
@@ -224,8 +224,6 @@ static void* android_app_entry(void* param) {
|
||||
android_app->cmdPollSource.app = android_app;
|
||||
android_app->cmdPollSource.process = process_cmd;
|
||||
|
||||
_rust_glue_on_create_hook(android_app);
|
||||
|
||||
ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
||||
ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN,
|
||||
ALOOPER_EVENT_INPUT, NULL, &android_app->cmdPollSource);
|
||||
@@ -756,10 +754,9 @@ static bool onEditorAction(GameActivity* activity, int action) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// XXX: This symbol is renamed with a _C suffix and then re-exported from
|
||||
// Rust because Rust/Cargo don't give us a way to directly export symbols
|
||||
// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771
|
||||
//
|
||||
// XXX: This symbol is renamed with a _C suffix so we can implement
|
||||
// `GameActivity_onCreate` as a wrapper in Rust that does some additional setup
|
||||
// before calling this function,
|
||||
JNIEXPORT
|
||||
void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
|
||||
size_t savedStateSize) {
|
||||
|
||||
@@ -9,7 +9,11 @@ fn build_glue_for_game_activity() {
|
||||
format!("{android_games_sdk}/game-text-input/prefab-src/modules/game-text-input/{src_inc}/game-text-input/{name}")
|
||||
};
|
||||
|
||||
for f in ["GameActivity.cpp", "GameActivityEvents.cpp"] {
|
||||
for f in [
|
||||
"GameActivity.cpp",
|
||||
"GameActivityEvents.cpp",
|
||||
"GameActivityEvents_internal.h",
|
||||
] {
|
||||
println!("cargo:rerun-if-changed={}", activity_path("src", f));
|
||||
}
|
||||
|
||||
@@ -17,7 +21,6 @@ fn build_glue_for_game_activity() {
|
||||
"GameActivity.h",
|
||||
"GameActivityEvents.h",
|
||||
"GameActivityLog.h",
|
||||
"GameActivityEvents_internal.h",
|
||||
] {
|
||||
println!("cargo:rerun-if-changed={}", activity_path("include", f));
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ pub const __ANDROID_API_V__: u32 = 35;
|
||||
pub const __ANDROID_NDK__: u32 = 1;
|
||||
pub const __NDK_MAJOR__: u32 = 29;
|
||||
pub const __NDK_MINOR__: u32 = 0;
|
||||
pub const __NDK_BETA__: u32 = 4;
|
||||
pub const __NDK_BUILD__: u32 = 14033849;
|
||||
pub const __NDK_BETA__: u32 = 0;
|
||||
pub const __NDK_BUILD__: u32 = 14206865;
|
||||
pub const __NDK_CANARY__: u32 = 0;
|
||||
pub const WCHAR_MIN: u8 = 0u8;
|
||||
pub const INT8_MIN: i32 = -128;
|
||||
@@ -4854,10 +4854,6 @@ unsafe extern "C" {
|
||||
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
|
||||
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
|
||||
pub fn _rust_glue_on_create_hook(app: *mut android_app);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
|
||||
pub fn _rust_glue_entry(app: *mut android_app);
|
||||
|
||||
@@ -165,8 +165,8 @@ pub const __ANDROID_API_V__: u32 = 35;
|
||||
pub const __ANDROID_NDK__: u32 = 1;
|
||||
pub const __NDK_MAJOR__: u32 = 29;
|
||||
pub const __NDK_MINOR__: u32 = 0;
|
||||
pub const __NDK_BETA__: u32 = 4;
|
||||
pub const __NDK_BUILD__: u32 = 14033849;
|
||||
pub const __NDK_BETA__: u32 = 0;
|
||||
pub const __NDK_BUILD__: u32 = 14206865;
|
||||
pub const __NDK_CANARY__: u32 = 0;
|
||||
pub const WCHAR_MIN: u8 = 0u8;
|
||||
pub const INT8_MIN: i32 = -128;
|
||||
@@ -5266,10 +5266,6 @@ unsafe extern "C" {
|
||||
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
|
||||
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
|
||||
pub fn _rust_glue_on_create_hook(app: *mut android_app);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
|
||||
pub fn _rust_glue_entry(app: *mut android_app);
|
||||
|
||||
@@ -28,8 +28,8 @@ pub const __ANDROID_API_V__: u32 = 35;
|
||||
pub const __ANDROID_NDK__: u32 = 1;
|
||||
pub const __NDK_MAJOR__: u32 = 29;
|
||||
pub const __NDK_MINOR__: u32 = 0;
|
||||
pub const __NDK_BETA__: u32 = 4;
|
||||
pub const __NDK_BUILD__: u32 = 14033849;
|
||||
pub const __NDK_BETA__: u32 = 0;
|
||||
pub const __NDK_BUILD__: u32 = 14206865;
|
||||
pub const __NDK_CANARY__: u32 = 0;
|
||||
pub const INT8_MIN: i32 = -128;
|
||||
pub const INT8_MAX: u32 = 127;
|
||||
@@ -5306,10 +5306,6 @@ unsafe extern "C" {
|
||||
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
|
||||
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
|
||||
pub fn _rust_glue_on_create_hook(app: *mut android_app);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
|
||||
pub fn _rust_glue_entry(app: *mut android_app);
|
||||
|
||||
@@ -28,8 +28,8 @@ pub const __ANDROID_API_V__: u32 = 35;
|
||||
pub const __ANDROID_NDK__: u32 = 1;
|
||||
pub const __NDK_MAJOR__: u32 = 29;
|
||||
pub const __NDK_MINOR__: u32 = 0;
|
||||
pub const __NDK_BETA__: u32 = 4;
|
||||
pub const __NDK_BUILD__: u32 = 14033849;
|
||||
pub const __NDK_BETA__: u32 = 0;
|
||||
pub const __NDK_BUILD__: u32 = 14206865;
|
||||
pub const __NDK_CANARY__: u32 = 0;
|
||||
pub const INT8_MIN: i32 = -128;
|
||||
pub const INT8_MAX: u32 = 127;
|
||||
@@ -5335,10 +5335,6 @@ unsafe extern "C" {
|
||||
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
|
||||
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
|
||||
pub fn _rust_glue_on_create_hook(app: *mut android_app);
|
||||
}
|
||||
unsafe extern "C" {
|
||||
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
|
||||
pub fn _rust_glue_entry(app: *mut android_app);
|
||||
|
||||
@@ -1156,13 +1156,6 @@ extern "Rust" {
|
||||
pub fn android_main(app: AndroidApp);
|
||||
}
|
||||
|
||||
// This is called via `GameActivity.onCreate`, from the Java main/UI thread,
|
||||
// before spawning an `android_main` thread.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn _rust_glue_on_create_hook(_game_activity_glue: *mut ffi::android_app) {
|
||||
// Noop currently
|
||||
}
|
||||
|
||||
// This is a spring board between android_native_app_glue and the user's
|
||||
// `android_main` function. This is run on a dedicated thread spawned
|
||||
// by android_native_app_glue.
|
||||
|
||||
Reference in New Issue
Block a user