(Android) Get rid of unused width/height/animated in g_android struct
This commit is contained in:
parent
291280670d
commit
cbcffbb5cf
|
@ -22,9 +22,6 @@ struct droid
|
|||
|
||||
bool init_quit;
|
||||
bool window_inited;
|
||||
unsigned animating;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
struct saved_state state;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,15 +39,15 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd)
|
|||
RARCH_LOG("engine_handle_cmd: APP_CMD_SAVE_STATE.\n");
|
||||
// The system has asked us to save our current state. Do so.
|
||||
g_android.app->savedState = malloc(sizeof(struct saved_state));
|
||||
*((struct saved_state*)g_android.app->savedState) = g_android.state;
|
||||
g_android.app->savedStateSize = sizeof(struct saved_state);
|
||||
break;
|
||||
*((struct saved_state*)g_android.app->savedState) = g_android.state;
|
||||
g_android.app->savedStateSize = sizeof(struct saved_state);
|
||||
break;
|
||||
case APP_CMD_INIT_WINDOW:
|
||||
RARCH_LOG("engine_handle_cmd: APP_CMD_INIT_WINDOW.\n");
|
||||
// The window is being shown, get it ready.
|
||||
if (g_android.app->window != NULL)
|
||||
// The window is being shown, get it ready.
|
||||
if (g_android.app->window != NULL)
|
||||
g_android.window_inited = true;
|
||||
break;
|
||||
break;
|
||||
case APP_CMD_START:
|
||||
RARCH_LOG("engine_handle_cmd: APP_CMD_START.\n");
|
||||
break;
|
||||
|
@ -59,43 +59,40 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd)
|
|||
break;
|
||||
case APP_CMD_PAUSE:
|
||||
RARCH_LOG("engine_handle_cmd: APP_CMD_PAUSE.\n");
|
||||
g_android.init_quit = true;
|
||||
g_android.init_quit = true;
|
||||
break;
|
||||
case APP_CMD_TERM_WINDOW:
|
||||
RARCH_LOG("engine_handle_cmd: APP_CMD_TERM_WINDOW.\n");
|
||||
// The window is being hidden or closed, clean it up.
|
||||
break;
|
||||
// The window is being hidden or closed, clean it up.
|
||||
break;
|
||||
case APP_CMD_GAINED_FOCUS:
|
||||
RARCH_LOG("engine_handle_cmd: APP_CMD_GAINED_FOCUS.\n");
|
||||
// When our app gains focus, we start monitoring the accelerometer.
|
||||
// When our app gains focus, we start monitoring the accelerometer.
|
||||
#if 0
|
||||
if (g_android.accelerometerSensor != NULL)
|
||||
if (g_android.accelerometerSensor != NULL)
|
||||
{
|
||||
ASensorEventQueue_enableSensor(g_android.sensorEventQueue,
|
||||
g_android.accelerometerSensor);
|
||||
g_android.accelerometerSensor);
|
||||
|
||||
// We'd like to get 60 events per second (in us).
|
||||
ASensorEventQueue_setEventRate(g_android.sensorEventQueue,
|
||||
g_android.accelerometerSensor, (1000L/60)*1000);
|
||||
}
|
||||
// We'd like to get 60 events per second (in us).
|
||||
ASensorEventQueue_setEventRate(g_android.sensorEventQueue,
|
||||
g_android.accelerometerSensor, (1000L/60)*1000);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
case APP_CMD_LOST_FOCUS:
|
||||
RARCH_LOG("engine_handle_cmd: APP_CMD_LOST_FOCUS.\n");
|
||||
// When our app loses focus, we stop monitoring the accelerometer.
|
||||
// This is to avoid consuming battery while not being used.
|
||||
if (!g_android.window_inited)
|
||||
// When our app loses focus, we stop monitoring the accelerometer.
|
||||
// This is to avoid consuming battery while not being used.
|
||||
if (!g_android.window_inited)
|
||||
{
|
||||
#if 0
|
||||
if (g_android.accelerometerSensor != NULL)
|
||||
ASensorEventQueue_disableSensor(g_android.sensorEventQueue,
|
||||
g_android.accelerometerSensor);
|
||||
g_android.accelerometerSensor);
|
||||
#endif
|
||||
|
||||
// Also stop animating.
|
||||
g_android.animating = 0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,45 +175,28 @@ void android_main(struct android_app* state)
|
|||
argv[argc++] = strdup(libretro_path);
|
||||
argv[argc++] = strdup("-v");
|
||||
|
||||
g_android.animating = 1;
|
||||
|
||||
g_extern.verbose = true;
|
||||
|
||||
while(!g_android.window_inited)
|
||||
{
|
||||
// Read all pending events.
|
||||
int ident;
|
||||
int events;
|
||||
struct 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
|
||||
// to draw the next frame of animation.
|
||||
while ((ident=ALooper_pollAll(g_android.animating ? 0 : -1, NULL, &events,
|
||||
(void**)&source)) >= 0)
|
||||
// Block forever waiting for events.
|
||||
while ((ident=ALooper_pollAll(0, NULL, 0, (void**)&source)) >= 0)
|
||||
{
|
||||
// Process this event.
|
||||
if (source != NULL)
|
||||
source->process(g_android.app, source);
|
||||
|
||||
// If a sensor has data, process it now.
|
||||
if (ident == LOOPER_ID_USER && g_android.accelerometerSensor != NULL)
|
||||
{
|
||||
ASensorEvent event;
|
||||
while (ASensorEventQueue_getEvents(g_android.sensorEventQueue, &event, 1) > 0)
|
||||
{
|
||||
//RARCH_LOG("accelerometer: x=%f y=%f z=%f.\n", event.acceleration.x,
|
||||
//event.acceleration.y, event.acceleration.z);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we are exiting.
|
||||
if (g_android.app->destroyRequested != 0)
|
||||
return;
|
||||
// Check if we are exiting.
|
||||
if (g_android.app->destroyRequested != 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RARCH_LOG("Start RetroArch...\n");
|
||||
RARCH_LOG("Starting RetroArch...\n");
|
||||
|
||||
rarch_main(argc, argv);
|
||||
exit(0);
|
||||
|
|
|
@ -57,22 +57,18 @@ static void gfx_ctx_destroy(void)
|
|||
g_egl_surf = EGL_NO_SURFACE;
|
||||
g_egl_ctx = EGL_NO_CONTEXT;
|
||||
g_config = 0;
|
||||
|
||||
g_android.width = 0;
|
||||
g_android.height = 0;
|
||||
g_android.animating = 0;
|
||||
}
|
||||
|
||||
static bool gfx_ctx_init(void)
|
||||
{
|
||||
RARCH_LOG("gfx_ctx_init().\n");
|
||||
const EGLint attribs[] = {
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_NONE
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLConfig config;
|
||||
EGLint num_config;
|
||||
|
@ -88,7 +84,7 @@ static bool gfx_ctx_init(void)
|
|||
};
|
||||
|
||||
RARCH_LOG("Initializing context\n");
|
||||
|
||||
|
||||
if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
|
||||
goto error;
|
||||
|
||||
|
@ -115,11 +111,9 @@ static bool gfx_ctx_init(void)
|
|||
goto error;
|
||||
|
||||
if (!eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &width) ||
|
||||
!eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &height))
|
||||
!eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &height))
|
||||
goto error;
|
||||
|
||||
g_android.width = width;
|
||||
g_android.height = height;
|
||||
g_android.state.angle = 0;
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue