From 1c867cedf0df55aad67a4d489ec9a202bdddcf16 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 29 Nov 2015 17:53:11 +0100 Subject: [PATCH] Move nonblock_state to input_driver.c (NOTE: we probably need to relocate this later on) --- driver.c | 5 ++--- driver.h | 1 - gfx/drivers/gl.c | 2 +- input/input_driver.c | 10 ++++++++++ input/input_driver.h | 5 ++++- runloop.c | 25 ++++++++++++++++++------- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/driver.c b/driver.c index c7afb6234d..5f9e6ef14c 100644 --- a/driver.c +++ b/driver.c @@ -233,7 +233,6 @@ void init_drivers_pre(void) static void driver_adjust_system_rates(void) { rarch_system_info_t *system = rarch_system_info_get_ptr(); - driver_t *driver = driver_get_ptr(); audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); @@ -275,7 +274,7 @@ void driver_set_nonblock_state(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); driver_t *driver = driver_get_ptr(); - bool enable = driver->nonblock_state; + bool enable = input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL); /* Only apply non-block-state for video if we're using vsync. */ if (driver->video_active && video_driver_get_ptr(false)) @@ -418,7 +417,7 @@ void init_drivers(int flags) if (flags & (DRIVER_VIDEO | DRIVER_AUDIO)) { /* Keep non-throttled state as good as possible. */ - if (driver->nonblock_state) + if (input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) driver_set_nonblock_state(); } } diff --git a/driver.h b/driver.h index 770184eae0..a189d0080b 100644 --- a/driver.h +++ b/driver.h @@ -266,7 +266,6 @@ typedef struct driver #ifdef HAVE_NETWORK_GAMEPAD rarch_remote_t *remote; #endif - bool nonblock_state; /* Last message given to the video driver */ char current_msg[PATH_MAX_LENGTH]; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index d52e15b7f8..9f52b754f7 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1846,7 +1846,7 @@ static bool gl_frame(void *data, const void *frame, * and pause to prevent flicker. */ if ( settings->video.black_frame_insertion - && !driver->nonblock_state + && !input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL) && !is_slowmotion && !is_paused) { gfx_ctx_swap_buffers(gl); diff --git a/input/input_driver.c b/input/input_driver.c index 90ff261410..80ec42bc15 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -85,6 +85,7 @@ struct turbo_buttons static bool flushing_input; static bool block_libretro_input; static bool block_hotkey; +static bool nonblock_state; static turbo_buttons_t turbo_btns; /** @@ -689,6 +690,7 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) case RARCH_INPUT_CTL_DESTROY: flushing_input = false; block_hotkey = false; + nonblock_state = false; memset(&turbo_btns, 0, sizeof(turbo_buttons_t)); if (!driver) return false; @@ -744,6 +746,14 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) break; case RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED: return block_libretro_input; + case RARCH_INPUT_CTL_SET_NONBLOCK_STATE: + nonblock_state = true; + break; + case RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE: + nonblock_state = false; + break; + case RARCH_INPUT_CTL_IS_NONBLOCK_STATE: + return nonblock_state; case RARCH_INPUT_CTL_NONE: default: break; diff --git a/input/input_driver.h b/input/input_driver.h index 0042b2f09a..0420ffab45 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -62,7 +62,10 @@ enum rarch_input_ctl_state RARCH_INPUT_CTL_IS_FLUSHING_INPUT, RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, - RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED + RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, + RARCH_INPUT_CTL_SET_NONBLOCK_STATE, + RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, + RARCH_INPUT_CTL_IS_NONBLOCK_STATE }; struct retro_keybind diff --git a/runloop.c b/runloop.c index 08f50c0534..dd79d027b0 100644 --- a/runloop.c +++ b/runloop.c @@ -230,8 +230,7 @@ static bool check_pause(settings_t *settings, * Checks if the fast forward key has been pressed for this frame. * **/ -static void check_fast_forward_button(driver_t *driver, - bool fastforward_pressed, +static void check_fast_forward_button(bool fastforward_pressed, bool hold_pressed, bool old_hold_pressed) { /* To avoid continous switching if we hold the button down, we require @@ -239,9 +238,19 @@ static void check_fast_forward_button(driver_t *driver, * to be able to toggle between then. */ if (fastforward_pressed) - driver->nonblock_state = !driver->nonblock_state; + { + if (input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) + input_driver_ctl(RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, NULL); + else + input_driver_ctl(RARCH_INPUT_CTL_SET_NONBLOCK_STATE, NULL); + } else if (old_hold_pressed != hold_pressed) - driver->nonblock_state = hold_pressed; + { + if (hold_pressed) + input_driver_ctl(RARCH_INPUT_CTL_SET_NONBLOCK_STATE, NULL); + else + input_driver_ctl(RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, NULL); + } else return; @@ -523,7 +532,7 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data) if (!rarch_main_ctl(RARCH_MAIN_CTL_CHECK_IDLE_STATE, data)) return false; - check_fast_forward_button(driver, + check_fast_forward_button( cmd->fastforward_pressed, cmd->hold_pressed, cmd->old_hold_pressed); check_stateslots(settings, cmd->state_slot_increase, @@ -997,7 +1006,8 @@ int rarch_main_iterate(unsigned *sleep_ms) retro_time_t current = retro_get_time_usec(); retro_time_t delta = current - system->frame_time_last; - bool is_locked_fps = (main_is_paused || driver->nonblock_state) | + bool is_locked_fps = (main_is_paused || + input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) | !!driver->recording_data; if (!system->frame_time_last || is_locked_fps) @@ -1115,7 +1125,8 @@ int rarch_main_iterate(unsigned *sleep_ms) settings->input.analog_dpad_mode[i]); } - if ((settings->video.frame_delay > 0) && !driver->nonblock_state) + if ((settings->video.frame_delay > 0) && + !input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) retro_sleep(settings->video.frame_delay); /* Run libretro for one frame. */