Refactor MODE_MENU_PREINIT code

This commit is contained in:
twinaphex 2014-09-21 06:33:49 +02:00
parent 213bb63a12
commit 9dc35b056f
4 changed files with 35 additions and 52 deletions

View File

@ -55,8 +55,6 @@
#define MAX_ARGS 32 #define MAX_ARGS 32
static retro_keyboard_event_t key_event;
static int main_entry_iterate_shutdown(signature(), args_type() args) static int main_entry_iterate_shutdown(signature(), args_type() args)
{ {
(void)args; (void)args;
@ -81,8 +79,6 @@ int main_entry_decide(signature(), args_type() args)
return main_entry_iterate_load_content(signature_expand(), args); return main_entry_iterate_load_content(signature_expand(), args);
if (g_extern.lifecycle_state & (1ULL << MODE_GAME)) if (g_extern.lifecycle_state & (1ULL << MODE_GAME))
return main_entry_iterate_content(signature_expand(), args); return main_entry_iterate_content(signature_expand(), args);
if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT))
return main_entry_iterate_menu_preinit(signature_expand(), args);
if (g_extern.lifecycle_state & (1ULL << MODE_MENU)) if (g_extern.lifecycle_state & (1ULL << MODE_MENU))
return main_entry_iterate_menu(signature_expand(), args); return main_entry_iterate_menu(signature_expand(), args);
@ -127,7 +123,7 @@ int main_entry_iterate_clear_input(signature(), args_type() args)
#endif #endif
/* Restore libretro keyboard callback. */ /* Restore libretro keyboard callback. */
g_extern.system.key_event = key_event; g_extern.system.key_event = g_extern.frontend_key_event;
rarch_main_set_state(RARCH_ACTION_STATE_FLUSH_INPUT_FINISHED); rarch_main_set_state(RARCH_ACTION_STATE_FLUSH_INPUT_FINISHED);
return 0; return 0;
@ -151,39 +147,6 @@ int main_entry_iterate_load_content(signature(), args_type() args)
} }
#ifdef HAVE_MENU #ifdef HAVE_MENU
int main_entry_iterate_menu_preinit(signature(), args_type() args)
{
int i;
/* Menu should always run with vsync on. */
rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE);
/* Stop all rumbling before entering the menu. */
for (i = 0; i < MAX_PLAYERS; i++)
{
driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0);
driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0);
}
rarch_main_command(RARCH_CMD_AUDIO_STOP);
if (driver.menu)
{
/* Override keyboard callback to redirect to menu instead.
* We'll use this later for something ...
* FIXME: This should probably be moved to menu_common somehow. */
key_event = g_extern.system.key_event;
g_extern.system.key_event = menu_key_event;
driver.menu->need_refresh = true;
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT_FINISHED);
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
}
return 0;
}
int main_entry_iterate_menu(signature(), args_type() args) int main_entry_iterate_menu(signature(), args_type() args)
{ {
retro_input_t input, old_state = 0; retro_input_t input, old_state = 0;

View File

@ -311,13 +311,6 @@ bool menu_iterate(void)
if (!driver.menu) if (!driver.menu)
return false; return false;
if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT))
{
driver.menu->need_refresh = true;
rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT_FINISHED);
}
rarch_input_poll(); rarch_input_poll();
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY, retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY,

View File

@ -137,7 +137,6 @@ enum action_state
{ {
RARCH_ACTION_STATE_NONE = 0, RARCH_ACTION_STATE_NONE = 0,
RARCH_ACTION_STATE_MENU_PREINIT, RARCH_ACTION_STATE_MENU_PREINIT,
RARCH_ACTION_STATE_MENU_PREINIT_FINISHED,
RARCH_ACTION_STATE_LOAD_CONTENT, RARCH_ACTION_STATE_LOAD_CONTENT,
RARCH_ACTION_STATE_LOAD_CONTENT_FINISHED, RARCH_ACTION_STATE_LOAD_CONTENT_FINISHED,
RARCH_ACTION_STATE_RUNNING, RARCH_ACTION_STATE_RUNNING,
@ -158,7 +157,6 @@ enum menu_enums
MODE_MENU, MODE_MENU,
MODE_MENU_WIDESCREEN, MODE_MENU_WIDESCREEN,
MODE_MENU_HD, MODE_MENU_HD,
MODE_MENU_PREINIT,
MODE_EXTLAUNCH_MULTIMAN, MODE_EXTLAUNCH_MULTIMAN,
MODE_EXITSPAWN, MODE_EXITSPAWN,
MODE_EXITSPAWN_START_GAME, MODE_EXITSPAWN_START_GAME,
@ -762,6 +760,8 @@ struct global
/* Config file associated with per-core configs. */ /* Config file associated with per-core configs. */
char core_specific_config_path[PATH_MAX]; char core_specific_config_path[PATH_MAX];
retro_keyboard_event_t frontend_key_event;
}; };
struct rarch_main_wrap struct rarch_main_wrap

View File

@ -43,6 +43,7 @@
#ifdef HAVE_MENU #ifdef HAVE_MENU
#include "frontend/menu/menu_common.h" #include "frontend/menu/menu_common.h"
#include "frontend/menu/menu_input_line_cb.h"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -3176,11 +3177,37 @@ void rarch_main_set_state(unsigned cmd)
switch (cmd) switch (cmd)
{ {
case RARCH_ACTION_STATE_MENU_PREINIT: case RARCH_ACTION_STATE_MENU_PREINIT:
g_extern.lifecycle_state |= (1ULL << MODE_MENU_PREINIT); {
g_extern.system.frame_time_last = 0; int i;
break;
case RARCH_ACTION_STATE_MENU_PREINIT_FINISHED: /* Menu should always run with vsync on. */
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_PREINIT); rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE);
/* Stop all rumbling before entering the menu. */
for (i = 0; i < MAX_PLAYERS; i++)
{
driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0);
driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0);
}
rarch_main_command(RARCH_CMD_AUDIO_STOP);
#ifdef HAVE_MENU
if (driver.menu)
{
/* Override keyboard callback to redirect to menu instead.
* We'll use this later for something ...
* FIXME: This should probably be moved to menu_common somehow. */
g_extern.frontend_key_event = g_extern.system.key_event;
g_extern.system.key_event = menu_key_event;
driver.menu->need_refresh = true;
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
}
#endif
g_extern.system.frame_time_last = 0;
}
break; break;
case RARCH_ACTION_STATE_LOAD_CONTENT: case RARCH_ACTION_STATE_LOAD_CONTENT:
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME); g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);