(Frontend) Go through frontend_loop function pointer

This commit is contained in:
twinaphex 2014-09-05 16:08:03 +02:00
parent f495170f3a
commit 1426e705c9
4 changed files with 60 additions and 39 deletions

View File

@ -69,10 +69,26 @@
#define MAX_ARGS 32
int (*frontend_loop)(args_type() args);
static retro_keyboard_event_t key_event;
int main_entry_iterate_content(args_type() args)
{
if (!rarch_main_iterate())
{
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
return 0;
}
if (driver.frontend_ctx && driver.frontend_ctx->process_events)
driver.frontend_ctx->process_events(args);
return 0;
}
#ifdef HAVE_MENU
static int main_entry_iterate_clear_input(args_type() args)
int main_entry_iterate_clear_input(args_type() args)
{
(void)args;
@ -102,21 +118,8 @@ static int main_entry_iterate_shutdown(args_type() args)
return 0;
}
static int main_entry_iterate_content(args_type() args)
{
if (!rarch_main_iterate())
{
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
return 0;
}
if (driver.frontend_ctx && driver.frontend_ctx->process_events)
driver.frontend_ctx->process_events(args);
return 0;
}
static int main_entry_iterate_load_content(args_type() args)
int main_entry_iterate_load_content(args_type() args)
{
if (!load_menu_content())
{
@ -131,7 +134,7 @@ static int main_entry_iterate_load_content(args_type() args)
return 0;
}
static int main_entry_iterate_menu_preinit(args_type() args)
int main_entry_iterate_menu_preinit(args_type() args)
{
int i;
@ -164,7 +167,7 @@ static int main_entry_iterate_menu_preinit(args_type() args)
return 0;
}
static int main_entry_iterate_menu(args_type() args)
int main_entry_iterate_menu(args_type() args)
{
if (menu_iterate())
{
@ -190,18 +193,9 @@ int main_entry_iterate(signature(), args_type() args)
{
if (g_extern.system.shutdown)
return main_entry_iterate_shutdown(args);
if (g_extern.lifecycle_state & (1ULL << MODE_CLEAR_INPUT))
return main_entry_iterate_clear_input(args);
if (g_extern.lifecycle_state & (1ULL << MODE_LOAD_GAME))
return main_entry_iterate_load_content(args);
if (g_extern.lifecycle_state & (1ULL << MODE_GAME))
return main_entry_iterate_content(args);
#ifdef HAVE_MENU
if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT))
return main_entry_iterate_menu_preinit(args);
if (g_extern.lifecycle_state & (1ULL << MODE_MENU))
return main_entry_iterate_menu(args);
#endif
if (frontend_loop)
return frontend_loop(args);
return 1;
}
#endif

View File

@ -23,16 +23,6 @@
#include "../boolean.h"
#include "frontend_context.h"
#if defined(ANDROID)
#define args_type() struct android_app*
#define signature() void* data
#define returntype void
#else
#define args_type() void*
#define signature() int argc, char *argv[]
#define returntype int
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -24,6 +24,16 @@
#include "../config.h"
#endif
#if defined(ANDROID)
#define args_type() struct android_app*
#define signature() void* data
#define returntype void
#else
#define args_type() void*
#define signature() int argc, char *argv[]
#define returntype int
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -61,6 +71,17 @@ extern const frontend_ctx_driver_t frontend_ctx_null;
const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize.
const frontend_ctx_driver_t *frontend_ctx_init_first(void); // Finds first suitable driver and initializes.
#ifdef HAVE_MENU
int main_entry_iterate_content(args_type() args);
int main_entry_iterate_menu_preinit(args_type() args);
int main_entry_iterate_menu(args_type() args);
int main_entry_iterate_clear_input(args_type() args);
int main_entry_iterate_load_content(args_type() args);
#endif
extern int (*frontend_loop)(args_type() args);
#ifdef __cplusplus
}
#endif

View File

@ -3303,6 +3303,9 @@ static inline void limit_frame_time(void)
void rarch_main_set_state(unsigned cmd)
{
frontend_loop = NULL;
switch (cmd)
{
case RARCH_ACTION_STATE_MENU_PREINIT:
@ -3346,6 +3349,19 @@ void rarch_main_set_state(unsigned cmd)
default:
break;
}
if (g_extern.lifecycle_state & (1ULL << MODE_CLEAR_INPUT))
frontend_loop = main_entry_iterate_clear_input;
else if (g_extern.lifecycle_state & (1ULL << MODE_LOAD_GAME))
frontend_loop = main_entry_iterate_load_content;
else if (g_extern.lifecycle_state & (1ULL << MODE_GAME))
frontend_loop = main_entry_iterate_content;
#ifdef HAVE_MENU
else if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT))
frontend_loop = main_entry_iterate_menu_preinit;
else if (g_extern.lifecycle_state & (1ULL << MODE_MENU))
frontend_loop = main_entry_iterate_menu;
#endif
}
void rarch_main_command(unsigned cmd)