Both the 'pause' state and the 'menu' state return 1 - so that

we can signal to the Apple upper-layer function that we want
to run CFRunLoopWakeUp
This commit is contained in:
twinaphex 2014-10-04 14:14:45 +02:00
parent 291f4579a2
commit 458eff5f4d
4 changed files with 70 additions and 64 deletions

View File

@ -56,7 +56,9 @@
int main_entry_decide(signature(), args_type() args) int main_entry_decide(signature(), args_type() args)
{ {
if (rarch_main_iterate() == -1) int ret = rarch_main_iterate();
if (ret == -1)
{ {
if (g_extern.core_shutdown_initiated if (g_extern.core_shutdown_initiated
&& g_settings.load_dummy_on_core_shutdown) && g_settings.load_dummy_on_core_shutdown)
@ -66,13 +68,12 @@ int main_entry_decide(signature(), args_type() args)
g_extern.core_shutdown_initiated = false; g_extern.core_shutdown_initiated = false;
return 0; return 0;
} }
return 1;
} }
if (driver.frontend_ctx && driver.frontend_ctx->process_events) if (driver.frontend_ctx && driver.frontend_ctx->process_events)
driver.frontend_ctx->process_events(args); driver.frontend_ctx->process_events(args);
return 0; return ret;
} }
void main_exit(args_type() args) void main_exit(args_type() args)
@ -241,7 +242,7 @@ returntype main_entry(signature())
#endif #endif
#if defined(HAVE_MAIN_LOOP) #if defined(HAVE_MAIN_LOOP)
while (!main_entry_decide(signature_expand(), args)); while (main_entry_decide(signature_expand(), args) != -1);
main_exit(args); main_exit(args);
#endif #endif

View File

@ -28,12 +28,17 @@ static CFRunLoopObserverRef iterate_observer;
static void do_iteration(void) static void do_iteration(void)
{ {
if (main_entry_decide(0, NULL, NULL)) int ret = main_entry_decide(0, NULL, NULL);
if (ret == -1)
{ {
main_exit(NULL); main_exit(NULL);
return; return;
} }
if (ret)
CFRunLoopWakeUp(CFRunLoopGetMain());
/* TODO/FIXME /* TODO/FIXME
I am almost positive that this is not necessary and is actually a I am almost positive that this is not necessary and is actually a
bad thing. bad thing.
@ -91,10 +96,6 @@ static void do_iteration(void)
"ugly way" first because it is the most expedient and "ugly way" first because it is the most expedient and
safe. Other eyeballs should decide if it isn't necessary. safe. Other eyeballs should decide if it isn't necessary.
*/ */
#if 0
if ( ! g_extern.is_menu )
CFRunLoopWakeUp(CFRunLoopGetMain());
#endif
} }
void apple_start_iteration(void) void apple_start_iteration(void)

View File

@ -27,7 +27,9 @@
static void emscripten_mainloop(void) static void emscripten_mainloop(void)
{ {
if (main_entry_decide(0, NULL, NULL)) int ret = main_entry_decide(0, NULL, NULL)
if (ret == -1)
{ {
main_exit(NULL); main_exit(NULL);
exit(0); exit(0);

View File

@ -3221,16 +3221,19 @@ static inline int time_to_exit(retro_input_t input)
/* Returns: /* Returns:
* 0 - Successful iteration. * 0 - Successful iteration.
* 1 - Forcibly wake up the loop.
* -1 - Quit out of iteration loop. * -1 - Quit out of iteration loop.
*/ */
int rarch_main_iterate(void) int rarch_main_iterate(void)
{ {
unsigned i; unsigned i;
retro_input_t trigger_input;
int ret = 0;
static retro_input_t last_input = 0; static retro_input_t last_input = 0;
retro_input_t old_input, trigger_input; retro_input_t old_input = last_input;
retro_input_t input = input_keys_pressed(); retro_input_t input = input_keys_pressed();
old_input = last_input;
last_input = input; last_input = input;
if (driver.flushing_input) if (driver.flushing_input)
@ -3258,6 +3261,7 @@ int rarch_main_iterate(void)
if (!menu_iterate(input, old_input, trigger_input)) if (!menu_iterate(input, old_input, trigger_input))
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED); rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
ret = 1;
goto success; goto success;
} }
#endif #endif
@ -3274,9 +3278,7 @@ int rarch_main_iterate(void)
driver.retro_ctx.poll_cb(); driver.retro_ctx.poll_cb();
rarch_sleep(10); rarch_sleep(10);
/* TODO - maybe change this from 0 to something else return 1;
* to signal that RetroArch is currently paused. */
return 0;
} }
#if defined(HAVE_THREADS) #if defined(HAVE_THREADS)
@ -3338,7 +3340,7 @@ success:
if (g_settings.fastforward_ratio_throttle_enable) if (g_settings.fastforward_ratio_throttle_enable)
limit_frame_time(); limit_frame_time();
return 0; return ret;
} }
void rarch_main_deinit(void) void rarch_main_deinit(void)