diff --git a/android/native/jni/android_native_app_glue.c b/android/native/jni/android_native_app_glue.c index 2fa5f0d276..f6ef5578bc 100644 --- a/android/native/jni/android_native_app_glue.c +++ b/android/native/jni/android_native_app_glue.c @@ -22,6 +22,7 @@ #include #include +#include "android-general.h" #include "android_native_app_glue.h" int8_t android_app_read_cmd(struct android_app* android_app) @@ -150,8 +151,10 @@ static void android_app_destroy(struct android_app* android_app) // Can't touch android_app object after this. } -void process_input(struct android_app* app, struct android_poll_source* source) +void process_input(void) { + struct android_app* app = g_android.app; + AInputEvent* event = NULL; if (AInputQueue_getEvent(app->inputQueue, &event) >= 0) @@ -168,8 +171,9 @@ void process_input(struct android_app* app, struct android_poll_source* source) } } -void process_cmd(struct android_app* app, struct android_poll_source* source) +void process_cmd(void) { + struct android_app* app = g_android.app; int8_t cmd = android_app_read_cmd(app); android_app_pre_exec_cmd(app, cmd); @@ -189,12 +193,8 @@ static void* android_app_entry(void* param) print_cur_config(android_app); - android_app->cmdPollSource.id = LOOPER_ID_MAIN; - android_app->cmdPollSource.app = android_app; - android_app->cmdPollSource.process = process_cmd; - android_app->inputPollSource.id = LOOPER_ID_INPUT; - android_app->inputPollSource.app = android_app; - android_app->inputPollSource.process = process_input; + android_app->cmdPollSource = LOOPER_ID_MAIN; + android_app->inputPollSource = LOOPER_ID_INPUT; ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL, diff --git a/android/native/jni/android_native_app_glue.h b/android/native/jni/android_native_app_glue.h index 3d6c4175e8..870fea9dae 100644 --- a/android/native/jni/android_native_app_glue.h +++ b/android/native/jni/android_native_app_glue.h @@ -87,18 +87,6 @@ extern "C" { * Data associated with an ALooper fd that will be returned as the "outData" * when that source has data ready. */ - struct android_poll_source { - // The identifier of this source. May be LOOPER_ID_MAIN or - // LOOPER_ID_INPUT. - int32_t id; - - // The android_app this ident is associated with. - struct android_app* app; - - // Function to call to perform the standard processing of data from - // this source. - void (*process)(struct android_app* app, struct android_poll_source* source); - }; /** * This is the interface for the standard glue code of a threaded @@ -157,8 +145,8 @@ extern "C" { pthread_t thread; - struct android_poll_source cmdPollSource; - struct android_poll_source inputPollSource; + int32_t cmdPollSource; + int32_t inputPollSource; int running; int destroyed; @@ -326,8 +314,8 @@ extern "C" { */ extern void android_main(struct android_app* app); - extern void process_input(struct android_app* app, struct android_poll_source* source); - extern void process_cmd(struct android_app* app, struct android_poll_source* source); + extern void process_input(void); + extern void process_cmd(void); #ifdef __cplusplus } diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index b86cf22578..deaecdc155 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -320,19 +320,16 @@ static void android_input_poll(void *data) (void)data; // Read all pending events. - int event, id; - struct android_poll_source* source; - struct android_app* state = g_android.app; - - id = ALooper_pollOnce(0, NULL, &event, (void**)&source); + int event; + int id = ALooper_pollOnce(0, NULL, &event, NULL); // Process this event. if(event) { if(id == LOOPER_ID_INPUT) - process_input(state, source); + process_input(); else - process_cmd(state, source); + process_cmd(); } } diff --git a/android/native/jni/main.c b/android/native/jni/main.c index f13cc18ff5..9996847be7 100644 --- a/android/native/jni/main.c +++ b/android/native/jni/main.c @@ -149,14 +149,14 @@ void android_main(struct android_app* state) while(!g_android.window_inited) { // Read all pending events. - struct android_poll_source* source; + int id; // Block forever waiting for events. - while ((ALooper_pollOnce(0, NULL, 0, (void**)&source)) >= 0) + while ((id = ALooper_pollOnce(0, NULL, 0, NULL)) >= 0) { // Process this event. - if (source != NULL) - process_cmd(g_android.app, source); + if (id) + process_cmd(); // Check if we are exiting. if (g_android.app->destroyRequested != 0)