| 264 | } |
| 265 | |
| 266 | void android_main(struct android_app *app) |
| 267 | { |
| 268 | g_App = app; |
| 269 | bindImageTextureFunctions(); |
| 270 | bindBackendFunctions(); |
| 271 | |
| 272 | std::string path = getAppFilesDir(app); |
| 273 | android_plugins_dir = getPluginsDir(app); |
| 274 | chdir(path.c_str()); |
| 275 | |
| 276 | app->onAppCmd = handleAppCmd; |
| 277 | app->onInputEvent = handleInputEvent; |
| 278 | |
| 279 | while (true) |
| 280 | { |
| 281 | int out_events; |
| 282 | struct android_poll_source *out_data; |
| 283 | |
| 284 | // Poll all events. If the app is not visible, this loop blocks until g_Initialized == true. |
| 285 | while (ALooper_pollAll(g_Initialized ? 0 : -1, NULL, &out_events, (void **)&out_data) >= 0) |
| 286 | { |
| 287 | // Process one event |
| 288 | if (out_data != NULL) |
| 289 | out_data->process(app, out_data); |
| 290 | |
| 291 | // Exit the app by returning from within the infinite loop |
| 292 | if (app->destroyRequested != 0) |
| 293 | { |
| 294 | // shutdown() should have been called already while processing the |
| 295 | // app command APP_CMD_TERM_WINDOW. But we play save here |
| 296 | if (!g_Initialized) |
| 297 | shutdown(); |
| 298 | |
| 299 | return; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | // Initiate a new frame |
| 304 | tick(); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | // Unfortunately, there is no way to show the on-screen input from native code. |
| 309 | // Therefore, we call ShowSoftKeyboardInput() of the main activity implemented in MainActivity.kt via JNI. |
nothing calls this directly
no test coverage detected