mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 16:39:43 +00:00
Reimplement rarch_main_iterate - menu iteration frame now gets
called from here too. Do away with the hoky 'MENU_GAME' state as well.
This commit is contained in:
parent
ff9a16d407
commit
430e0f1911
@ -591,6 +591,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
case RETRO_ENVIRONMENT_SHUTDOWN:
|
||||
RARCH_LOG("Environ SHUTDOWN.\n");
|
||||
g_extern.system.shutdown = true;
|
||||
g_extern.core_shutdown_initiated = true;
|
||||
break;
|
||||
|
||||
case RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL:
|
||||
|
@ -55,64 +55,33 @@
|
||||
|
||||
#define MAX_ARGS 32
|
||||
|
||||
static int main_entry_iterate_shutdown(signature(), args_type() args)
|
||||
static int main_entry_iterate_shutdown(signature(),
|
||||
args_type() args)
|
||||
{
|
||||
(void)args;
|
||||
|
||||
if (!g_settings.load_dummy_on_core_shutdown)
|
||||
return 1;
|
||||
if (g_extern.core_shutdown_initiated
|
||||
&& g_settings.load_dummy_on_core_shutdown)
|
||||
{
|
||||
/* Load dummy core instead of exiting RetroArch completely. */
|
||||
rarch_main_command(RARCH_CMD_PREPARE_DUMMY);
|
||||
g_extern.core_shutdown_initiated = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load dummy core instead of exiting RetroArch completely. */
|
||||
rarch_main_command(RARCH_CMD_PREPARE_DUMMY);
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main_entry_decide(signature(), args_type() args)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
int ret = 1;
|
||||
if (g_extern.system.shutdown)
|
||||
ret = main_entry_iterate_shutdown(signature_expand(), args);
|
||||
else if (g_extern.lifecycle_state & (1ULL << MODE_MENU))
|
||||
{
|
||||
retro_input_t input, old_state = 0;
|
||||
|
||||
if (!menu_iterate())
|
||||
{
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
driver_set_nonblock_state(driver.nonblock_state);
|
||||
|
||||
rarch_main_command(RARCH_CMD_AUDIO_START);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_FLUSH_INPUT);
|
||||
|
||||
input = input_keys_pressed_func(RARCH_QUIT_KEY, RARCH_QUIT_KEY + 1,
|
||||
&old_state);
|
||||
|
||||
if (BIND_PRESSED(input, RARCH_QUIT_KEY) ||
|
||||
!driver.video->alive(driver.video_data))
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
else if (g_extern.lifecycle_state & (1ULL << MODE_GAME))
|
||||
{
|
||||
if (!rarch_main_iterate())
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
|
||||
ret = 0;
|
||||
}
|
||||
int ret = 0;
|
||||
if (!rarch_main_iterate())
|
||||
return main_entry_iterate_shutdown(signature_expand(), args);
|
||||
|
||||
if (driver.frontend_ctx && driver.frontend_ctx->process_events)
|
||||
driver.frontend_ctx->process_events(args);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
if (!rarch_main_iterate())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void main_exit(args_type() args)
|
||||
|
@ -1870,13 +1870,6 @@ static int menu_common_iterate(unsigned action)
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
|
||||
driver.menu_ctx->set_texture(driver.menu);
|
||||
|
||||
if (action == MENU_ACTION_TOGGLE &&
|
||||
g_extern.main_is_init && !g_extern.libretro_dummy)
|
||||
{
|
||||
rarch_main_command(RARCH_CMD_RESUME);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcmp(menu_label, "help"))
|
||||
return menu_start_screen_iterate(action);
|
||||
else if (!strcmp(menu_label, "info_screen"))
|
||||
|
@ -515,7 +515,7 @@ static int menu_lakka_iterate(unsigned action)
|
||||
(active_category->num_items - 1))))
|
||||
{
|
||||
add_tween(LAKKA_DELAY, 1.0, &global_alpha, &inOutQuad, NULL);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
|
||||
rarch_main_command(RARCH_CMD_QUIT_RETROARCH);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -162,9 +162,6 @@ static void glui_frame(void)
|
||||
if (!driver.menu || !gl)
|
||||
return;
|
||||
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_GAME))
|
||||
return;
|
||||
|
||||
line_height = g_settings.video.font_size * 4 / 3;
|
||||
glyph_width = line_height / 2;
|
||||
glui_margin = gl->win_width / 20 ;
|
||||
|
@ -299,9 +299,10 @@ static unsigned input_frame(uint64_t trigger_state)
|
||||
return MENU_ACTION_NOOP;
|
||||
}
|
||||
|
||||
bool menu_iterate(void)
|
||||
bool menu_iterate(retro_input_t input,
|
||||
retro_input_t old_input, retro_input_t trigger_input)
|
||||
{
|
||||
retro_input_t old_state = 0, trigger_input = 0;
|
||||
retro_input_t old_state = 0;
|
||||
unsigned action = MENU_ACTION_NOOP;
|
||||
static bool initial_held = true;
|
||||
static bool first_held = false;
|
||||
@ -311,24 +312,20 @@ bool menu_iterate(void)
|
||||
if (!driver.menu)
|
||||
return false;
|
||||
|
||||
rarch_input_poll();
|
||||
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY,
|
||||
RARCH_BIND_LIST_END, &old_state);
|
||||
|
||||
trigger_input = input & ~old_state;
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (BIND_PRESSED(trigger_input, RARCH_OVERLAY_NEXT))
|
||||
input_overlay_next(driver.overlay);
|
||||
#endif
|
||||
check_fullscreen_func(trigger_input);
|
||||
|
||||
if (check_quit_key_func(input) || !driver.video->alive(driver.video_data))
|
||||
if (check_enter_menu_func(trigger_input) &&
|
||||
g_extern.main_is_init && !g_extern.libretro_dummy)
|
||||
{
|
||||
rarch_main_command(RARCH_CMD_RESUME);
|
||||
return false;
|
||||
}
|
||||
|
||||
rarch_input_poll();
|
||||
input_state = menu_input();
|
||||
|
||||
if (driver.menu->do_held)
|
||||
|
@ -131,7 +131,7 @@ typedef enum
|
||||
|
||||
void *menu_init(const void *data);
|
||||
|
||||
bool menu_iterate(void);
|
||||
bool menu_iterate(retro_input_t input, retro_input_t old_input, retro_input_t trigger_input);
|
||||
|
||||
void menu_free(void *data);
|
||||
|
||||
|
@ -138,8 +138,6 @@ enum action_state
|
||||
RARCH_ACTION_STATE_NONE = 0,
|
||||
RARCH_ACTION_STATE_MENU_PREINIT,
|
||||
RARCH_ACTION_STATE_LOAD_CONTENT,
|
||||
RARCH_ACTION_STATE_RUNNING,
|
||||
RARCH_ACTION_STATE_RUNNING_FINISHED,
|
||||
RARCH_ACTION_STATE_MENU_RUNNING,
|
||||
RARCH_ACTION_STATE_MENU_RUNNING_FINISHED,
|
||||
RARCH_ACTION_STATE_EXITSPAWN,
|
||||
@ -150,7 +148,7 @@ enum action_state
|
||||
|
||||
enum menu_enums
|
||||
{
|
||||
MODE_GAME = 0,
|
||||
MODE_NONE = 0,
|
||||
MODE_MENU,
|
||||
MODE_MENU_WIDESCREEN,
|
||||
MODE_MENU_HD,
|
||||
@ -431,6 +429,7 @@ struct global
|
||||
bool location_active;
|
||||
bool osk_active;
|
||||
bool force_fullscreen;
|
||||
bool core_shutdown_initiated;
|
||||
|
||||
struct string_list *temporary_content;
|
||||
|
||||
|
38
retroarch.c
38
retroarch.c
@ -3214,18 +3214,11 @@ void rarch_main_set_state(unsigned cmd)
|
||||
if (!load_menu_content())
|
||||
{
|
||||
/* If content loading fails, we go back to menu. */
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
|
||||
if (driver.menu)
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case RARCH_ACTION_STATE_RUNNING:
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_GAME);
|
||||
break;
|
||||
case RARCH_ACTION_STATE_RUNNING_FINISHED:
|
||||
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
|
||||
break;
|
||||
case RARCH_ACTION_STATE_MENU_RUNNING:
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_MENU);
|
||||
break;
|
||||
@ -3236,8 +3229,8 @@ void rarch_main_set_state(unsigned cmd)
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_EXITSPAWN);
|
||||
break;
|
||||
case RARCH_ACTION_STATE_QUIT:
|
||||
g_extern.system.shutdown = true;
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
|
||||
break;
|
||||
case RARCH_ACTION_STATE_FORCE_QUIT:
|
||||
g_extern.lifecycle_state = 0;
|
||||
@ -3295,7 +3288,6 @@ void rarch_main_command(unsigned cmd)
|
||||
return;
|
||||
#endif
|
||||
main_state(cmd);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING);
|
||||
break;
|
||||
case RARCH_CMD_RESET:
|
||||
RARCH_LOG(RETRO_LOG_RESETTING_CONTENT);
|
||||
@ -3305,14 +3297,12 @@ void rarch_main_command(unsigned cmd)
|
||||
/* bSNES since v073r01 resets controllers to JOYPAD
|
||||
* after a reset, so just enforce it here. */
|
||||
init_controllers();
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING);
|
||||
break;
|
||||
case RARCH_CMD_SAVE_STATE:
|
||||
if (g_settings.savestate_auto_index)
|
||||
g_settings.state_slot++;
|
||||
|
||||
main_state(cmd);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING);
|
||||
break;
|
||||
case RARCH_CMD_TAKE_SCREENSHOT:
|
||||
take_screenshot();
|
||||
@ -3480,7 +3470,6 @@ void rarch_main_command(unsigned cmd)
|
||||
#ifdef HAVE_MENU
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
#endif
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING);
|
||||
break;
|
||||
case RARCH_CMD_RESTART_RETROARCH:
|
||||
#if defined(GEKKO) && defined(HW_RVL)
|
||||
@ -3488,7 +3477,6 @@ void rarch_main_command(unsigned cmd)
|
||||
SALAMANDER_FILE,
|
||||
sizeof(g_extern.fullpath));
|
||||
#endif
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_EXITSPAWN);
|
||||
break;
|
||||
case RARCH_CMD_MENU_SAVE_CONFIG:
|
||||
@ -3625,19 +3613,31 @@ bool rarch_main_iterate(void)
|
||||
|
||||
trigger_input = input & ~old_input;
|
||||
|
||||
/* SHUTDOWN on consoles should exit RetroArch completely. */
|
||||
if (g_extern.system.shutdown)
|
||||
/* Time to drop? */
|
||||
if (
|
||||
g_extern.system.shutdown ||
|
||||
check_quit_key_func(input) ||
|
||||
!driver.video->alive(driver.video_data))
|
||||
return false;
|
||||
|
||||
/* Time to drop? */
|
||||
if (check_quit_key_func(input) || !driver.video->alive(driver.video_data))
|
||||
return false;
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_MENU))
|
||||
{
|
||||
if (!menu_iterate(input, old_input, trigger_input))
|
||||
{
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
driver_set_nonblock_state(driver.nonblock_state);
|
||||
|
||||
rarch_main_command(RARCH_CMD_AUDIO_START);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_FLUSH_INPUT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (check_enter_menu_func(trigger_input) || (g_extern.libretro_dummy))
|
||||
{
|
||||
/* Always go into menu if dummy core is loaded. */
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT);
|
||||
return false; /* Enter menu, don't exit. */
|
||||
return true; /* Enter menu on next run. */
|
||||
}
|
||||
|
||||
if (g_extern.exec)
|
||||
|
Loading…
Reference in New Issue
Block a user