From d7d1d9ff10bd2b9882c7d8214a0b82262c820e24 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 13 Jun 2014 12:19:34 +0200 Subject: [PATCH] Properly handle overlay_enable changes. --- frontend/menu/backend/menu_common_backend.c | 37 ++++++++++++++++++--- settings.c | 2 -- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index e0547d09a8..583001708b 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -2472,9 +2472,14 @@ static int menu_common_iterate(unsigned action) if (driver.overlay) input_overlay_free(driver.overlay); - driver.overlay = input_overlay_new(g_settings.input.overlay); - if (!driver.overlay) - RARCH_ERR("Failed to load overlay.\n"); + driver.overlay = NULL; + + if (g_settings.input.overlay_enable) + { + driver.overlay = input_overlay_new(g_settings.input.overlay); + if (!driver.overlay) + RARCH_ERR("Failed to load overlay.\n"); + } menu_flush_stack_type(MENU_SETTINGS_OPTIONS); } @@ -3773,11 +3778,33 @@ static int menu_common_setting_set(unsigned setting, unsigned action) break; #ifdef HAVE_OVERLAY case MENU_SETTINGS_OVERLAY_ENABLE: - if (action == MENU_ACTION_OK) + { + bool changed = false; + if (action == MENU_ACTION_OK || action == MENU_ACTION_LEFT || action == MENU_ACTION_RIGHT) + { g_settings.input.overlay_enable = !g_settings.input.overlay_enable; + changed = true; + } else if (action == MENU_ACTION_START) + { g_settings.input.overlay_enable = g_defaults.settings.input_overlay_enable; + changed = true; + } + + if (changed) + { + if (driver.overlay) + input_overlay_free(driver.overlay); + driver.overlay = NULL; + if (g_settings.input.overlay_enable && *g_settings.input.overlay) + { + driver.overlay = input_overlay_new(g_settings.input.overlay); + if (!driver.overlay) + RARCH_ERR("Failed to load overlay.\n"); + } + } break; + } case MENU_SETTINGS_OVERLAY_PRESET: switch (action) { @@ -4081,7 +4108,7 @@ static int menu_common_setting_set(unsigned setting, unsigned action) break; } case MENU_SETTINGS_DEVICE_AUTODETECT_ENABLE: - if (action == MENU_ACTION_OK) + if (action == MENU_ACTION_OK || action == MENU_ACTION_LEFT || action == MENU_ACTION_RIGHT) g_settings.input.autodetect_enable = !g_settings.input.autodetect_enable; break; case MENU_SETTINGS_CUSTOM_BIND_MODE: diff --git a/settings.c b/settings.c index 2caab84e9d..8595d5c235 100644 --- a/settings.c +++ b/settings.c @@ -390,8 +390,6 @@ void config_set_defaults(void) g_settings.input.turbo_period = turbo_period; g_settings.input.turbo_duty_cycle = turbo_duty_cycle; - g_settings.input.overlay_enable = false; - g_settings.input.overlay_enable = g_defaults.settings.input_overlay_enable; g_settings.input.overlay_opacity = 0.7f;