diff --git a/native-activity/app/src/main/cpp/main.cpp b/native-activity/app/src/main/cpp/main.cpp index 2f82d570d..dd774849f 100644 --- a/native-activity/app/src/main/cpp/main.cpp +++ b/native-activity/app/src/main/cpp/main.cpp @@ -77,7 +77,7 @@ struct SavedState { * Shared state for our app. */ struct Engine { - struct android_app* app; + android_app* app; ASensorManager* sensorManager; const ASensor* accelerometerSensor; @@ -89,7 +89,7 @@ struct Engine { EGLContext context; int32_t width; int32_t height; - struct SavedState state; + SavedState state; void CreateSensorListener(ALooper_callbackFunc callback) { CHECK_NOT_NULL(app); @@ -109,7 +109,7 @@ struct Engine { /** * Initialize an EGL context for the current display. */ -static int engine_init_display(struct Engine* engine) { +static int engine_init_display(Engine* engine) { // initialize OpenGL ES and EGL /* @@ -209,7 +209,7 @@ static int engine_init_display(struct Engine* engine) { /** * Just the current frame in the display. */ -static void engine_draw_frame(struct Engine* engine) { +static void engine_draw_frame(Engine* engine) { if (engine->display == nullptr) { // No display. return; @@ -226,7 +226,7 @@ static void engine_draw_frame(struct Engine* engine) { /** * Tear down the EGL context currently associated with the display. */ -static void engine_term_display(struct Engine* engine) { +static void engine_term_display(Engine* engine) { if (engine->display != EGL_NO_DISPLAY) { eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -247,9 +247,9 @@ static void engine_term_display(struct Engine* engine) { /** * Process the next input event. */ -static int32_t engine_handle_input(struct android_app* app, +static int32_t engine_handle_input(android_app* app, AInputEvent* event) { - auto* engine = (struct Engine*)app->userData; + auto* engine = (Engine*)app->userData; if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) { engine->animating = 1; engine->state.x = AMotionEvent_getX(event, 0); @@ -262,14 +262,14 @@ static int32_t engine_handle_input(struct android_app* app, /** * Process the next main command. */ -static void engine_handle_cmd(struct android_app* app, int32_t cmd) { - auto* engine = (struct Engine*)app->userData; +static void engine_handle_cmd(android_app* app, int32_t cmd) { + auto* engine = (Engine*)app->userData; switch (cmd) { case APP_CMD_SAVE_STATE: // The system has asked us to save our current state. Do so. - engine->app->savedState = malloc(sizeof(struct SavedState)); - *((struct SavedState*)engine->app->savedState) = engine->state; - engine->app->savedStateSize = sizeof(struct SavedState); + engine->app->savedState = malloc(sizeof(SavedState)); + *((SavedState*)engine->app->savedState) = engine->state; + engine->app->savedStateSize = sizeof(SavedState); break; case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. @@ -311,7 +311,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) { int OnSensorEvent(int /* fd */, int /* events */, void* data) { CHECK_NOT_NULL(data); - Engine* engine = reinterpret_cast(data); + Engine* engine = reinterpret_cast(data); CHECK_NOT_NULL(engine->accelerometerSensor); ASensorEvent event; @@ -332,8 +332,8 @@ int OnSensorEvent(int /* fd */, int /* events */, void* data) { * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */ -void android_main(struct android_app* state) { - struct Engine engine {}; +void android_main(android_app* state) { + Engine engine {}; memset(&engine, 0, sizeof(engine)); state->userData = &engine; @@ -346,7 +346,7 @@ void android_main(struct android_app* state) { if (state->savedState != nullptr) { // We are starting with a previous saved state; restore from it. - engine.state = *(struct SavedState*)state->savedState; + engine.state = *(SavedState*)state->savedState; } // loop waiting for stuff to do. @@ -354,7 +354,7 @@ void android_main(struct android_app* state) { while (true) { // Read all pending events. int events; - struct android_poll_source* source; + android_poll_source* source; // If not animating, we will block forever waiting for events. // If animating, we loop until all events are read, then continue