mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Only grab setting pointer for command events where we need it
This commit is contained in:
parent
e50ecc1b5f
commit
17609e1d42
262
command.c
262
command.c
@ -1764,7 +1764,6 @@ static bool command_event_resize_windowed_scale(void)
|
|||||||
bool command_event(enum event_command cmd, void *data)
|
bool command_event(enum event_command cmd, void *data)
|
||||||
{
|
{
|
||||||
bool boolean = false;
|
bool boolean = false;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@ -1838,17 +1837,20 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_LOAD_STATE:
|
case CMD_EVENT_LOAD_STATE:
|
||||||
/* Immutable - disallow savestate load when
|
{
|
||||||
* we absolutely cannot change game state. */
|
settings_t *settings = config_get_ptr();
|
||||||
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
/* Immutable - disallow savestate load when
|
||||||
return false;
|
* we absolutely cannot change game state. */
|
||||||
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||||
|
return false;
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
if (settings->cheevos.hardcore_mode_enable)
|
if (settings->cheevos.hardcore_mode_enable)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
command_event_main_state(cmd);
|
command_event_main_state(cmd);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_UNDO_LOAD_STATE:
|
case CMD_EVENT_UNDO_LOAD_STATE:
|
||||||
command_event_main_state(cmd);
|
command_event_main_state(cmd);
|
||||||
@ -1879,23 +1881,32 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
core_reset();
|
core_reset();
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_SAVE_STATE:
|
case CMD_EVENT_SAVE_STATE:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
if (settings->cheevos.hardcore_mode_enable)
|
if (settings->cheevos.hardcore_mode_enable)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (settings->savestate_auto_index)
|
if (settings->savestate_auto_index)
|
||||||
settings->state_slot++;
|
settings->state_slot++;
|
||||||
|
|
||||||
command_event_main_state(cmd);
|
command_event_main_state(cmd);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_SAVE_STATE_DECREMENT:
|
case CMD_EVENT_SAVE_STATE_DECREMENT:
|
||||||
/* Slot -1 is (auto) slot. */
|
{
|
||||||
if (settings->state_slot >= 0)
|
settings_t *settings = config_get_ptr();
|
||||||
settings->state_slot--;
|
/* Slot -1 is (auto) slot. */
|
||||||
|
if (settings->state_slot >= 0)
|
||||||
|
settings->state_slot--;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_SAVE_STATE_INCREMENT:
|
case CMD_EVENT_SAVE_STATE_INCREMENT:
|
||||||
settings->state_slot++;
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
settings->state_slot++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_TAKE_SCREENSHOT:
|
case CMD_EVENT_TAKE_SCREENSHOT:
|
||||||
if (!take_screenshot(path_get(RARCH_PATH_BASENAME), false))
|
if (!take_screenshot(path_get(RARCH_PATH_BASENAME), false))
|
||||||
@ -1957,32 +1968,41 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
cheat_manager_apply_cheats();
|
cheat_manager_apply_cheats();
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_REWIND_DEINIT:
|
case CMD_EVENT_REWIND_DEINIT:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
if (settings->cheevos.hardcore_mode_enable)
|
if (settings->cheevos.hardcore_mode_enable)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
state_manager_event_deinit();
|
state_manager_event_deinit();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_REWIND_INIT:
|
case CMD_EVENT_REWIND_INIT:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
if (settings->cheevos.hardcore_mode_enable)
|
if (settings->cheevos.hardcore_mode_enable)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||||
#endif
|
#endif
|
||||||
state_manager_event_init();
|
state_manager_event_init();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_REWIND_TOGGLE:
|
case CMD_EVENT_REWIND_TOGGLE:
|
||||||
if (settings->rewind_enable)
|
{
|
||||||
command_event(CMD_EVENT_REWIND_INIT, NULL);
|
settings_t *settings = config_get_ptr();
|
||||||
else
|
if (settings->rewind_enable)
|
||||||
command_event(CMD_EVENT_REWIND_DEINIT, NULL);
|
command_event(CMD_EVENT_REWIND_INIT, NULL);
|
||||||
|
else
|
||||||
|
command_event(CMD_EVENT_REWIND_DEINIT, NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_AUTOSAVE_DEINIT:
|
case CMD_EVENT_AUTOSAVE_DEINIT:
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
@ -2008,18 +2028,22 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_AUDIO_START:
|
case CMD_EVENT_AUDIO_START:
|
||||||
if (audio_driver_alive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (settings && !settings->audio.mute_enable && !audio_driver_start())
|
|
||||||
{
|
{
|
||||||
RARCH_ERR("%s\n",
|
settings_t *settings = config_get_ptr();
|
||||||
msg_hash_to_str(MSG_FAILED_TO_START_AUDIO_DRIVER));
|
if (audio_driver_alive())
|
||||||
audio_driver_unset_active();
|
return false;
|
||||||
|
|
||||||
|
if (settings && !settings->audio.mute_enable && !audio_driver_start())
|
||||||
|
{
|
||||||
|
RARCH_ERR("%s\n",
|
||||||
|
msg_hash_to_str(MSG_FAILED_TO_START_AUDIO_DRIVER));
|
||||||
|
audio_driver_unset_active();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_AUDIO_MUTE_TOGGLE:
|
case CMD_EVENT_AUDIO_MUTE_TOGGLE:
|
||||||
{
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
const char *msg = !settings->audio.mute_enable ?
|
const char *msg = !settings->audio.mute_enable ?
|
||||||
msg_hash_to_str(MSG_AUDIO_MUTED):
|
msg_hash_to_str(MSG_AUDIO_MUTED):
|
||||||
msg_hash_to_str(MSG_AUDIO_UNMUTED);
|
msg_hash_to_str(MSG_AUDIO_UNMUTED);
|
||||||
@ -2042,25 +2066,34 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_OVERLAY_INIT:
|
case CMD_EVENT_OVERLAY_INIT:
|
||||||
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
if (settings->input.overlay_enable)
|
if (settings->input.overlay_enable)
|
||||||
task_push_overlay_load_default(input_overlay_loaded, NULL);
|
task_push_overlay_load_default(input_overlay_loaded, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_OVERLAY_NEXT:
|
case CMD_EVENT_OVERLAY_NEXT:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
input_overlay_next(overlay_ptr, settings->input.overlay_opacity);
|
input_overlay_next(overlay_ptr, settings->input.overlay_opacity);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_DSP_FILTER_DEINIT:
|
case CMD_EVENT_DSP_FILTER_DEINIT:
|
||||||
audio_driver_dsp_filter_free();
|
audio_driver_dsp_filter_free();
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_DSP_FILTER_INIT:
|
case CMD_EVENT_DSP_FILTER_INIT:
|
||||||
command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL);
|
{
|
||||||
if (string_is_empty(settings->path.audio_dsp_plugin))
|
settings_t *settings = config_get_ptr();
|
||||||
break;
|
command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL);
|
||||||
audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin);
|
if (string_is_empty(settings->path.audio_dsp_plugin))
|
||||||
|
break;
|
||||||
|
audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_GPU_RECORD_DEINIT:
|
case CMD_EVENT_GPU_RECORD_DEINIT:
|
||||||
video_driver_gpu_record_deinit();
|
video_driver_gpu_record_deinit();
|
||||||
@ -2108,50 +2141,56 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_HISTORY_INIT:
|
case CMD_EVENT_HISTORY_INIT:
|
||||||
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
|
{
|
||||||
if (!settings->history_list_enable)
|
settings_t *settings = config_get_ptr();
|
||||||
return false;
|
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
|
||||||
|
if (!settings->history_list_enable)
|
||||||
|
return false;
|
||||||
|
|
||||||
RARCH_LOG("%s: [%s].\n",
|
RARCH_LOG("%s: [%s].\n",
|
||||||
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
||||||
settings->path.content_history);
|
settings->path.content_history);
|
||||||
g_defaults.content_history = playlist_init(
|
g_defaults.content_history = playlist_init(
|
||||||
settings->path.content_history,
|
settings->path.content_history,
|
||||||
settings->content_history_size);
|
settings->content_history_size);
|
||||||
|
|
||||||
#ifdef HAVE_FFMPEG
|
#ifdef HAVE_FFMPEG
|
||||||
RARCH_LOG("%s: [%s].\n",
|
RARCH_LOG("%s: [%s].\n",
|
||||||
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
||||||
settings->path.content_music_history);
|
settings->path.content_music_history);
|
||||||
g_defaults.music_history = playlist_init(
|
g_defaults.music_history = playlist_init(
|
||||||
settings->path.content_music_history,
|
settings->path.content_music_history,
|
||||||
settings->content_history_size);
|
settings->content_history_size);
|
||||||
|
|
||||||
RARCH_LOG("%s: [%s].\n",
|
RARCH_LOG("%s: [%s].\n",
|
||||||
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
||||||
settings->path.content_video_history);
|
settings->path.content_video_history);
|
||||||
g_defaults.video_history = playlist_init(
|
g_defaults.video_history = playlist_init(
|
||||||
settings->path.content_video_history,
|
settings->path.content_video_history,
|
||||||
settings->content_history_size);
|
settings->content_history_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_IMAGEVIEWER
|
#ifdef HAVE_IMAGEVIEWER
|
||||||
RARCH_LOG("%s: [%s].\n",
|
RARCH_LOG("%s: [%s].\n",
|
||||||
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
||||||
settings->path.content_image_history);
|
settings->path.content_image_history);
|
||||||
g_defaults.image_history = playlist_init(
|
g_defaults.image_history = playlist_init(
|
||||||
settings->path.content_image_history,
|
settings->path.content_image_history,
|
||||||
settings->content_history_size);
|
settings->content_history_size);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_CORE_INFO_DEINIT:
|
case CMD_EVENT_CORE_INFO_DEINIT:
|
||||||
core_info_deinit_list();
|
core_info_deinit_list();
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_CORE_INFO_INIT:
|
case CMD_EVENT_CORE_INFO_INIT:
|
||||||
command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL);
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL);
|
||||||
|
|
||||||
if (!string_is_empty(settings->directory.libretro))
|
if (!string_is_empty(settings->directory.libretro))
|
||||||
core_info_init_list();
|
core_info_init_list();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_CORE_DEINIT:
|
case CMD_EVENT_CORE_DEINIT:
|
||||||
{
|
{
|
||||||
@ -2187,14 +2226,20 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
audio_driver_set_nonblocking_state(boolean);
|
audio_driver_set_nonblocking_state(boolean);
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR:
|
case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR:
|
||||||
|
{
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
input_overlay_set_scale_factor(overlay_ptr, settings->input.overlay_scale);
|
settings_t *settings = config_get_ptr();
|
||||||
|
input_overlay_set_scale_factor(overlay_ptr, settings->input.overlay_scale);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_OVERLAY_SET_ALPHA_MOD:
|
case CMD_EVENT_OVERLAY_SET_ALPHA_MOD:
|
||||||
|
{
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
input_overlay_set_alpha_mod(overlay_ptr, settings->input.overlay_opacity);
|
settings_t *settings = config_get_ptr();
|
||||||
|
input_overlay_set_alpha_mod(overlay_ptr, settings->input.overlay_opacity);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_AUDIO_REINIT:
|
case CMD_EVENT_AUDIO_REINIT:
|
||||||
{
|
{
|
||||||
@ -2272,6 +2317,7 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
||||||
{
|
{
|
||||||
bool is_paused = false;
|
bool is_paused = false;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED));
|
||||||
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
||||||
@ -2310,20 +2356,24 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
command_event(CMD_EVENT_PAUSE_CHECKS, NULL);
|
command_event(CMD_EVENT_PAUSE_CHECKS, NULL);
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_MENU_PAUSE_LIBRETRO:
|
case CMD_EVENT_MENU_PAUSE_LIBRETRO:
|
||||||
|
{
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
settings_t *settings = config_get_ptr();
|
||||||
{
|
|
||||||
if (settings->menu.pause_libretro)
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
||||||
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
{
|
||||||
|
if (settings->menu.pause_libretro)
|
||||||
|
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
||||||
|
else
|
||||||
|
command_event(CMD_EVENT_AUDIO_START, NULL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
command_event(CMD_EVENT_AUDIO_START, NULL);
|
{
|
||||||
}
|
if (settings->menu.pause_libretro)
|
||||||
else
|
command_event(CMD_EVENT_AUDIO_START, NULL);
|
||||||
{
|
}
|
||||||
if (settings->menu.pause_libretro)
|
|
||||||
command_event(CMD_EVENT_AUDIO_START, NULL);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_SHADER_DIR_DEINIT:
|
case CMD_EVENT_SHADER_DIR_DEINIT:
|
||||||
dir_free_shader();
|
dir_free_shader();
|
||||||
@ -2357,13 +2407,16 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETPLAY_INIT:
|
case CMD_EVENT_NETPLAY_INIT:
|
||||||
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (!init_netplay(
|
if (!init_netplay(
|
||||||
data, settings->netplay.server,
|
data, settings->netplay.server,
|
||||||
settings->netplay.port))
|
settings->netplay.port))
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETPLAY_FLIP_PLAYERS:
|
case CMD_EVENT_NETPLAY_FLIP_PLAYERS:
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
@ -2376,17 +2429,20 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_FULLSCREEN_TOGGLE:
|
case CMD_EVENT_FULLSCREEN_TOGGLE:
|
||||||
if (!video_driver_has_windowed())
|
{
|
||||||
return false;
|
settings_t *settings = config_get_ptr();
|
||||||
|
if (!video_driver_has_windowed())
|
||||||
|
return false;
|
||||||
|
|
||||||
/* If we go fullscreen we drop all drivers and
|
/* If we go fullscreen we drop all drivers and
|
||||||
* reinitialize to be safe. */
|
* reinitialize to be safe. */
|
||||||
settings->video.fullscreen = !settings->video.fullscreen;
|
settings->video.fullscreen = !settings->video.fullscreen;
|
||||||
command_event(CMD_EVENT_REINIT, NULL);
|
command_event(CMD_EVENT_REINIT, NULL);
|
||||||
if (settings->video.fullscreen)
|
if (settings->video.fullscreen)
|
||||||
video_driver_hide_mouse();
|
video_driver_hide_mouse();
|
||||||
else
|
else
|
||||||
video_driver_show_mouse();
|
video_driver_show_mouse();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_COMMAND_DEINIT:
|
case CMD_EVENT_COMMAND_DEINIT:
|
||||||
input_driver_deinit_command();
|
input_driver_deinit_command();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user