diff --git a/command.c b/command.c index 28f751cce9..d6e4389c4d 100644 --- a/command.c +++ b/command.c @@ -1093,18 +1093,20 @@ static void command_event_set_volume(float gain) { char msg[128]; settings_t *settings = config_get_ptr(); + float new_volume = settings->audio.volume + gain; - settings->audio.volume += gain; - settings->audio.volume = MAX(settings->audio.volume, -80.0f); - settings->audio.volume = MIN(settings->audio.volume, 12.0f); + new_volume = MAX(new_volume, -80.0f); + new_volume = MIN(new_volume, -80.0f); + + configuration_set_float(settings, settings->audio.volume, new_volume); snprintf(msg, sizeof(msg), "%s: %.1f dB", msg_hash_to_str(MSG_AUDIO_VOLUME), - settings->audio.volume); + new_volume); runloop_msg_queue_push(msg, 1, 180, true); RARCH_LOG("%s\n", msg); - audio_driver_set_volume_gain(db_to_gain(settings->audio.volume)); + audio_driver_set_volume_gain(db_to_gain(new_volume)); } /** @@ -1121,10 +1123,11 @@ static void command_event_init_controllers(void) for (i = 0; i < MAX_USERS; i++) { retro_ctx_controller_info_t pad; - const char *ident = NULL; - bool set_controller = false; + const char *ident = NULL; + bool set_controller = false; const struct retro_controller_description *desc = NULL; - unsigned device = settings->input.libretro_device[i]; + unsigned device = + settings->input.libretro_device[i]; if (info) { @@ -1314,10 +1317,11 @@ static void command_event_set_savestate_auto_index(void) dir_list_free(dir_list); - settings->state_slot = max_idx; + configuration_set_int(settings, settings->state_slot, max_idx); + RARCH_LOG("%s: #%d\n", msg_hash_to_str(MSG_FOUND_LAST_STATE_SLOT), - settings->state_slot); + max_idx); } static bool event_init_content(void) @@ -1779,7 +1783,7 @@ static bool command_event_resize_windowed_scale(void) if (!window_scale || *window_scale == 0) return false; - settings->video.scale = *window_scale; + configuration_set_float(settings, settings->video.scale, *window_scale); } if (!settings->video.fullscreen) @@ -1932,7 +1936,10 @@ bool command_event(enum event_command cmd, void *data) #endif if (settings->savestate_auto_index) - settings->state_slot++; + { + int new_state_slot = settings->state_slot + 1; + configuration_set_int(settings, settings->state_slot, new_state_slot); + } } return command_event_main_state(cmd); case CMD_EVENT_SAVE_STATE_DECREMENT: @@ -1940,13 +1947,17 @@ bool command_event(enum event_command cmd, void *data) settings_t *settings = config_get_ptr(); /* Slot -1 is (auto) slot. */ if (settings->state_slot >= 0) - settings->state_slot--; + { + int new_state_slot = settings->state_slot - 1; + configuration_set_int(settings, settings->state_slot, new_state_slot); + } } break; case CMD_EVENT_SAVE_STATE_INCREMENT: { settings_t *settings = config_get_ptr(); - settings->state_slot++; + int new_state_slot = settings->state_slot + 1; + configuration_set_int(settings, settings->state_slot, new_state_slot); } break; case CMD_EVENT_TAKE_SCREENSHOT: @@ -2494,12 +2505,15 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_FULLSCREEN_TOGGLE: { settings_t *settings = config_get_ptr(); + bool new_fullscreen_state = !settings->video.fullscreen; if (!video_driver_has_windowed()) return false; /* If we go fullscreen we drop all drivers and * reinitialize to be safe. */ - settings->video.fullscreen = !settings->video.fullscreen; + configuration_set_bool(settings, settings->video.fullscreen, + new_fullscreen_state); + command_event(CMD_EVENT_REINIT, NULL); if (settings->video.fullscreen) video_driver_hide_mouse(); diff --git a/configuration.h b/configuration.h index 7e12d0113e..5d03b25e04 100644 --- a/configuration.h +++ b/configuration.h @@ -497,6 +497,10 @@ typedef struct settings } settings_t; +#define configuration_set_float(settings, var, newvar) \ + settings->modified = true; \ + var = newvar + #define configuration_set_bool(settings, var, newvar) \ settings->modified = true; \ var = newvar