Create rarch_main_command - command.c could maybe later be made

more generic so we can just do this through command.c functions
locally
This commit is contained in:
twinaphex 2014-07-22 02:14:52 +02:00
parent 2629eb5a8c
commit 4b0f3584e0
5 changed files with 37 additions and 13 deletions

View File

@ -19,14 +19,7 @@
#include <stdint.h> #include <stdint.h>
enum basic_event_t {
RESET = 1,
LOAD_STATE = 2,
SAVE_STATE = 3,
QUIT = 4
};
extern void apple_event_basic_command(enum basic_event_t action); extern void apple_event_basic_command(enum basic_event_t action);
extern void apple_refresh_config(void); extern void apple_refresh_config(void);
#endif #endif

View File

@ -3796,7 +3796,7 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
if (action == MENU_ACTION_OK) if (action == MENU_ACTION_OK)
{ {
if (setting == MENU_SETTINGS_SAVESTATE_SAVE) if (setting == MENU_SETTINGS_SAVESTATE_SAVE)
rarch_save_state(); rarch_main_command(RARCH_CMD_SAVE_STATE);
else else
{ {
// Disallow savestate load when we absolutely cannot change game state. // Disallow savestate load when we absolutely cannot change game state.
@ -3808,7 +3808,7 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
if (g_extern.netplay) if (g_extern.netplay)
break; break;
#endif #endif
rarch_load_state(); rarch_main_command(RARCH_CMD_LOAD_STATE);
} }
g_extern.lifecycle_state |= (1ULL << MODE_GAME); g_extern.lifecycle_state |= (1ULL << MODE_GAME);
return -1; return -1;
@ -3833,7 +3833,7 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
case MENU_SETTINGS_RESTART_GAME: case MENU_SETTINGS_RESTART_GAME:
if (action == MENU_ACTION_OK) if (action == MENU_ACTION_OK)
{ {
rarch_game_reset(); rarch_main_command(RARCH_CMD_RESET);
g_extern.lifecycle_state |= (1ULL << MODE_GAME); g_extern.lifecycle_state |= (1ULL << MODE_GAME);
return -1; return -1;
} }

View File

@ -357,13 +357,13 @@ static int menu_lakka_iterate(unsigned action)
break; break;
case 1: case 1:
global_alpha = 0.0; global_alpha = 0.0;
rarch_save_state(); rarch_main_command(RARCH_CMD_SAVE_STATE);
g_extern.lifecycle_state |= (1ULL << MODE_GAME); g_extern.lifecycle_state |= (1ULL << MODE_GAME);
return -1; return -1;
break; break;
case 2: case 2:
global_alpha = 0.0; global_alpha = 0.0;
rarch_load_state(); rarch_main_command(RARCH_CMD_LOAD_STATE);
g_extern.lifecycle_state |= (1ULL << MODE_GAME); g_extern.lifecycle_state |= (1ULL << MODE_GAME);
return -1; return -1;
break; break;
@ -372,7 +372,7 @@ static int menu_lakka_iterate(unsigned action)
break; break;
case 4: case 4:
global_alpha = 0.0; global_alpha = 0.0;
rarch_game_reset(); rarch_main_command(RARCH_CMD_RESET);
g_extern.lifecycle_state |= (1ULL << MODE_GAME); g_extern.lifecycle_state |= (1ULL << MODE_GAME);
return -1; return -1;
break; break;

View File

@ -87,6 +87,14 @@ extern "C" {
#define MAX_PLAYERS 8 #define MAX_PLAYERS 8
enum basic_event
{
RARCH_CMD_RESET = 1,
RARCH_CMD_LOAD_STATE,
RARCH_CMD_SAVE_STATE,
RARCH_CMD_QUIT
};
enum menu_enums enum menu_enums
{ {
MODE_GAME = 0, MODE_GAME = 0,
@ -756,6 +764,7 @@ void rarch_main_init_wrap(const struct rarch_main_wrap *args, int *argc, char **
int rarch_main_init(int argc, char *argv[]); int rarch_main_init(int argc, char *argv[]);
bool rarch_main_idle_iterate(void); bool rarch_main_idle_iterate(void);
void rarch_main_command(unsigned action);
bool rarch_main_iterate(void); bool rarch_main_iterate(void);
void rarch_main_deinit(void); void rarch_main_deinit(void);
void rarch_main_deinit_core(void); void rarch_main_deinit_core(void);

View File

@ -3078,6 +3078,28 @@ static inline void limit_frame_time(void)
g_extern.frame_limit.last_frame_time = rarch_get_time_usec(); g_extern.frame_limit.last_frame_time = rarch_get_time_usec();
} }
//TODO - can we refactor command.c to do this? Should be local and not
//stdin or network-based
void rarch_main_command(unsigned action)
{
switch (action)
{
case RARCH_CMD_RESET:
rarch_game_reset();
break;
case RARCH_CMD_LOAD_STATE:
rarch_load_state();
break;
case RARCH_CMD_SAVE_STATE:
rarch_save_state();
break;
case RARCH_CMD_QUIT:
g_extern.system.shutdown = true;
break;
}
}
bool rarch_main_iterate(void) bool rarch_main_iterate(void)
{ {
unsigned i; unsigned i;