mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 08:59:58 +00:00
(Apple) Move code out of main.m (ObjC) and into platform_apple (C)
This commit is contained in:
parent
70f696bc56
commit
b1003b7640
@ -48,7 +48,12 @@ extern RAModuleInfo* apple_core;
|
||||
extern id<RetroArch_Platform> apple_platform;
|
||||
|
||||
// main.m
|
||||
enum basic_event_t { RESET = 1, LOAD_STATE = 2, SAVE_STATE = 3, QUIT = 4 };
|
||||
enum basic_event_t {
|
||||
RESET = 1,
|
||||
LOAD_STATE = 2,
|
||||
SAVE_STATE = 3,
|
||||
QUIT = 4
|
||||
};
|
||||
extern void apple_event_basic_command(void* userdata);
|
||||
extern void apple_event_set_state_slot(void* userdata);
|
||||
extern void apple_event_show_rgui(void* userdata);
|
||||
|
@ -27,77 +27,6 @@ char** apple_argv;
|
||||
|
||||
id<RetroArch_Platform> apple_platform;
|
||||
|
||||
void apple_event_basic_command(void* userdata)
|
||||
{
|
||||
switch ((enum basic_event_t)userdata)
|
||||
{
|
||||
case RESET: rarch_game_reset(); return;
|
||||
case LOAD_STATE: rarch_load_state(); return;
|
||||
case SAVE_STATE: rarch_save_state(); return;
|
||||
case QUIT: g_extern.system.shutdown = true; return;
|
||||
}
|
||||
}
|
||||
|
||||
void apple_event_set_state_slot(void* userdata)
|
||||
{
|
||||
g_extern.state_slot = (uint32_t)userdata;
|
||||
}
|
||||
|
||||
void apple_event_show_rgui(void* userdata)
|
||||
{
|
||||
const bool in_menu = g_extern.lifecycle_state & (1 << MODE_MENU);
|
||||
g_extern.lifecycle_state &= ~(1ULL << (in_menu ? MODE_MENU : MODE_GAME));
|
||||
g_extern.lifecycle_state |= (1ULL << (in_menu ? MODE_GAME : MODE_MENU));
|
||||
}
|
||||
|
||||
static void event_reload_config(void* userdata)
|
||||
{
|
||||
objc_clear_config_hack();
|
||||
|
||||
uninit_drivers();
|
||||
config_load();
|
||||
init_drivers();
|
||||
}
|
||||
|
||||
void apple_refresh_config()
|
||||
{
|
||||
if (apple_is_running)
|
||||
apple_frontend_post_event(&event_reload_config, 0);
|
||||
else
|
||||
objc_clear_config_hack();
|
||||
}
|
||||
|
||||
pthread_mutex_t stasis_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void event_stasis(void* userdata)
|
||||
{
|
||||
uninit_drivers();
|
||||
pthread_mutex_lock(&stasis_mutex);
|
||||
pthread_mutex_unlock(&stasis_mutex);
|
||||
init_drivers();
|
||||
}
|
||||
|
||||
void apple_enter_stasis()
|
||||
{
|
||||
if (apple_is_running)
|
||||
{
|
||||
pthread_mutex_lock(&stasis_mutex);
|
||||
apple_frontend_post_event(event_stasis, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void apple_exit_stasis(bool reload_config)
|
||||
{
|
||||
if (reload_config)
|
||||
{
|
||||
objc_clear_config_hack();
|
||||
config_load();
|
||||
}
|
||||
|
||||
if (apple_is_running)
|
||||
pthread_mutex_unlock(&stasis_mutex);
|
||||
}
|
||||
|
||||
#pragma mark EMULATION
|
||||
static pthread_t apple_retro_thread;
|
||||
bool apple_is_paused;
|
||||
|
@ -49,6 +49,85 @@ void apple_frontend_post_event(void (*fn)(void*), void* userdata)
|
||||
pthread_mutex_unlock(&apple_event_queue_lock);
|
||||
}
|
||||
|
||||
void apple_event_basic_command(void* userdata)
|
||||
{
|
||||
switch ((enum basic_event_t)userdata)
|
||||
{
|
||||
case RESET:
|
||||
rarch_game_reset();
|
||||
return;
|
||||
case LOAD_STATE:
|
||||
rarch_load_state();
|
||||
return;
|
||||
case SAVE_STATE:
|
||||
rarch_save_state();
|
||||
return;
|
||||
case QUIT:
|
||||
g_extern.system.shutdown = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void apple_event_set_state_slot(void* userdata)
|
||||
{
|
||||
g_extern.state_slot = (uint32_t)userdata;
|
||||
}
|
||||
|
||||
void apple_event_show_rgui(void* userdata)
|
||||
{
|
||||
const bool in_menu = g_extern.lifecycle_state & (1 << MODE_MENU);
|
||||
g_extern.lifecycle_state &= ~(1ULL << (in_menu ? MODE_MENU : MODE_GAME));
|
||||
g_extern.lifecycle_state |= (1ULL << (in_menu ? MODE_GAME : MODE_MENU));
|
||||
}
|
||||
|
||||
static void event_reload_config(void* userdata)
|
||||
{
|
||||
objc_clear_config_hack();
|
||||
|
||||
uninit_drivers();
|
||||
config_load();
|
||||
init_drivers();
|
||||
}
|
||||
|
||||
void apple_refresh_config()
|
||||
{
|
||||
if (apple_is_running)
|
||||
apple_frontend_post_event(&event_reload_config, 0);
|
||||
else
|
||||
objc_clear_config_hack();
|
||||
}
|
||||
|
||||
pthread_mutex_t stasis_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void event_stasis(void* userdata)
|
||||
{
|
||||
uninit_drivers();
|
||||
pthread_mutex_lock(&stasis_mutex);
|
||||
pthread_mutex_unlock(&stasis_mutex);
|
||||
init_drivers();
|
||||
}
|
||||
|
||||
void apple_enter_stasis()
|
||||
{
|
||||
if (apple_is_running)
|
||||
{
|
||||
pthread_mutex_lock(&stasis_mutex);
|
||||
apple_frontend_post_event(event_stasis, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void apple_exit_stasis(bool reload_config)
|
||||
{
|
||||
if (reload_config)
|
||||
{
|
||||
objc_clear_config_hack();
|
||||
config_load();
|
||||
}
|
||||
|
||||
if (apple_is_running)
|
||||
pthread_mutex_unlock(&stasis_mutex);
|
||||
}
|
||||
|
||||
static int process_events(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
Loading…
Reference in New Issue
Block a user