* This is the main entry point of a native application that is using * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */
| 1189 | * event loop for receiving input events and doing other things. |
| 1190 | */ |
| 1191 | void android_main(struct android_app* state) { |
| 1192 | |
| 1193 | //init startup time so U32 doesnt overflow |
| 1194 | android_StartupTime(); |
| 1195 | |
| 1196 | // Make sure glue isn't stripped. |
| 1197 | app_dummy(); |
| 1198 | |
| 1199 | platState.engine = &engine; |
| 1200 | |
| 1201 | memset(&engine, 0, sizeof(engine)); |
| 1202 | state->userData = &engine; |
| 1203 | state->onAppCmd = engine_handle_cmd; |
| 1204 | state->onInputEvent = engine_handle_input; |
| 1205 | engine.app = state; |
| 1206 | |
| 1207 | // Prepare to monitor accelerometer |
| 1208 | engine.sensorManager = ASensorManager_getInstance(); |
| 1209 | engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, |
| 1210 | ASENSOR_TYPE_ACCELEROMETER); |
| 1211 | engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager, |
| 1212 | state->looper, LOOPER_ID_USER, NULL, NULL); |
| 1213 | |
| 1214 | |
| 1215 | if (state->savedState != NULL) { |
| 1216 | // We are starting with a previous saved state; restore from it. |
| 1217 | engine.state = *(struct saved_state*)state->savedState; |
| 1218 | } |
| 1219 | |
| 1220 | keepScreenOn(); |
| 1221 | |
| 1222 | //This is to help the debugger catch up. If you dont have this you cant debug this early in the execution |
| 1223 | //so only uncomment when needed as it adds 10 seconds to startup |
| 1224 | //sleep(10); |
| 1225 | |
| 1226 | //store the cache dir |
| 1227 | activity.loadCacheDir(); |
| 1228 | activity.loadInternalDir(); |
| 1229 | |
| 1230 | //enumerate fonts |
| 1231 | activity.enumerateFonts(); |
| 1232 | |
| 1233 | platState.argc = 0; |
| 1234 | |
| 1235 | // loop waiting for stuff to do. |
| 1236 | while (1) { |
| 1237 | // Read all pending events. |
| 1238 | int ident; |
| 1239 | int events; |
| 1240 | struct android_poll_source* source; |
| 1241 | |
| 1242 | // If not animating, we will block forever waiting for events. |
| 1243 | // If animating, we loop until all events are read, then continue |
| 1244 | // to draw the next frame of animation. |
| 1245 | while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events, |
| 1246 | (void**)&source)) >= 0) { |
| 1247 | |
| 1248 | // Process this event. |
no test coverage detected