mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Refactor away rarch_main_set_idle
This commit is contained in:
parent
5ad2987449
commit
e3e1a5a35c
@ -359,9 +359,11 @@ static void engine_handle_cmd(void)
|
||||
|
||||
if (!system->shutdown)
|
||||
{
|
||||
bool boolean = true;
|
||||
RARCH_LOG("Pausing RetroArch.\n");
|
||||
rarch_main_set_pause(true);
|
||||
rarch_main_set_idle(true);
|
||||
|
||||
rarch_main_ctl(RARCH_MAIN_CTL_SET_IDLE, &boolean);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -390,16 +392,20 @@ static void engine_handle_cmd(void)
|
||||
break;
|
||||
|
||||
case APP_CMD_GAINED_FOCUS:
|
||||
rarch_main_set_pause(false);
|
||||
rarch_main_set_idle(false);
|
||||
{
|
||||
bool boolean = false;
|
||||
|
||||
if ((android_app->sensor_state_mask
|
||||
& (UINT64_C(1) << RETRO_SENSOR_ACCELEROMETER_ENABLE))
|
||||
&& android_app->accelerometerSensor == NULL
|
||||
&& driver->input_data)
|
||||
android_input_set_sensor_state(driver->input_data, 0,
|
||||
RETRO_SENSOR_ACCELEROMETER_ENABLE,
|
||||
android_app->accelerometer_event_rate);
|
||||
rarch_main_set_pause(false);
|
||||
rarch_main_ctl(RARCH_MAIN_CTL_SET_IDLE, &boolean);
|
||||
|
||||
if ((android_app->sensor_state_mask
|
||||
& (UINT64_C(1) << RETRO_SENSOR_ACCELEROMETER_ENABLE))
|
||||
&& android_app->accelerometerSensor == NULL
|
||||
&& driver->input_data)
|
||||
android_input_set_sensor_state(driver->input_data, 0,
|
||||
RETRO_SENSOR_ACCELEROMETER_ENABLE,
|
||||
android_app->accelerometer_event_rate);
|
||||
}
|
||||
break;
|
||||
case APP_CMD_LOST_FOCUS:
|
||||
/* Avoid draining battery while app is not being used. */
|
||||
|
13
runloop.c
13
runloop.c
@ -881,11 +881,6 @@ void rarch_main_set_max_frames(unsigned val)
|
||||
main_max_frames = val;
|
||||
}
|
||||
|
||||
void rarch_main_set_idle(unsigned enable)
|
||||
{
|
||||
main_is_idle = enable;
|
||||
}
|
||||
|
||||
bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
|
||||
{
|
||||
switch (state)
|
||||
@ -898,6 +893,14 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
|
||||
*ptr = main_is_idle;
|
||||
}
|
||||
return true;
|
||||
case RARCH_MAIN_CTL_SET_IDLE:
|
||||
{
|
||||
bool *ptr = (bool*)data;
|
||||
if (!ptr)
|
||||
return false;
|
||||
main_is_idle = *ptr;
|
||||
}
|
||||
return true;
|
||||
case RARCH_MAIN_CTL_IS_SLOWMOTION:
|
||||
{
|
||||
bool *ptr = (bool*)data;
|
||||
|
@ -36,6 +36,7 @@ extern "C" {
|
||||
enum rarch_main_ctl_state
|
||||
{
|
||||
RARCH_MAIN_CTL_IS_IDLE = 0,
|
||||
RARCH_MAIN_CTL_SET_IDLE,
|
||||
RARCH_MAIN_CTL_IS_SLOWMOTION,
|
||||
RARCH_MAIN_CTL_SET_SLOWMOTION,
|
||||
RARCH_MAIN_CTL_IS_PAUSED,
|
||||
@ -342,8 +343,6 @@ void rarch_main_set_frame_limit_last_time(void);
|
||||
|
||||
void rarch_main_set_max_frames(unsigned val);
|
||||
|
||||
void rarch_main_set_idle(unsigned enable);
|
||||
|
||||
void rarch_main_state_free(void);
|
||||
|
||||
void rarch_main_global_free(void);
|
||||
|
@ -45,16 +45,22 @@ void apple_rarch_exited(void);
|
||||
|
||||
static void rarch_enable_ui(void)
|
||||
{
|
||||
bool boolean = true;
|
||||
|
||||
ui_companion_set_foreground(true);
|
||||
rarch_main_set_pause(true);
|
||||
rarch_main_set_idle(true);
|
||||
|
||||
rarch_main_ctl(RARCH_MAIN_CTL_SET_IDLE, &boolean);
|
||||
}
|
||||
|
||||
static void rarch_disable_ui(void)
|
||||
{
|
||||
bool boolean = false;
|
||||
|
||||
ui_companion_set_foreground(false);
|
||||
rarch_main_set_pause(false);
|
||||
rarch_main_set_idle(false);
|
||||
|
||||
rarch_main_ctl(RARCH_MAIN_CTL_SET_IDLE, &boolean);
|
||||
}
|
||||
|
||||
static void rarch_draw_observer(CFRunLoopObserverRef observer,
|
||||
|
Loading…
x
Reference in New Issue
Block a user