2012-05-27 12:12:29 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-03-22 02:09:18 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2018-08-30 14:05:51 +00:00
|
|
|
* Copyright (C) 2015-2017 - Andres Suarez
|
2019-02-22 21:31:54 +00:00
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
2015-01-29 01:29:07 +00:00
|
|
|
*
|
2012-05-27 12:12:29 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2016-05-09 18:30:47 +00:00
|
|
|
#include <ctype.h>
|
2012-05-27 12:12:29 +00:00
|
|
|
|
2015-06-14 15:19:32 +00:00
|
|
|
#include <compat/strl.h>
|
|
|
|
#include <compat/posix_string.h>
|
|
|
|
#include <file/file_path.h>
|
2016-05-09 18:30:47 +00:00
|
|
|
#include <lists/dir_list.h>
|
|
|
|
#include <string/stdstring.h>
|
2017-12-14 19:05:46 +00:00
|
|
|
#include <streams/file_stream.h>
|
2017-05-20 12:58:51 +00:00
|
|
|
#include <streams/stdin_stream.h>
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-09-08 04:07:43 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_COMMAND
|
2017-05-20 12:58:51 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
|
|
|
#include <net/net_compat.h>
|
|
|
|
#include <net/net_socket.h>
|
|
|
|
#endif
|
2016-01-20 04:21:52 +00:00
|
|
|
#include <string/stdstring.h>
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2015-07-01 22:29:02 +00:00
|
|
|
|
2016-09-08 06:08:42 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2017-05-07 18:06:03 +00:00
|
|
|
#include "cheevos/cheevos.h"
|
2018-10-01 13:02:20 +00:00
|
|
|
#include "cheevos/var.h"
|
2019-03-17 01:13:57 +00:00
|
|
|
#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove lines */
|
|
|
|
#include "cheevos-new/fixup.h"
|
2016-09-08 06:08:42 +00:00
|
|
|
#endif
|
|
|
|
|
2018-05-29 04:43:30 +00:00
|
|
|
#ifdef HAVE_DISCORD
|
|
|
|
#include "discord/discord.h"
|
|
|
|
#endif
|
|
|
|
|
2018-06-17 23:44:17 +00:00
|
|
|
#include "midi/midi_driver.h"
|
|
|
|
|
2016-09-08 06:08:42 +00:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "menu/menu_driver.h"
|
|
|
|
#include "menu/menu_content.h"
|
|
|
|
#include "menu/menu_shader.h"
|
2016-09-15 13:57:25 +00:00
|
|
|
#include "menu/widgets/menu_dialog.h"
|
2019-04-08 14:44:21 +00:00
|
|
|
#ifdef HAVE_MENU_WIDGETS
|
|
|
|
#include "menu/widgets/menu_widgets.h"
|
|
|
|
#endif
|
2016-09-08 06:08:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETWORKING
|
|
|
|
#include <net/net_compat.h>
|
2016-09-29 19:07:10 +00:00
|
|
|
#include "network/netplay/netplay.h"
|
2016-09-08 06:08:42 +00:00
|
|
|
#endif
|
|
|
|
|
2015-06-14 15:19:32 +00:00
|
|
|
#include "command.h"
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "defaults.h"
|
2016-09-11 14:31:23 +00:00
|
|
|
#include "driver.h"
|
2017-08-31 00:25:04 +00:00
|
|
|
#include "input/input_driver.h"
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "frontend/frontend_driver.h"
|
|
|
|
#include "audio/audio_driver.h"
|
|
|
|
#include "record/record_driver.h"
|
2016-08-01 16:29:26 +00:00
|
|
|
#include "file_path_special.h"
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "autosave.h"
|
|
|
|
#include "core_info.h"
|
|
|
|
#include "core_type.h"
|
2016-05-10 06:53:14 +00:00
|
|
|
#include "performance_counters.h"
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "dynamic.h"
|
|
|
|
#include "content.h"
|
2016-09-23 01:21:33 +00:00
|
|
|
#include "dirs.h"
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "movie.h"
|
2016-09-17 10:25:26 +00:00
|
|
|
#include "paths.h"
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "msg_hash.h"
|
|
|
|
#include "retroarch.h"
|
|
|
|
#include "managers/cheat_manager.h"
|
|
|
|
#include "managers/state_manager.h"
|
|
|
|
#include "ui/ui_companion_driver.h"
|
2019-01-20 02:16:58 +00:00
|
|
|
#include "tasks/task_content.h"
|
2016-05-16 15:19:16 +00:00
|
|
|
#include "tasks/tasks_internal.h"
|
2019-02-04 16:20:34 +00:00
|
|
|
#include "gfx/video_driver.h"
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "list_special.h"
|
|
|
|
|
2016-09-08 04:07:43 +00:00
|
|
|
#include "core.h"
|
|
|
|
#include "verbosity.h"
|
2017-05-11 07:11:46 +00:00
|
|
|
#include "retroarch.h"
|
2016-09-08 04:07:43 +00:00
|
|
|
#include "configuration.h"
|
|
|
|
#include "input/input_remapping.h"
|
2018-07-29 13:15:29 +00:00
|
|
|
#include "version.h"
|
2016-09-08 04:07:43 +00:00
|
|
|
|
2012-06-01 13:15:06 +00:00
|
|
|
#define DEFAULT_NETWORK_CMD_PORT 55355
|
2016-02-13 06:19:21 +00:00
|
|
|
#define STDIN_BUF_SIZE 4096
|
|
|
|
|
2018-09-09 21:41:50 +00:00
|
|
|
extern bool discord_is_inited;
|
|
|
|
|
2017-09-28 07:17:58 +00:00
|
|
|
enum cmd_source_t
|
|
|
|
{
|
|
|
|
CMD_NONE = 0,
|
|
|
|
CMD_STDIN,
|
|
|
|
CMD_NETWORK
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cmd_map
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
unsigned id;
|
|
|
|
};
|
|
|
|
|
2018-10-04 14:24:10 +00:00
|
|
|
#ifdef HAVE_COMMAND
|
2017-09-28 07:17:58 +00:00
|
|
|
struct cmd_action_map
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
bool (*action)(const char *arg);
|
|
|
|
const char *arg_desc;
|
|
|
|
};
|
2018-10-04 14:24:10 +00:00
|
|
|
#endif
|
2017-09-28 07:17:58 +00:00
|
|
|
|
2016-05-09 18:10:08 +00:00
|
|
|
struct command
|
2012-05-27 12:12:29 +00:00
|
|
|
{
|
2012-07-24 00:47:28 +00:00
|
|
|
bool stdin_enable;
|
2017-09-28 07:29:36 +00:00
|
|
|
bool state[RARCH_BIND_LIST_END];
|
|
|
|
#ifdef HAVE_STDIN_CMD
|
2012-07-24 00:47:28 +00:00
|
|
|
char stdin_buf[STDIN_BUF_SIZE];
|
|
|
|
size_t stdin_buf_ptr;
|
|
|
|
#endif
|
2016-09-29 19:07:10 +00:00
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD)
|
2012-07-24 00:47:28 +00:00
|
|
|
int net_fd;
|
|
|
|
#endif
|
2012-05-27 12:12:29 +00:00
|
|
|
};
|
|
|
|
|
2018-10-04 14:24:10 +00:00
|
|
|
#if defined(HAVE_COMMAND)
|
|
|
|
static enum cmd_source_t lastcmd_source;
|
2018-10-06 11:37:37 +00:00
|
|
|
#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING)
|
2018-10-04 14:24:10 +00:00
|
|
|
static int lastcmd_net_fd;
|
|
|
|
static struct sockaddr_storage lastcmd_net_source;
|
|
|
|
static socklen_t lastcmd_net_source_len;
|
2018-10-06 11:37:37 +00:00
|
|
|
#endif
|
2018-07-29 13:15:29 +00:00
|
|
|
|
2018-10-06 11:37:37 +00:00
|
|
|
#if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING))
|
2018-10-04 14:24:10 +00:00
|
|
|
static void command_reply(const char * data, size_t len)
|
|
|
|
{
|
|
|
|
switch (lastcmd_source)
|
|
|
|
{
|
|
|
|
case CMD_STDIN:
|
|
|
|
#ifdef HAVE_STDIN_CMD
|
|
|
|
fwrite(data, 1,len, stdout);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case CMD_NETWORK:
|
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD)
|
|
|
|
sendto(lastcmd_net_fd, data, len, 0,
|
|
|
|
(struct sockaddr*)&lastcmd_net_source, lastcmd_net_source_len);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case CMD_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
static bool command_version(const char* arg)
|
|
|
|
{
|
|
|
|
char reply[256] = {0};
|
|
|
|
|
2019-01-31 14:13:36 +00:00
|
|
|
snprintf(reply, sizeof(reply), "%s\n", PACKAGE_VERSION);
|
2018-10-04 14:24:10 +00:00
|
|
|
#if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING))
|
|
|
|
command_reply(reply, strlen(reply));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(HAVE_CHEEVOS)
|
2017-09-28 07:17:58 +00:00
|
|
|
static bool command_read_ram(const char *arg);
|
|
|
|
static bool command_write_ram(const char *arg);
|
2018-01-02 05:40:19 +00:00
|
|
|
#endif
|
2017-09-28 07:17:58 +00:00
|
|
|
|
|
|
|
static const struct cmd_action_map action_map[] = {
|
2017-09-28 07:29:36 +00:00
|
|
|
{ "SET_SHADER", command_set_shader, "<shader path>" },
|
2018-07-29 13:15:29 +00:00
|
|
|
{ "VERSION", command_version, "No argument"},
|
2018-10-04 14:24:10 +00:00
|
|
|
#if defined(HAVE_CHEEVOS)
|
2017-09-28 07:29:36 +00:00
|
|
|
{ "READ_CORE_RAM", command_read_ram, "<address> <number of bytes>" },
|
|
|
|
{ "WRITE_CORE_RAM", command_write_ram, "<address> <byte1> <byte2> ..." },
|
2017-09-28 07:17:58 +00:00
|
|
|
#endif
|
2016-09-11 15:37:05 +00:00
|
|
|
};
|
|
|
|
|
2017-09-28 07:17:58 +00:00
|
|
|
static const struct cmd_map map[] = {
|
|
|
|
{ "FAST_FORWARD", RARCH_FAST_FORWARD_KEY },
|
|
|
|
{ "FAST_FORWARD_HOLD", RARCH_FAST_FORWARD_HOLD_KEY },
|
2018-03-10 17:42:45 +00:00
|
|
|
{ "SLOWMOTION", RARCH_SLOWMOTION_KEY },
|
|
|
|
{ "SLOWMOTION_HOLD", RARCH_SLOWMOTION_HOLD_KEY },
|
2017-09-28 07:17:58 +00:00
|
|
|
{ "LOAD_STATE", RARCH_LOAD_STATE_KEY },
|
|
|
|
{ "SAVE_STATE", RARCH_SAVE_STATE_KEY },
|
|
|
|
{ "FULLSCREEN_TOGGLE", RARCH_FULLSCREEN_TOGGLE_KEY },
|
|
|
|
{ "QUIT", RARCH_QUIT_KEY },
|
|
|
|
{ "STATE_SLOT_PLUS", RARCH_STATE_SLOT_PLUS },
|
|
|
|
{ "STATE_SLOT_MINUS", RARCH_STATE_SLOT_MINUS },
|
|
|
|
{ "REWIND", RARCH_REWIND },
|
2018-09-16 02:26:37 +00:00
|
|
|
{ "BSV_RECORD_TOGGLE", RARCH_BSV_RECORD_TOGGLE },
|
2017-09-28 07:17:58 +00:00
|
|
|
{ "PAUSE_TOGGLE", RARCH_PAUSE_TOGGLE },
|
|
|
|
{ "FRAMEADVANCE", RARCH_FRAMEADVANCE },
|
|
|
|
{ "RESET", RARCH_RESET },
|
|
|
|
{ "SHADER_NEXT", RARCH_SHADER_NEXT },
|
|
|
|
{ "SHADER_PREV", RARCH_SHADER_PREV },
|
|
|
|
{ "CHEAT_INDEX_PLUS", RARCH_CHEAT_INDEX_PLUS },
|
|
|
|
{ "CHEAT_INDEX_MINUS", RARCH_CHEAT_INDEX_MINUS },
|
|
|
|
{ "CHEAT_TOGGLE", RARCH_CHEAT_TOGGLE },
|
|
|
|
{ "SCREENSHOT", RARCH_SCREENSHOT },
|
|
|
|
{ "MUTE", RARCH_MUTE },
|
|
|
|
{ "OSK", RARCH_OSK },
|
2018-11-29 12:12:11 +00:00
|
|
|
{ "FPS_TOGGLE", RARCH_FPS_TOGGLE },
|
2019-03-09 21:03:17 +00:00
|
|
|
{ "SEND_DEBUG_INFO", RARCH_SEND_DEBUG_INFO },
|
2019-03-09 22:48:03 +00:00
|
|
|
{ "NETPLAY_HOST_TOGGLE", RARCH_NETPLAY_HOST_TOGGLE },
|
2017-09-28 07:17:58 +00:00
|
|
|
{ "NETPLAY_GAME_WATCH", RARCH_NETPLAY_GAME_WATCH },
|
|
|
|
{ "VOLUME_UP", RARCH_VOLUME_UP },
|
|
|
|
{ "VOLUME_DOWN", RARCH_VOLUME_DOWN },
|
|
|
|
{ "OVERLAY_NEXT", RARCH_OVERLAY_NEXT },
|
|
|
|
{ "DISK_EJECT_TOGGLE", RARCH_DISK_EJECT_TOGGLE },
|
|
|
|
{ "DISK_NEXT", RARCH_DISK_NEXT },
|
|
|
|
{ "DISK_PREV", RARCH_DISK_PREV },
|
|
|
|
{ "GRAB_MOUSE_TOGGLE", RARCH_GRAB_MOUSE_TOGGLE },
|
2018-04-30 18:33:05 +00:00
|
|
|
{ "UI_COMPANION_TOGGLE", RARCH_UI_COMPANION_TOGGLE },
|
2017-09-28 07:17:58 +00:00
|
|
|
{ "GAME_FOCUS_TOGGLE", RARCH_GAME_FOCUS_TOGGLE },
|
|
|
|
{ "MENU_TOGGLE", RARCH_MENU_TOGGLE },
|
2018-09-18 06:51:35 +00:00
|
|
|
{ "RECORDING_TOGGLE", RARCH_RECORDING_TOGGLE },
|
|
|
|
{ "STREAMING_TOGGLE", RARCH_STREAMING_TOGGLE },
|
2017-09-28 07:17:58 +00:00
|
|
|
{ "MENU_UP", RETRO_DEVICE_ID_JOYPAD_UP },
|
|
|
|
{ "MENU_DOWN", RETRO_DEVICE_ID_JOYPAD_DOWN },
|
|
|
|
{ "MENU_LEFT", RETRO_DEVICE_ID_JOYPAD_LEFT },
|
|
|
|
{ "MENU_RIGHT", RETRO_DEVICE_ID_JOYPAD_RIGHT },
|
|
|
|
{ "MENU_A", RETRO_DEVICE_ID_JOYPAD_A },
|
|
|
|
{ "MENU_B", RETRO_DEVICE_ID_JOYPAD_B },
|
|
|
|
{ "MENU_B", RETRO_DEVICE_ID_JOYPAD_B },
|
|
|
|
};
|
2016-06-04 15:41:14 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-20 13:50:38 +00:00
|
|
|
bool command_set_shader(const char *arg)
|
2016-05-09 19:23:53 +00:00
|
|
|
{
|
|
|
|
char msg[256];
|
2018-02-25 16:20:22 +00:00
|
|
|
bool is_preset = false;
|
|
|
|
enum rarch_shader_type type = video_shader_get_type_from_ext(
|
|
|
|
path_get_extension(arg), &is_preset);
|
2016-05-09 19:23:53 +00:00
|
|
|
|
2018-02-25 16:20:22 +00:00
|
|
|
if (type == RARCH_SHADER_NONE)
|
|
|
|
return false;
|
2016-05-09 19:23:53 +00:00
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg);
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 19:23:53 +00:00
|
|
|
RARCH_LOG("%s \"%s\".\n",
|
|
|
|
msg_hash_to_str(MSG_APPLYING_SHADER),
|
|
|
|
arg);
|
|
|
|
|
2018-02-09 03:24:18 +00:00
|
|
|
retroarch_set_shader_preset(arg);
|
2018-08-16 07:50:37 +00:00
|
|
|
#ifdef HAVE_MENU
|
2019-03-13 19:31:57 +00:00
|
|
|
return menu_shader_manager_set_preset(menu_shader_get(), type, arg);
|
2018-08-16 07:50:37 +00:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
2016-05-09 19:23:53 +00:00
|
|
|
}
|
2016-02-13 06:19:21 +00:00
|
|
|
|
2018-01-02 05:40:19 +00:00
|
|
|
#if defined(HAVE_COMMAND) && defined(HAVE_CHEEVOS)
|
2018-07-29 12:49:31 +00:00
|
|
|
#define SMY_CMD_STR "READ_CORE_RAM"
|
2016-06-04 15:41:14 +00:00
|
|
|
static bool command_read_ram(const char *arg)
|
|
|
|
{
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove settings init and test */
|
|
|
|
settings_t *settings = config_get_ptr();
|
2019-03-07 05:46:39 +00:00
|
|
|
cheevos_var_t var;
|
2019-03-17 01:13:57 +00:00
|
|
|
|
2016-06-19 20:43:49 +00:00
|
|
|
unsigned i;
|
2019-03-06 12:40:25 +00:00
|
|
|
char *reply = NULL;
|
|
|
|
const uint8_t *data = NULL;
|
2018-07-31 23:27:30 +00:00
|
|
|
char *reply_at = NULL;
|
|
|
|
unsigned int nbytes = 0;
|
2018-07-29 12:49:31 +00:00
|
|
|
unsigned int alloc_size = 0;
|
2019-03-06 12:40:25 +00:00
|
|
|
unsigned int addr = -1;
|
2017-04-28 11:43:47 +00:00
|
|
|
|
2019-03-14 16:09:51 +00:00
|
|
|
if (sscanf(arg, "%x %u", &addr, &nbytes) != 2)
|
2018-07-29 12:49:31 +00:00
|
|
|
return true;
|
2019-03-06 12:40:25 +00:00
|
|
|
alloc_size = 40 + nbytes * 3; /* We alloc more than needed, saving 20 bytes is not really relevant */
|
|
|
|
reply = (char*) malloc(alloc_size);
|
|
|
|
reply[0] = '\0';
|
2019-03-06 13:23:58 +00:00
|
|
|
reply_at = reply + snprintf(reply, alloc_size - 1, SMY_CMD_STR " %x", addr);
|
2016-06-04 15:41:14 +00:00
|
|
|
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove if condition below */
|
|
|
|
if (settings->bools.cheevos_rcheevos_enable)
|
|
|
|
{
|
|
|
|
data = rcheevos_patch_address(addr, rcheevos_get_console());
|
|
|
|
}
|
|
|
|
/* RCHEEVOS TODO: remove whole else block below */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var.value = addr;
|
|
|
|
cheevos_var_patch_addr(&var, cheevos_get_console());
|
|
|
|
data = cheevos_var_get_memory(&var);
|
|
|
|
}
|
2018-10-01 13:02:20 +00:00
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
2019-01-31 14:13:36 +00:00
|
|
|
for (i = 0; i < nbytes; i++)
|
2019-03-06 13:23:58 +00:00
|
|
|
snprintf(reply_at + 3 * i, 4, " %.2X", data[i]);
|
2019-03-06 12:40:25 +00:00
|
|
|
reply_at[3 * nbytes] = '\n';
|
|
|
|
command_reply(reply, reply_at + 3 * nbytes + 1 - reply);
|
2018-10-01 13:02:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-06 12:40:25 +00:00
|
|
|
strlcpy(reply_at, " -1\n", sizeof(reply) - strlen(reply));
|
|
|
|
command_reply(reply, reply_at + strlen(" -1\n") - reply);
|
2018-10-01 13:02:20 +00:00
|
|
|
}
|
2019-03-06 12:40:25 +00:00
|
|
|
free(reply);
|
2016-06-04 15:41:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-29 12:49:31 +00:00
|
|
|
#undef SMY_CMD_STR
|
2016-06-04 15:41:14 +00:00
|
|
|
|
|
|
|
static bool command_write_ram(const char *arg)
|
|
|
|
{
|
2019-03-17 01:13:57 +00:00
|
|
|
unsigned nbytes = 0;
|
|
|
|
uint8_t *data = NULL;
|
|
|
|
unsigned int addr = 0;
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove settings init and test */
|
|
|
|
settings_t *settings = config_get_ptr();
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2019-03-17 01:13:57 +00:00
|
|
|
if (settings->bools.cheevos_rcheevos_enable)
|
|
|
|
{
|
|
|
|
addr = strtoul(arg, (char**)&arg, 16);
|
|
|
|
data = (uint8_t *)rcheevos_patch_address(addr, rcheevos_get_console());
|
|
|
|
}
|
|
|
|
/* RCHEEVOS TODO: remove the whole else block below */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cheevos_var_t var;
|
|
|
|
|
|
|
|
var.value = strtoul(arg, (char**)&arg, 16);
|
|
|
|
cheevos_var_patch_addr(&var, cheevos_get_console());
|
|
|
|
|
|
|
|
data = cheevos_var_get_memory(&var);
|
|
|
|
}
|
2016-06-04 15:41:14 +00:00
|
|
|
|
2017-09-28 07:17:58 +00:00
|
|
|
if (data)
|
2016-06-04 15:41:14 +00:00
|
|
|
{
|
2017-09-28 07:17:58 +00:00
|
|
|
while (*arg)
|
|
|
|
{
|
|
|
|
*data = strtoul(arg, (char**)&arg, 16);
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
return true;
|
2016-06-04 15:41:14 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 07:17:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-01-02 05:40:19 +00:00
|
|
|
#endif
|
2016-02-13 06:19:21 +00:00
|
|
|
|
2019-02-22 15:27:46 +00:00
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND)
|
2014-09-02 03:10:54 +00:00
|
|
|
static bool command_get_arg(const char *tok,
|
|
|
|
const char **arg, unsigned *index)
|
2012-05-27 12:12:29 +00:00
|
|
|
{
|
2013-10-22 19:26:33 +00:00
|
|
|
unsigned i;
|
2014-08-02 23:38:49 +00:00
|
|
|
|
2013-10-22 19:26:33 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
2012-05-27 12:12:29 +00:00
|
|
|
{
|
2016-01-20 04:21:52 +00:00
|
|
|
if (string_is_equal(tok, map[i].str))
|
2012-05-27 12:12:29 +00:00
|
|
|
{
|
2012-09-21 19:56:54 +00:00
|
|
|
if (arg)
|
|
|
|
*arg = NULL;
|
|
|
|
|
|
|
|
if (index)
|
|
|
|
*index = i;
|
|
|
|
|
|
|
|
return true;
|
2012-05-27 12:12:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-22 19:26:33 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(action_map); i++)
|
2012-09-21 19:56:54 +00:00
|
|
|
{
|
|
|
|
const char *str = strstr(tok, action_map[i].str);
|
|
|
|
if (str == tok)
|
|
|
|
{
|
|
|
|
const char *argument = str + strlen(action_map[i].str);
|
2018-07-29 13:15:29 +00:00
|
|
|
if (*argument != ' ' && *argument != '\0')
|
2012-09-21 19:56:54 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (arg)
|
|
|
|
*arg = argument + 1;
|
|
|
|
|
|
|
|
if (index)
|
|
|
|
*index = i;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-11 17:37:56 +00:00
|
|
|
static bool command_network_init(command_t *handle, uint16_t port)
|
|
|
|
{
|
|
|
|
struct addrinfo *res = NULL;
|
2017-05-15 03:32:23 +00:00
|
|
|
int fd = socket_init((void**)&res, port,
|
|
|
|
NULL, SOCKET_TYPE_DATAGRAM);
|
2016-05-11 17:37:56 +00:00
|
|
|
|
2016-08-22 00:38:19 +00:00
|
|
|
RARCH_LOG("%s %hu.\n",
|
2016-10-22 22:49:36 +00:00
|
|
|
msg_hash_to_str(MSG_BRINGING_UP_COMMAND_INTERFACE_ON_PORT),
|
2016-05-11 17:37:56 +00:00
|
|
|
(unsigned short)port);
|
|
|
|
|
|
|
|
if (fd < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
handle->net_fd = fd;
|
|
|
|
|
|
|
|
if (!socket_nonblock(handle->net_fd))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!socket_bind(handle->net_fd, (void*)res))
|
|
|
|
{
|
2016-10-20 16:23:34 +00:00
|
|
|
RARCH_ERR("%s.\n",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_BIND_SOCKET));
|
2016-05-11 17:37:56 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
freeaddrinfo_retro(res);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (res)
|
|
|
|
freeaddrinfo_retro(res);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-09 19:36:17 +00:00
|
|
|
static bool command_verify(const char *cmd)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (command_get_arg(cmd, NULL, NULL))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
RARCH_ERR("Command \"%s\" is not recognized by the program.\n", cmd);
|
|
|
|
RARCH_ERR("\tValid commands:\n");
|
|
|
|
for (i = 0; i < sizeof(map) / sizeof(map[0]); i++)
|
|
|
|
RARCH_ERR("\t\t%s\n", map[i].str);
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(action_map) / sizeof(action_map[0]); i++)
|
|
|
|
RARCH_ERR("\t\t%s %s\n", action_map[i].str, action_map[i].arg_desc);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-02 05:40:19 +00:00
|
|
|
static void command_parse_sub_msg(command_t *handle, const char *tok)
|
|
|
|
{
|
|
|
|
const char *arg = NULL;
|
|
|
|
unsigned index = 0;
|
|
|
|
|
|
|
|
if (command_get_arg(tok, &arg, &index))
|
|
|
|
{
|
|
|
|
if (arg)
|
|
|
|
{
|
|
|
|
if (!action_map[index].action(arg))
|
|
|
|
RARCH_ERR("Command \"%s\" failed.\n", arg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
handle->state[map[index].id] = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
RARCH_WARN("%s \"%s\" %s.\n",
|
|
|
|
msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND),
|
|
|
|
tok,
|
|
|
|
msg_hash_to_str(MSG_RECEIVED));
|
|
|
|
}
|
|
|
|
|
2017-09-28 07:19:43 +00:00
|
|
|
static void command_parse_msg(command_t *handle, char *buf, enum cmd_source_t source)
|
|
|
|
{
|
|
|
|
char *save = NULL;
|
|
|
|
const char *tok = strtok_r(buf, "\n", &save);
|
|
|
|
|
|
|
|
lastcmd_source = source;
|
|
|
|
|
|
|
|
while (tok)
|
|
|
|
{
|
|
|
|
command_parse_sub_msg(handle, tok);
|
|
|
|
tok = strtok_r(NULL, "\n", &save);
|
|
|
|
}
|
|
|
|
lastcmd_source = CMD_NONE;
|
|
|
|
}
|
|
|
|
|
2017-09-27 21:59:18 +00:00
|
|
|
static void command_network_poll(command_t *handle)
|
|
|
|
{
|
|
|
|
fd_set fds;
|
|
|
|
struct timeval tmp_tv = {0};
|
|
|
|
|
|
|
|
if (handle->net_fd < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
FD_ZERO(&fds);
|
|
|
|
FD_SET(handle->net_fd, &fds);
|
|
|
|
|
|
|
|
if (socket_select(handle->net_fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!FD_ISSET(handle->net_fd, &fds))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ssize_t ret;
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
|
|
|
|
lastcmd_net_fd = handle->net_fd;
|
|
|
|
lastcmd_net_source_len = sizeof(lastcmd_net_source);
|
|
|
|
ret = recvfrom(handle->net_fd, buf,
|
|
|
|
sizeof(buf) - 1, 0,
|
|
|
|
(struct sockaddr*)&lastcmd_net_source,
|
|
|
|
&lastcmd_net_source_len);
|
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
buf[ret] = '\0';
|
|
|
|
|
|
|
|
command_parse_msg(handle, buf, CMD_NETWORK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-05-09 19:36:17 +00:00
|
|
|
bool command_network_send(const char *cmd_)
|
|
|
|
{
|
2017-09-27 21:59:18 +00:00
|
|
|
#if defined(HAVE_COMMAND) && defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD)
|
2016-05-26 16:09:46 +00:00
|
|
|
bool ret = false;
|
2016-05-09 19:36:17 +00:00
|
|
|
char *command = NULL;
|
|
|
|
char *save = NULL;
|
|
|
|
const char *cmd = NULL;
|
|
|
|
const char *host = NULL;
|
|
|
|
const char *port_ = NULL;
|
|
|
|
uint16_t port = DEFAULT_NETWORK_CMD_PORT;
|
|
|
|
|
|
|
|
if (!network_init())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!(command = strdup(cmd_)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
cmd = strtok_r(command, ";", &save);
|
|
|
|
if (cmd)
|
|
|
|
host = strtok_r(NULL, ";", &save);
|
|
|
|
if (host)
|
|
|
|
port_ = strtok_r(NULL, ";", &save);
|
|
|
|
|
|
|
|
if (!host)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
host = "127.0.0.1";
|
|
|
|
#else
|
|
|
|
host = "localhost";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port_)
|
|
|
|
port = strtoul(port_, NULL, 0);
|
|
|
|
|
2016-05-26 16:09:46 +00:00
|
|
|
if (cmd)
|
|
|
|
{
|
|
|
|
RARCH_LOG("%s: \"%s\" to %s:%hu\n",
|
|
|
|
msg_hash_to_str(MSG_SENDING_COMMAND),
|
|
|
|
cmd, host, (unsigned short)port);
|
2016-05-09 19:36:17 +00:00
|
|
|
|
2017-05-20 12:28:18 +00:00
|
|
|
ret = command_verify(cmd) && udp_send_packet(host, port, cmd);
|
2016-05-26 16:09:46 +00:00
|
|
|
}
|
2016-05-09 19:36:17 +00:00
|
|
|
free(command);
|
|
|
|
|
2018-08-16 07:59:51 +00:00
|
|
|
if (ret)
|
|
|
|
return true;
|
2017-09-27 21:59:18 +00:00
|
|
|
#endif
|
2018-08-16 07:59:51 +00:00
|
|
|
return false;
|
2016-05-09 19:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_STDIN_CMD
|
|
|
|
static bool command_stdin_init(command_t *handle)
|
|
|
|
{
|
|
|
|
#ifndef _WIN32
|
2016-09-29 19:07:10 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-05-09 19:36:17 +00:00
|
|
|
if (!socket_nonblock(STDIN_FILENO))
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
handle->stdin_enable = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-20 14:32:57 +00:00
|
|
|
command_t *command_new(void)
|
2016-05-09 19:36:17 +00:00
|
|
|
{
|
|
|
|
command_t *handle = (command_t*)calloc(1, sizeof(*handle));
|
|
|
|
if (!handle)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool command_network_new(
|
|
|
|
command_t *handle,
|
|
|
|
bool stdin_enable,
|
|
|
|
bool network_enable,
|
|
|
|
uint16_t port)
|
|
|
|
{
|
|
|
|
if (!handle)
|
|
|
|
return false;
|
|
|
|
|
2017-09-28 21:35:07 +00:00
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND)
|
2016-05-09 19:36:17 +00:00
|
|
|
handle->net_fd = -1;
|
|
|
|
if (network_enable && !command_network_init(handle, port))
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDIN_CMD
|
|
|
|
handle->stdin_enable = stdin_enable;
|
|
|
|
if (stdin_enable && !command_stdin_init(handle))
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2018-10-04 14:24:10 +00:00
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND) || defined(HAVE_STDIN_CMD)
|
2016-05-09 19:36:17 +00:00
|
|
|
error:
|
|
|
|
command_free(handle);
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-07-24 00:47:28 +00:00
|
|
|
#ifdef HAVE_STDIN_CMD
|
2016-05-09 19:23:53 +00:00
|
|
|
static void command_stdin_poll(command_t *handle)
|
2012-07-24 00:47:28 +00:00
|
|
|
{
|
2014-08-02 23:38:49 +00:00
|
|
|
ptrdiff_t msg_len;
|
2016-10-22 03:05:07 +00:00
|
|
|
char *last_newline = NULL;
|
2017-09-30 15:34:28 +00:00
|
|
|
ssize_t ret = read_stdin(
|
|
|
|
handle->stdin_buf + handle->stdin_buf_ptr,
|
2014-09-02 03:10:54 +00:00
|
|
|
STDIN_BUF_SIZE - handle->stdin_buf_ptr - 1);
|
2017-09-30 15:34:28 +00:00
|
|
|
|
2012-07-24 00:47:28 +00:00
|
|
|
if (ret == 0)
|
|
|
|
return;
|
|
|
|
|
2017-09-30 15:34:28 +00:00
|
|
|
handle->stdin_buf_ptr += ret;
|
|
|
|
handle->stdin_buf[handle->stdin_buf_ptr] = '\0';
|
2012-07-24 00:47:28 +00:00
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
last_newline =
|
2017-09-30 15:34:28 +00:00
|
|
|
strrchr(handle->stdin_buf, '\n');
|
2014-08-02 23:38:49 +00:00
|
|
|
|
2012-07-24 00:47:28 +00:00
|
|
|
if (!last_newline)
|
2012-07-28 08:57:14 +00:00
|
|
|
{
|
2015-01-29 01:29:07 +00:00
|
|
|
/* We're receiving bogus data in pipe
|
2014-09-02 03:10:54 +00:00
|
|
|
* (no terminating newline), flush out the buffer. */
|
2012-07-28 08:57:14 +00:00
|
|
|
if (handle->stdin_buf_ptr + 1 >= STDIN_BUF_SIZE)
|
|
|
|
{
|
|
|
|
handle->stdin_buf_ptr = 0;
|
2017-09-30 15:34:28 +00:00
|
|
|
handle->stdin_buf[0] = '\0';
|
2012-07-28 08:57:14 +00:00
|
|
|
}
|
|
|
|
|
2012-07-24 00:47:28 +00:00
|
|
|
return;
|
2012-07-28 08:57:14 +00:00
|
|
|
}
|
2012-07-24 00:47:28 +00:00
|
|
|
|
|
|
|
*last_newline++ = '\0';
|
2017-09-30 15:34:28 +00:00
|
|
|
msg_len = last_newline - handle->stdin_buf;
|
2012-05-27 12:12:29 +00:00
|
|
|
|
2017-10-22 02:02:03 +00:00
|
|
|
#if defined(HAVE_NETWORKING)
|
2016-09-11 15:37:05 +00:00
|
|
|
command_parse_msg(handle, handle->stdin_buf, CMD_STDIN);
|
2017-10-22 02:02:03 +00:00
|
|
|
#endif
|
2012-07-24 00:47:28 +00:00
|
|
|
|
2014-09-02 03:10:54 +00:00
|
|
|
memmove(handle->stdin_buf, last_newline,
|
|
|
|
handle->stdin_buf_ptr - msg_len);
|
2012-07-24 00:47:28 +00:00
|
|
|
handle->stdin_buf_ptr -= msg_len;
|
|
|
|
}
|
|
|
|
#endif
|
2012-06-01 13:15:06 +00:00
|
|
|
|
2016-05-09 18:10:08 +00:00
|
|
|
bool command_poll(command_t *handle)
|
2016-02-13 06:19:21 +00:00
|
|
|
{
|
2017-11-21 11:04:47 +00:00
|
|
|
memset(handle->state, 0, sizeof(handle->state));
|
2017-09-28 07:17:58 +00:00
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND)
|
2016-05-09 19:23:53 +00:00
|
|
|
command_network_poll(handle);
|
2016-02-13 06:19:21 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDIN_CMD
|
2017-09-30 15:34:28 +00:00
|
|
|
if (handle->stdin_enable)
|
|
|
|
command_stdin_poll(handle);
|
2016-02-13 06:19:21 +00:00
|
|
|
#endif
|
2016-05-07 22:25:04 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-09 19:23:53 +00:00
|
|
|
bool command_get(command_handle_t *handle)
|
|
|
|
{
|
|
|
|
if (!handle || !handle->handle)
|
|
|
|
return false;
|
2016-09-05 15:35:27 +00:00
|
|
|
return handle->id < RARCH_BIND_LIST_END
|
2016-05-09 19:23:53 +00:00
|
|
|
&& handle->handle->state[handle->id];
|
|
|
|
}
|
|
|
|
|
2016-05-09 18:10:08 +00:00
|
|
|
bool command_set(command_handle_t *handle)
|
2016-05-07 22:25:04 +00:00
|
|
|
{
|
|
|
|
if (!handle || !handle->handle)
|
|
|
|
return false;
|
|
|
|
if (handle->id < RARCH_BIND_LIST_END)
|
|
|
|
handle->handle->state[handle->id] = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-09 18:10:08 +00:00
|
|
|
bool command_free(command_t *handle)
|
2016-05-07 22:25:04 +00:00
|
|
|
{
|
2017-09-28 07:17:58 +00:00
|
|
|
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND)
|
2016-05-07 22:25:04 +00:00
|
|
|
if (handle && handle->net_fd >= 0)
|
|
|
|
socket_close(handle->net_fd);
|
2016-02-13 06:19:21 +00:00
|
|
|
#endif
|
|
|
|
|
2016-05-07 22:25:04 +00:00
|
|
|
free(handle);
|
2016-02-13 06:19:21 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-07 22:25:04 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_disk_control_set_eject:
|
2016-05-09 18:30:47 +00:00
|
|
|
* @new_state : Eject or close the virtual drive tray.
|
|
|
|
* false (0) : Close
|
|
|
|
* true (1) : Eject
|
|
|
|
* @print_log : Show message onscreen.
|
|
|
|
*
|
|
|
|
* Ejects/closes of the virtual drive tray.
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_disk_control_set_eject(bool new_state, bool print_log)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2016-10-22 03:05:07 +00:00
|
|
|
char msg[128];
|
2016-05-09 18:30:47 +00:00
|
|
|
bool error = false;
|
|
|
|
const struct retro_disk_control_callback *control = NULL;
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *info = runloop_get_system_info();
|
2016-09-06 06:38:26 +00:00
|
|
|
|
2016-10-22 03:05:07 +00:00
|
|
|
msg[0] = '\0';
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
if (info)
|
|
|
|
control = (const struct retro_disk_control_callback*)&info->disk_control_cb;
|
|
|
|
|
|
|
|
if (!control || !control->get_num_images)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (control->set_eject_state(new_state))
|
|
|
|
snprintf(msg, sizeof(msg), "%s %s",
|
2016-09-05 15:35:27 +00:00
|
|
|
new_state ?
|
|
|
|
msg_hash_to_str(MSG_DISK_EJECTED) :
|
2016-06-27 06:19:39 +00:00
|
|
|
msg_hash_to_str(MSG_DISK_CLOSED),
|
2016-05-09 18:30:47 +00:00
|
|
|
msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
snprintf(msg, sizeof(msg), "%s %s %s",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO),
|
|
|
|
new_state ? "eject" : "close",
|
|
|
|
msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY));
|
|
|
|
}
|
|
|
|
|
2016-06-28 09:02:51 +00:00
|
|
|
if (!string_is_empty(msg))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
else
|
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
|
|
|
|
/* Only noise in menu. */
|
|
|
|
if (print_log)
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_disk_control_set_index:
|
2016-05-09 18:30:47 +00:00
|
|
|
* @idx : Index of disk to set as current.
|
|
|
|
*
|
|
|
|
* Sets current disk to @index.
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_disk_control_set_index(unsigned idx)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
unsigned num_disks;
|
2016-10-22 03:05:07 +00:00
|
|
|
char msg[128];
|
2016-05-09 18:30:47 +00:00
|
|
|
bool error = false;
|
|
|
|
const struct retro_disk_control_callback *control = NULL;
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *info = runloop_get_system_info();
|
2016-09-06 06:38:26 +00:00
|
|
|
|
2016-10-22 03:05:07 +00:00
|
|
|
msg[0] = '\0';
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
if (info)
|
|
|
|
control = (const struct retro_disk_control_callback*)&info->disk_control_cb;
|
|
|
|
|
|
|
|
if (!control || !control->get_num_images)
|
|
|
|
return;
|
|
|
|
|
|
|
|
num_disks = control->get_num_images();
|
|
|
|
|
|
|
|
if (control->set_image_index(idx))
|
|
|
|
{
|
|
|
|
if (idx < num_disks)
|
2016-10-22 03:05:07 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s: %u/%u.",
|
|
|
|
msg_hash_to_str(MSG_SETTING_DISK_IN_TRAY),
|
2016-05-09 18:30:47 +00:00
|
|
|
idx + 1, num_disks);
|
|
|
|
else
|
|
|
|
strlcpy(msg,
|
|
|
|
msg_hash_to_str(MSG_REMOVED_DISK_FROM_TRAY),
|
|
|
|
sizeof(msg));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (idx < num_disks)
|
2016-10-22 03:05:07 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s %u/%u.",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_SET_DISK),
|
2016-05-09 18:30:47 +00:00
|
|
|
idx + 1, num_disks);
|
|
|
|
else
|
|
|
|
strlcpy(msg,
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_REMOVE_DISK_FROM_TRAY),
|
|
|
|
sizeof(msg));
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
|
2016-06-28 09:02:51 +00:00
|
|
|
if (!string_is_empty(msg))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
else
|
|
|
|
RARCH_LOG("%s\n", msg);
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_disk_control_append_image:
|
2016-05-09 18:30:47 +00:00
|
|
|
* @path : Path to disk image.
|
|
|
|
*
|
|
|
|
* Appends disk image to disk image list.
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static bool command_event_disk_control_append_image(const char *path)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
unsigned new_idx;
|
2016-10-22 03:05:07 +00:00
|
|
|
char msg[128];
|
2016-05-09 18:30:47 +00:00
|
|
|
struct retro_game_info info = {0};
|
|
|
|
const struct retro_disk_control_callback *control = NULL;
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *sysinfo = runloop_get_system_info();
|
2016-09-06 06:38:26 +00:00
|
|
|
|
2016-10-22 03:05:07 +00:00
|
|
|
msg[0] = '\0';
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
if (sysinfo)
|
|
|
|
control = (const struct retro_disk_control_callback*)
|
|
|
|
&sysinfo->disk_control_cb;
|
|
|
|
|
|
|
|
if (!control)
|
|
|
|
return false;
|
|
|
|
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_disk_control_set_eject(true, false);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
control->add_image_index();
|
|
|
|
new_idx = control->get_num_images();
|
|
|
|
if (!new_idx)
|
|
|
|
return false;
|
|
|
|
new_idx--;
|
|
|
|
|
|
|
|
info.path = path;
|
|
|
|
control->replace_image_index(new_idx, &info);
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK));
|
|
|
|
strlcat(msg, path, sizeof(msg));
|
|
|
|
RARCH_LOG("%s\n", msg);
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 0, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
/* TODO: Need to figure out what to do with subsystems case. */
|
2016-09-30 02:43:16 +00:00
|
|
|
if (path_is_empty(RARCH_PATH_SUBSYSTEM))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
/* Update paths for our new image.
|
|
|
|
* If we actually use append_image, we assume that we
|
|
|
|
* started out in a single disk case, and that this way
|
|
|
|
* of doing it makes the most sense. */
|
2016-09-30 02:19:42 +00:00
|
|
|
path_set(RARCH_PATH_NAMES, path);
|
2016-09-17 10:25:26 +00:00
|
|
|
path_fill_names();
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_AUTOSAVE_INIT, NULL);
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_disk_control_set_index(new_idx);
|
|
|
|
command_event_disk_control_set_eject(false, false);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_check_disk_prev:
|
2016-05-09 18:30:47 +00:00
|
|
|
* @control : Handle to disk control handle.
|
|
|
|
*
|
|
|
|
* Perform disk cycle to previous index action (Core Disk Options).
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_check_disk_prev(
|
2016-05-09 18:30:47 +00:00
|
|
|
const struct retro_disk_control_callback *control)
|
|
|
|
{
|
|
|
|
unsigned num_disks = 0;
|
|
|
|
unsigned current = 0;
|
|
|
|
bool disk_prev_enable = false;
|
|
|
|
|
|
|
|
if (!control || !control->get_num_images)
|
|
|
|
return;
|
|
|
|
if (!control->get_image_index)
|
|
|
|
return;
|
|
|
|
|
|
|
|
num_disks = control->get_num_images();
|
|
|
|
current = control->get_image_index();
|
|
|
|
disk_prev_enable = num_disks && num_disks != UINT_MAX;
|
|
|
|
|
|
|
|
if (!disk_prev_enable)
|
|
|
|
{
|
|
|
|
RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current > 0)
|
|
|
|
current--;
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_disk_control_set_index(current);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_check_disk_next:
|
2016-05-09 18:30:47 +00:00
|
|
|
* @control : Handle to disk control handle.
|
|
|
|
*
|
|
|
|
* Perform disk cycle to next index action (Core Disk Options).
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_check_disk_next(
|
2016-05-09 18:30:47 +00:00
|
|
|
const struct retro_disk_control_callback *control)
|
|
|
|
{
|
|
|
|
unsigned num_disks = 0;
|
|
|
|
unsigned current = 0;
|
|
|
|
bool disk_next_enable = false;
|
|
|
|
|
|
|
|
if (!control || !control->get_num_images)
|
|
|
|
return;
|
|
|
|
if (!control->get_image_index)
|
|
|
|
return;
|
|
|
|
|
|
|
|
num_disks = control->get_num_images();
|
|
|
|
current = control->get_image_index();
|
|
|
|
disk_next_enable = num_disks && num_disks != UINT_MAX;
|
|
|
|
|
|
|
|
if (!disk_next_enable)
|
|
|
|
{
|
|
|
|
RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current < num_disks - 1)
|
|
|
|
current++;
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_disk_control_set_index(current);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_set_volume:
|
|
|
|
* @gain : amount of gain to be applied to current volume level.
|
|
|
|
*
|
|
|
|
* Adjusts the current audio volume level.
|
|
|
|
*
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_set_volume(float gain)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
char msg[128];
|
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 12:57:55 +00:00
|
|
|
float new_volume = settings->floats.audio_volume + gain;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-04-23 15:36:25 +00:00
|
|
|
new_volume = MAX(new_volume, -80.0f);
|
2017-04-23 15:51:06 +00:00
|
|
|
new_volume = MIN(new_volume, 12.0f);
|
2017-04-23 15:36:25 +00:00
|
|
|
|
2017-04-28 12:57:55 +00:00
|
|
|
configuration_set_float(settings, settings->floats.audio_volume, new_volume);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-10-28 14:09:52 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s: %.1f dB",
|
2016-10-22 03:05:07 +00:00
|
|
|
msg_hash_to_str(MSG_AUDIO_VOLUME),
|
2017-04-23 15:36:25 +00:00
|
|
|
new_volume);
|
2018-11-22 14:45:52 +00:00
|
|
|
|
2019-04-08 15:01:02 +00:00
|
|
|
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
|
|
|
if (!video_driver_has_widgets() || !menu_widgets_volume_update_and_show())
|
|
|
|
#endif
|
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2018-11-22 14:45:52 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
|
2017-06-08 20:24:51 +00:00
|
|
|
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, new_volume);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-08 20:58:43 +00:00
|
|
|
/**
|
|
|
|
* event_set_mixer_volume:
|
|
|
|
* @gain : amount of gain to be applied to current volume level.
|
|
|
|
*
|
|
|
|
* Adjusts the current audio volume level.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
static void command_event_set_mixer_volume(float gain)
|
|
|
|
{
|
|
|
|
char msg[128];
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
float new_volume = settings->floats.audio_mixer_volume + gain;
|
|
|
|
|
|
|
|
new_volume = MAX(new_volume, -80.0f);
|
|
|
|
new_volume = MIN(new_volume, 12.0f);
|
|
|
|
|
|
|
|
configuration_set_float(settings, settings->floats.audio_mixer_volume, new_volume);
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg), "%s: %.1f dB",
|
|
|
|
msg_hash_to_str(MSG_AUDIO_VOLUME),
|
|
|
|
new_volume);
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2017-06-08 20:58:43 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
|
|
|
|
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, new_volume);
|
|
|
|
}
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_init_controllers:
|
2016-05-09 18:30:47 +00:00
|
|
|
*
|
|
|
|
* Initialize libretro controllers.
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_init_controllers(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *info = runloop_get_system_info();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_USERS; i++)
|
|
|
|
{
|
|
|
|
retro_ctx_controller_info_t pad;
|
2017-04-23 15:36:25 +00:00
|
|
|
const char *ident = NULL;
|
|
|
|
bool set_controller = false;
|
2016-05-09 18:30:47 +00:00
|
|
|
const struct retro_controller_description *desc = NULL;
|
2017-04-25 15:14:46 +00:00
|
|
|
unsigned device = input_config_get_device(i);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-06-01 03:18:59 +00:00
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
if (i < info->ports.size)
|
|
|
|
desc = libretro_find_controller_description(
|
|
|
|
&info->ports.data[i], device);
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (desc)
|
|
|
|
ident = desc->desc;
|
|
|
|
|
|
|
|
if (!ident)
|
|
|
|
{
|
|
|
|
/* If we're trying to connect a completely unknown device,
|
|
|
|
* revert back to JOYPAD. */
|
|
|
|
|
|
|
|
if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE)
|
|
|
|
{
|
2017-04-25 15:14:46 +00:00
|
|
|
/* Do not fix device,
|
2016-05-09 18:30:47 +00:00
|
|
|
* because any use of dummy core will reset this,
|
|
|
|
* which is not a good idea. */
|
|
|
|
RARCH_WARN("Input device ID %u is unknown to this "
|
|
|
|
"libretro implementation. Using RETRO_DEVICE_JOYPAD.\n",
|
|
|
|
device);
|
|
|
|
device = RETRO_DEVICE_JOYPAD;
|
|
|
|
}
|
|
|
|
ident = "Joypad";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_NONE:
|
2016-08-22 00:38:19 +00:00
|
|
|
RARCH_LOG("%s %u.\n",
|
|
|
|
msg_hash_to_str(MSG_VALUE_DISCONNECTING_DEVICE_FROM_PORT),
|
|
|
|
i + 1);
|
2017-09-12 06:46:47 +00:00
|
|
|
set_controller = true;
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
2017-09-28 07:17:58 +00:00
|
|
|
/* Ideally these checks shouldn't be required but if we always
|
2017-12-12 07:55:31 +00:00
|
|
|
* call core_set_controller_port_device input won't work on
|
2017-09-28 07:17:58 +00:00
|
|
|
* cores that don't set port information properly */
|
2018-04-26 00:50:51 +00:00
|
|
|
if (info && info->ports.size != 0)
|
2017-09-12 06:58:21 +00:00
|
|
|
set_controller = true;
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Some cores do not properly range check port argument.
|
|
|
|
* This is broken behavior of course, but avoid breaking
|
|
|
|
* cores needlessly. */
|
2016-10-30 08:42:59 +00:00
|
|
|
RARCH_LOG("%s %u: %s (ID: %u).\n",
|
2017-09-12 06:46:47 +00:00
|
|
|
msg_hash_to_str(MSG_CONNECTING_TO_PORT),
|
|
|
|
device, ident, i+1);
|
|
|
|
set_controller = true;
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-08-18 05:10:05 +00:00
|
|
|
if (set_controller && info && i < info->ports.size)
|
2017-09-12 06:46:47 +00:00
|
|
|
{
|
|
|
|
pad.device = device;
|
|
|
|
pad.port = i;
|
|
|
|
core_set_controller_port_device(&pad);
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-11 15:04:22 +00:00
|
|
|
static void command_event_deinit_core(bool reinit)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove settings init and test */
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
settings->bools.cheevos_rcheevos_enable ? rcheevos_unload() : cheevos_unload();
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-22 22:10:35 +00:00
|
|
|
RARCH_LOG("Unloading game..\n");
|
2016-05-09 18:30:47 +00:00
|
|
|
core_unload_game();
|
2018-07-22 22:10:35 +00:00
|
|
|
RARCH_LOG("Unloading core..\n");
|
2016-05-09 18:30:47 +00:00
|
|
|
core_unload();
|
2018-07-22 22:10:35 +00:00
|
|
|
RARCH_LOG("Unloading core symbols..\n");
|
2016-07-23 05:06:32 +00:00
|
|
|
core_uninit_symbols();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (reinit)
|
2017-05-28 13:03:03 +00:00
|
|
|
driver_uninit(DRIVERS_CMD_ALL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-05-20 22:54:29 +00:00
|
|
|
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
|
2016-07-30 19:36:01 +00:00
|
|
|
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
|
2017-08-05 04:56:17 +00:00
|
|
|
command_event(CMD_EVENT_RESTORE_REMAPS, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-05-07 16:28:07 +00:00
|
|
|
static void command_event_init_cheats(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2018-08-07 21:34:46 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
bool allow_cheats = true;
|
2018-07-25 23:19:14 +00:00
|
|
|
|
2016-09-29 19:07:10 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-05-09 18:30:47 +00:00
|
|
|
allow_cheats &= !netplay_driver_ctl(
|
|
|
|
RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL);
|
|
|
|
#endif
|
|
|
|
allow_cheats &= !bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL);
|
|
|
|
|
|
|
|
if (!allow_cheats)
|
2017-05-07 16:28:07 +00:00
|
|
|
return;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2018-07-25 23:19:14 +00:00
|
|
|
cheat_manager_alloc_if_empty() ;
|
|
|
|
cheat_manager_load_game_specific_cheats() ;
|
2018-08-07 21:34:46 +00:00
|
|
|
|
|
|
|
if (settings != NULL && settings->bools.apply_cheats_after_load)
|
|
|
|
cheat_manager_apply_cheats();
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_load_auto_state(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
bool ret;
|
2017-09-09 03:26:14 +00:00
|
|
|
char msg[128] = {0};
|
|
|
|
char *savestate_name_auto = (char*)calloc(PATH_MAX_LENGTH,
|
|
|
|
sizeof(*savestate_name_auto));
|
|
|
|
size_t savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char);
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-10-01 06:18:23 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-12-10 04:04:39 +00:00
|
|
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove OR below */
|
|
|
|
if (cheevos_hardcore_active || rcheevos_hardcore_active)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-28 11:43:47 +00:00
|
|
|
if (!settings->bools.savestate_auto_load)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
if (global)
|
|
|
|
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
|
|
|
file_path_str(FILE_PATH_AUTO_EXTENSION),
|
2017-09-09 03:26:14 +00:00
|
|
|
savestate_name_auto_size);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-12-14 19:05:46 +00:00
|
|
|
if (!filestream_exists(savestate_name_auto))
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-10-02 08:03:35 +00:00
|
|
|
ret = content_load_state(savestate_name_auto, false, true);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-10-20 16:23:34 +00:00
|
|
|
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_FOUND_AUTO_SAVESTATE_IN),
|
|
|
|
savestate_name_auto);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-10-20 16:08:31 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s \"%s\" %s.",
|
|
|
|
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM),
|
2016-05-09 18:30:47 +00:00
|
|
|
savestate_name_auto, ret ? "succeeded" : "failed");
|
|
|
|
RARCH_LOG("%s\n", msg);
|
2017-12-12 07:55:31 +00:00
|
|
|
|
2017-09-09 03:26:14 +00:00
|
|
|
free(savestate_name_auto);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
free(savestate_name_auto);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 18:41:59 +00:00
|
|
|
static void command_event_set_savestate_auto_index(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2017-09-09 03:26:14 +00:00
|
|
|
char *state_dir = (char*)calloc(PATH_MAX_LENGTH, sizeof(*state_dir));
|
|
|
|
char *state_base = (char*)calloc(PATH_MAX_LENGTH, sizeof(*state_base));
|
|
|
|
size_t state_size = PATH_MAX_LENGTH * sizeof(char);
|
|
|
|
struct string_list *dir_list = NULL;
|
|
|
|
unsigned max_idx = 0;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-04-28 11:43:47 +00:00
|
|
|
if (!settings->bools.savestate_auto_index)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
if (global)
|
|
|
|
{
|
|
|
|
/* Find the file in the same directory as global->savestate_name
|
|
|
|
* with the largest numeral suffix.
|
|
|
|
*
|
|
|
|
* E.g. /foo/path/content.state, will try to find
|
|
|
|
* /foo/path/content.state%d, where %d is the largest number available.
|
|
|
|
*/
|
|
|
|
fill_pathname_basedir(state_dir, global->name.savestate,
|
2017-09-09 03:26:14 +00:00
|
|
|
state_size);
|
2017-01-25 14:51:57 +00:00
|
|
|
fill_pathname_base(state_base, global->name.savestate,
|
2017-09-09 03:26:14 +00:00
|
|
|
state_size);
|
2017-01-25 14:51:57 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
if (!dir_list)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
for (i = 0; i < dir_list->size; i++)
|
|
|
|
{
|
|
|
|
unsigned idx;
|
|
|
|
char elem_base[128] = {0};
|
|
|
|
const char *end = NULL;
|
|
|
|
const char *dir_elem = dir_list->elems[i].data;
|
|
|
|
|
|
|
|
fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
|
|
|
|
|
|
|
if (strstr(elem_base, state_base) != elem_base)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
end = dir_elem + strlen(dir_elem);
|
|
|
|
while ((end > dir_elem) && isdigit((int)end[-1]))
|
|
|
|
end--;
|
|
|
|
|
2017-02-26 09:33:03 +00:00
|
|
|
idx = (unsigned)strtoul(end, NULL, 0);
|
2016-05-09 18:30:47 +00:00
|
|
|
if (idx > max_idx)
|
|
|
|
max_idx = idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir_list_free(dir_list);
|
|
|
|
|
2017-04-28 17:12:48 +00:00
|
|
|
configuration_set_int(settings, settings->ints.state_slot, max_idx);
|
2017-04-23 15:36:25 +00:00
|
|
|
|
2016-08-22 11:41:11 +00:00
|
|
|
RARCH_LOG("%s: #%d\n",
|
2016-10-22 22:35:40 +00:00
|
|
|
msg_hash_to_str(MSG_FOUND_LAST_STATE_SLOT),
|
2017-04-23 15:36:25 +00:00
|
|
|
max_idx);
|
2017-09-09 03:26:14 +00:00
|
|
|
|
|
|
|
free(state_dir);
|
|
|
|
free(state_base);
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
free(state_dir);
|
|
|
|
free(state_base);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2018-02-11 15:04:22 +00:00
|
|
|
static bool event_init_content(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-01-25 14:44:21 +00:00
|
|
|
bool contentless = false;
|
2017-01-25 14:51:57 +00:00
|
|
|
bool is_inited = false;
|
2018-10-10 00:07:05 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2017-01-25 14:44:21 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
content_get_status(&contentless, &is_inited);
|
2017-01-25 14:44:21 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE, NULL);
|
|
|
|
|
|
|
|
/* No content to be loaded for dummy core,
|
|
|
|
* just successfully exit. */
|
|
|
|
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
|
|
|
return true;
|
|
|
|
|
2018-02-11 20:18:40 +00:00
|
|
|
content_set_subsystem_info();
|
|
|
|
|
2017-01-25 14:44:21 +00:00
|
|
|
if (!contentless)
|
2016-09-17 10:25:26 +00:00
|
|
|
path_fill_names();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (!content_init())
|
|
|
|
return false;
|
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
content_get_status(&contentless, &is_inited);
|
2017-01-25 14:44:21 +00:00
|
|
|
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_set_savestate_auto_index();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (event_load_save_files())
|
|
|
|
RARCH_LOG("%s.\n",
|
|
|
|
msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD));
|
|
|
|
|
2018-10-10 00:07:05 +00:00
|
|
|
/*
|
|
|
|
Since the operations are asynchronouse we can't guarantee users will not use auto_load_state to cheat on
|
|
|
|
achievements so we forbid auto_load_state from happening if cheevos_enable and cheevos_hardcode_mode_enable
|
|
|
|
are true
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CHEEVOS
|
|
|
|
if (!settings->bools.cheevos_enable || !settings->bools.cheevos_hardcore_mode_enable)
|
|
|
|
command_event_load_auto_state();
|
|
|
|
#else
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_load_auto_state();
|
2018-10-10 00:07:05 +00:00
|
|
|
#endif
|
|
|
|
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_BSV_MOVIE_INIT, NULL);
|
|
|
|
command_event(CMD_EVENT_NETPLAY_INIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-09 19:36:17 +00:00
|
|
|
static bool command_event_init_core(enum rarch_core_type *data)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
retro_ctx_environ_info_t info;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!core_init_symbols(data))
|
|
|
|
return false;
|
|
|
|
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SYSTEM_INFO_INIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
/* auto overrides: apply overrides */
|
2017-04-28 11:43:47 +00:00
|
|
|
if(settings->bools.auto_overrides_enable)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
if (config_load_override())
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
else
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 05:37:26 +00:00
|
|
|
/* Auto-shaders: apply shader preset files */
|
2017-04-28 11:43:47 +00:00
|
|
|
if(settings->bools.auto_shaders_enable)
|
2016-07-30 18:55:50 +00:00
|
|
|
config_load_shader_preset();
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/* reset video format to libretro's default */
|
|
|
|
video_driver_set_pixel_format(RETRO_PIXEL_FORMAT_0RGB1555);
|
|
|
|
|
|
|
|
info.env = rarch_environment_cb;
|
|
|
|
core_set_environment(&info);
|
|
|
|
|
|
|
|
/* Auto-remap: apply remap files */
|
2017-04-28 11:43:47 +00:00
|
|
|
if(settings->bools.auto_remaps_enable)
|
2016-05-09 18:30:47 +00:00
|
|
|
config_load_remap();
|
|
|
|
|
|
|
|
/* Per-core saves: reset redirection paths */
|
2017-05-15 02:36:48 +00:00
|
|
|
path_set_redirect();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (!core_init())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!event_init_content())
|
|
|
|
return false;
|
|
|
|
|
2017-04-28 19:03:04 +00:00
|
|
|
if (!core_load(settings->uints.input_poll_type_behavior))
|
2016-05-09 18:30:47 +00:00
|
|
|
return false;
|
|
|
|
|
2018-05-29 04:43:30 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_FRAME_LIMIT, NULL);
|
2019-02-12 05:32:01 +00:00
|
|
|
rarch_ctl(RARCH_CTL_CONTENT_RUNTIME_LOG_INIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-20 22:54:29 +00:00
|
|
|
static void command_event_disable_overrides(void)
|
|
|
|
{
|
2017-05-15 03:06:23 +00:00
|
|
|
if (!rarch_ctl(RARCH_CTL_IS_OVERRIDES_ACTIVE, NULL))
|
2016-09-23 01:50:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* reload the original config */
|
|
|
|
config_unload_override();
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2016-05-20 22:54:29 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 19:36:01 +00:00
|
|
|
static void command_event_restore_default_shader_preset(void)
|
|
|
|
{
|
2018-02-09 03:24:18 +00:00
|
|
|
retroarch_unset_shader_preset();
|
2016-07-30 19:36:01 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 04:56:17 +00:00
|
|
|
static void command_event_restore_remaps(void)
|
|
|
|
{
|
2018-08-15 01:38:52 +00:00
|
|
|
if (rarch_ctl(RARCH_CTL_IS_REMAPS_CORE_ACTIVE, NULL) ||
|
|
|
|
rarch_ctl(RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE, NULL) ||
|
2018-05-14 04:17:44 +00:00
|
|
|
rarch_ctl(RARCH_CTL_IS_REMAPS_GAME_ACTIVE, NULL))
|
2017-09-12 03:49:39 +00:00
|
|
|
input_remapping_set_defaults(true);
|
2017-08-05 04:56:17 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:36:17 +00:00
|
|
|
static bool command_event_save_auto_state(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-09-09 03:26:14 +00:00
|
|
|
bool ret = false;
|
|
|
|
bool contentless = false;
|
|
|
|
bool is_inited = false;
|
|
|
|
char *savestate_name_auto = (char*)
|
|
|
|
calloc(PATH_MAX_LENGTH, sizeof(*savestate_name_auto));
|
2017-12-12 07:55:31 +00:00
|
|
|
size_t
|
2017-09-09 03:26:14 +00:00
|
|
|
savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char);
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-04-28 11:43:47 +00:00
|
|
|
if (!settings || !settings->bools.savestate_auto_save)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-10-01 06:18:23 +00:00
|
|
|
if (!global)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2017-01-25 14:44:21 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
content_get_status(&contentless, &is_inited);
|
2017-01-25 14:44:21 +00:00
|
|
|
|
|
|
|
if (contentless)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove OR below */
|
|
|
|
if (cheevos_hardcore_active || rcheevos_hardcore_active)
|
2017-09-09 03:26:14 +00:00
|
|
|
goto error;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
|
2016-10-01 06:18:23 +00:00
|
|
|
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
2016-07-01 05:07:06 +00:00
|
|
|
file_path_str(FILE_PATH_AUTO_EXTENSION),
|
2017-09-09 03:26:14 +00:00
|
|
|
savestate_name_auto_size);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-10-04 21:58:05 +00:00
|
|
|
ret = content_save_state((const char*)savestate_name_auto, true, true);
|
2016-10-28 14:09:52 +00:00
|
|
|
RARCH_LOG("%s \"%s\" %s.\n",
|
2016-10-20 16:23:34 +00:00
|
|
|
msg_hash_to_str(MSG_AUTO_SAVE_STATE_TO),
|
|
|
|
savestate_name_auto, ret ?
|
2016-05-09 18:30:47 +00:00
|
|
|
"succeeded" : "failed");
|
|
|
|
|
2017-09-09 03:26:14 +00:00
|
|
|
free(savestate_name_auto);
|
2016-05-09 18:30:47 +00:00
|
|
|
return true;
|
2017-09-09 03:26:14 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
free(savestate_name_auto);
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-11-23 17:07:28 +00:00
|
|
|
static bool command_event_save_config(
|
|
|
|
const char *config_path,
|
2016-09-24 14:49:42 +00:00
|
|
|
char *s, size_t len)
|
|
|
|
{
|
2019-02-21 18:57:06 +00:00
|
|
|
char log[PATH_MAX_LENGTH];
|
2017-11-23 17:07:28 +00:00
|
|
|
bool path_exists = !string_is_empty(config_path);
|
2017-12-12 07:55:31 +00:00
|
|
|
const char *str = path_exists ? config_path :
|
2017-11-23 17:07:28 +00:00
|
|
|
path_get(RARCH_PATH_CONFIG);
|
2017-11-21 18:22:44 +00:00
|
|
|
|
2017-11-23 17:07:28 +00:00
|
|
|
if (path_exists && config_save_file(config_path))
|
|
|
|
{
|
2019-02-21 18:57:06 +00:00
|
|
|
snprintf(s, len, "%s \"%s\".",
|
2017-11-23 17:07:28 +00:00
|
|
|
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
|
|
|
config_path);
|
2019-02-21 18:57:06 +00:00
|
|
|
snprintf(log, PATH_MAX_LENGTH, "[config] %s", s);
|
|
|
|
RARCH_LOG("%s\n", log);
|
2017-11-23 17:07:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-12-27 02:19:07 +00:00
|
|
|
|
2017-11-23 17:07:28 +00:00
|
|
|
if (!string_is_empty(str))
|
|
|
|
{
|
|
|
|
snprintf(s, len, "%s \"%s\".",
|
|
|
|
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
|
|
|
|
str);
|
2019-02-21 18:57:06 +00:00
|
|
|
snprintf(log, PATH_MAX_LENGTH, "[config] %s", s);
|
|
|
|
RARCH_ERR("%s\n", log);
|
2016-09-24 14:49:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-23 17:07:28 +00:00
|
|
|
return false;
|
2016-09-24 14:49:42 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/**
|
2016-05-09 18:41:59 +00:00
|
|
|
* command_event_save_core_config:
|
2016-05-09 18:30:47 +00:00
|
|
|
*
|
|
|
|
* Saves a new (core) configuration to a file. Filename is based
|
|
|
|
* on heuristics to avoid typing.
|
|
|
|
*
|
|
|
|
* Returns: true (1) on success, otherwise false (0).
|
|
|
|
**/
|
2016-05-09 18:41:59 +00:00
|
|
|
static bool command_event_save_core_config(void)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-01-25 14:44:21 +00:00
|
|
|
char msg[128];
|
2017-09-09 03:26:14 +00:00
|
|
|
bool found_path = false;
|
|
|
|
bool overrides_active = false;
|
2017-11-24 05:40:13 +00:00
|
|
|
const char *core_path = NULL;
|
2018-02-04 22:02:52 +00:00
|
|
|
char *config_name = NULL;
|
|
|
|
char *config_path = NULL;
|
2018-02-05 13:34:54 +00:00
|
|
|
char *config_dir = NULL;
|
2017-09-09 03:26:14 +00:00
|
|
|
size_t config_size = PATH_MAX_LENGTH * sizeof(char);
|
|
|
|
settings_t *settings = config_get_ptr();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2018-02-05 13:34:54 +00:00
|
|
|
msg[0] = '\0';
|
2017-01-25 14:44:21 +00:00
|
|
|
|
2018-02-04 22:02:52 +00:00
|
|
|
if (settings && !string_is_empty(settings->paths.directory_menu_config))
|
2018-02-05 13:34:54 +00:00
|
|
|
config_dir = strdup(settings->paths.directory_menu_config);
|
2016-09-30 02:43:16 +00:00
|
|
|
else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */
|
2018-02-05 13:34:54 +00:00
|
|
|
{
|
|
|
|
config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
|
|
|
config_dir[0] = '\0';
|
2016-09-29 06:31:41 +00:00
|
|
|
fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG),
|
2017-09-09 03:26:14 +00:00
|
|
|
config_size);
|
2018-02-05 13:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (string_is_empty(config_dir))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2019-02-21 18:57:06 +00:00
|
|
|
RARCH_ERR("[config] %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
|
2018-02-09 03:24:18 +00:00
|
|
|
free (config_dir);
|
2018-02-04 22:02:52 +00:00
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2018-02-04 22:02:52 +00:00
|
|
|
core_path = path_get(RARCH_PATH_CORE);
|
|
|
|
config_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
|
|
|
config_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
|
|
|
config_name[0] = '\0';
|
|
|
|
config_path[0] = '\0';
|
2017-11-24 05:40:13 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/* Infer file name based on libretro core. */
|
2017-12-14 19:05:46 +00:00
|
|
|
if (!string_is_empty(core_path) && filestream_exists(core_path))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
2016-07-01 05:28:46 +00:00
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG));
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/* In case of collision, find an alternative name. */
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
2016-06-28 11:13:36 +00:00
|
|
|
char tmp[64] = {0};
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-06-28 11:13:36 +00:00
|
|
|
fill_pathname_base_noext(
|
2016-05-09 18:30:47 +00:00
|
|
|
config_name,
|
2017-11-24 05:40:13 +00:00
|
|
|
core_path,
|
2017-09-09 03:26:14 +00:00
|
|
|
config_size);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
fill_pathname_join(config_path, config_dir, config_name,
|
2017-09-09 03:26:14 +00:00
|
|
|
config_size);
|
2016-06-28 11:13:36 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
if (i)
|
2016-06-27 06:19:39 +00:00
|
|
|
snprintf(tmp, sizeof(tmp), "-%u%s",
|
|
|
|
i,
|
|
|
|
file_path_str(FILE_PATH_CONFIG_EXTENSION));
|
2016-05-09 18:30:47 +00:00
|
|
|
else
|
2016-06-27 06:19:39 +00:00
|
|
|
strlcpy(tmp,
|
|
|
|
file_path_str(FILE_PATH_CONFIG_EXTENSION),
|
|
|
|
sizeof(tmp));
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-09-09 03:26:14 +00:00
|
|
|
strlcat(config_path, tmp, config_size);
|
2017-12-14 19:05:46 +00:00
|
|
|
if (!filestream_exists(config_path))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
found_path = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found_path)
|
|
|
|
{
|
2016-07-01 05:28:46 +00:00
|
|
|
/* Fallback to system time... */
|
2019-02-21 18:57:06 +00:00
|
|
|
RARCH_WARN("[config] %s\n",
|
2016-07-01 05:28:46 +00:00
|
|
|
msg_hash_to_str(MSG_CANNOT_INFER_NEW_CONFIG_PATH));
|
2016-06-27 06:19:39 +00:00
|
|
|
fill_dated_filename(config_name,
|
|
|
|
file_path_str(FILE_PATH_CONFIG_EXTENSION),
|
2017-09-09 03:26:14 +00:00
|
|
|
config_size);
|
2016-05-09 18:30:47 +00:00
|
|
|
fill_pathname_join(config_path, config_dir, config_name,
|
2017-09-09 03:26:14 +00:00
|
|
|
config_size);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-05-15 03:06:23 +00:00
|
|
|
if (rarch_ctl(RARCH_CTL_IS_OVERRIDES_ACTIVE, NULL))
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2016-09-05 15:35:27 +00:00
|
|
|
/* Overrides block config file saving,
|
|
|
|
* make it appear as overrides weren't enabled
|
2016-07-01 05:28:46 +00:00
|
|
|
* for a manual save. */
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
overrides_active = true;
|
|
|
|
}
|
|
|
|
|
2016-09-24 14:49:42 +00:00
|
|
|
command_event_save_config(config_path, msg, sizeof(msg));
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-11-21 18:22:44 +00:00
|
|
|
if (!string_is_empty(msg))
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (overrides_active)
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
else
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2017-09-09 03:26:14 +00:00
|
|
|
|
|
|
|
free(config_dir);
|
|
|
|
free(config_name);
|
|
|
|
free(config_path);
|
2018-07-15 03:58:01 +00:00
|
|
|
return true;
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_save_current_config:
|
|
|
|
*
|
|
|
|
* Saves current configuration file to disk, and (optionally)
|
|
|
|
* autosave state.
|
|
|
|
**/
|
2017-01-01 04:36:18 +00:00
|
|
|
static void command_event_save_current_config(enum override_type type)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-01-25 14:44:21 +00:00
|
|
|
char msg[128];
|
|
|
|
|
|
|
|
msg[0] = '\0';
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-01-01 04:36:18 +00:00
|
|
|
switch (type)
|
2016-08-25 06:34:51 +00:00
|
|
|
{
|
2017-01-01 04:36:18 +00:00
|
|
|
case OVERRIDE_NONE:
|
2017-02-26 05:07:58 +00:00
|
|
|
if (path_is_empty(RARCH_PATH_CONFIG))
|
2019-02-21 18:57:06 +00:00
|
|
|
strlcpy(msg, "[config] Config directory not set, cannot save configuration.",
|
2017-02-26 05:07:58 +00:00
|
|
|
sizeof(msg));
|
|
|
|
else
|
2017-01-01 04:36:18 +00:00
|
|
|
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg));
|
|
|
|
break;
|
|
|
|
case OVERRIDE_GAME:
|
|
|
|
case OVERRIDE_CORE:
|
2018-05-14 04:17:44 +00:00
|
|
|
case OVERRIDE_CONTENT_DIR:
|
2017-01-01 04:36:18 +00:00
|
|
|
if (config_save_overrides(type))
|
|
|
|
{
|
|
|
|
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
|
2019-02-21 18:57:06 +00:00
|
|
|
RARCH_LOG("[config] [overrides] %s\n", msg);
|
2016-09-13 05:37:23 +00:00
|
|
|
|
2017-01-01 04:36:18 +00:00
|
|
|
/* set overrides to active so the original config can be
|
|
|
|
restored after closing content */
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
2017-01-01 04:36:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_SAVING), sizeof(msg));
|
2019-02-21 18:57:06 +00:00
|
|
|
RARCH_ERR("[config] [overrides] %s\n", msg);
|
2017-01-01 04:36:18 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-09-16 22:28:47 +00:00
|
|
|
}
|
2017-01-01 04:36:18 +00:00
|
|
|
|
2016-09-16 22:28:47 +00:00
|
|
|
if (!string_is_empty(msg))
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 19:27:54 +00:00
|
|
|
static void command_event_undo_save_state(char *s, size_t len)
|
|
|
|
{
|
2016-06-10 19:12:43 +00:00
|
|
|
if (content_undo_save_buf_is_empty())
|
|
|
|
{
|
2016-09-05 15:35:27 +00:00
|
|
|
strlcpy(s,
|
2016-07-01 05:28:46 +00:00
|
|
|
msg_hash_to_str(MSG_NO_SAVE_STATE_HAS_BEEN_OVERWRITTEN_YET), len);
|
2016-09-05 15:35:27 +00:00
|
|
|
return;
|
2016-06-10 19:12:43 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 19:27:54 +00:00
|
|
|
if (!content_undo_save_state())
|
2016-06-10 19:12:43 +00:00
|
|
|
return;
|
2016-06-08 19:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void command_event_undo_load_state(char *s, size_t len)
|
|
|
|
{
|
2016-09-05 15:35:27 +00:00
|
|
|
|
2016-06-10 19:12:43 +00:00
|
|
|
if (content_undo_load_buf_is_empty())
|
|
|
|
{
|
2016-09-05 15:35:27 +00:00
|
|
|
strlcpy(s,
|
2016-07-01 05:28:46 +00:00
|
|
|
msg_hash_to_str(MSG_NO_STATE_HAS_BEEN_LOADED_YET),
|
|
|
|
len);
|
2016-09-05 15:35:27 +00:00
|
|
|
return;
|
2016-06-10 19:12:43 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 19:27:54 +00:00
|
|
|
if (!content_undo_load_state())
|
|
|
|
{
|
|
|
|
snprintf(s, len, "%s \"%s\".",
|
2016-06-08 22:03:49 +00:00
|
|
|
msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE),
|
2016-06-08 23:38:27 +00:00
|
|
|
"RAM");
|
2016-06-10 19:12:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-29 19:07:10 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-09-17 15:24:23 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL);
|
|
|
|
#endif
|
|
|
|
|
2016-09-05 15:35:27 +00:00
|
|
|
strlcpy(s,
|
2016-07-01 05:28:46 +00:00
|
|
|
msg_hash_to_str(MSG_UNDID_LOAD_STATE), len);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-26 08:35:35 +00:00
|
|
|
static bool command_event_main_state(unsigned cmd)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
retro_ctx_size_info_t info;
|
2017-01-25 14:44:21 +00:00
|
|
|
char msg[128];
|
2018-10-04 14:24:10 +00:00
|
|
|
size_t state_path_size = 16384 * sizeof(char);
|
2018-09-28 19:42:09 +00:00
|
|
|
char *state_path = (char*)malloc(state_path_size);
|
2016-10-01 06:18:23 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2017-09-28 07:17:58 +00:00
|
|
|
bool ret = false;
|
2016-10-02 08:03:35 +00:00
|
|
|
bool push_msg = true;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-09-09 03:26:14 +00:00
|
|
|
state_path[0] = msg[0] = '\0';
|
2017-01-25 14:44:21 +00:00
|
|
|
|
|
|
|
if (global)
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 17:12:48 +00:00
|
|
|
int state_slot = settings->ints.state_slot;
|
2017-01-25 14:44:21 +00:00
|
|
|
|
2017-04-28 17:12:48 +00:00
|
|
|
if (state_slot > 0)
|
2017-09-09 03:26:14 +00:00
|
|
|
snprintf(state_path, state_path_size, "%s%d",
|
2017-04-28 17:12:48 +00:00
|
|
|
global->name.savestate, state_slot);
|
|
|
|
else if (state_slot < 0)
|
2017-09-09 03:26:14 +00:00
|
|
|
fill_pathname_join_delim(state_path,
|
|
|
|
global->name.savestate, "auto", '.', state_path_size);
|
2017-01-25 14:44:21 +00:00
|
|
|
else
|
2017-09-09 03:26:14 +00:00
|
|
|
strlcpy(state_path, global->name.savestate, state_path_size);
|
2017-01-25 14:44:21 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
core_serialize_size(&info);
|
|
|
|
|
|
|
|
if (info.size)
|
|
|
|
{
|
|
|
|
switch (cmd)
|
|
|
|
{
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SAVE_STATE:
|
2017-09-09 03:26:14 +00:00
|
|
|
content_save_state(state_path, true, false);
|
2017-02-26 08:35:35 +00:00
|
|
|
ret = true;
|
2016-10-02 08:03:35 +00:00
|
|
|
push_msg = false;
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_LOAD_STATE:
|
2017-09-09 03:26:14 +00:00
|
|
|
if (content_load_state(state_path, false, false))
|
2016-10-03 01:30:34 +00:00
|
|
|
{
|
2018-09-21 04:20:38 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove duplication below */
|
|
|
|
rcheevos_state_loaded_flag = cheevos_state_loaded_flag = true;
|
2018-09-21 04:20:38 +00:00
|
|
|
#endif
|
2017-02-26 08:35:35 +00:00
|
|
|
ret = true;
|
2016-10-03 01:30:34 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
2016-10-02 08:03:35 +00:00
|
|
|
push_msg = false;
|
2016-06-03 04:33:52 +00:00
|
|
|
break;
|
|
|
|
case CMD_EVENT_UNDO_LOAD_STATE:
|
2016-06-08 19:27:54 +00:00
|
|
|
command_event_undo_load_state(msg, sizeof(msg));
|
2017-02-26 08:35:35 +00:00
|
|
|
ret = true;
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-06-04 19:34:06 +00:00
|
|
|
case CMD_EVENT_UNDO_SAVE_STATE:
|
2016-06-08 19:27:54 +00:00
|
|
|
command_event_undo_save_state(msg, sizeof(msg));
|
2017-02-26 08:35:35 +00:00
|
|
|
ret = true;
|
2016-06-04 19:34:06 +00:00
|
|
|
break;
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strlcpy(msg, msg_hash_to_str(
|
|
|
|
MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg));
|
|
|
|
|
2016-10-02 08:03:35 +00:00
|
|
|
if (push_msg)
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 2, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
2017-02-26 08:35:35 +00:00
|
|
|
|
2017-09-09 03:26:14 +00:00
|
|
|
free(state_path);
|
2017-02-26 08:35:35 +00:00
|
|
|
return ret;
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-25 00:11:18 +00:00
|
|
|
static bool command_event_resize_windowed_scale(void)
|
|
|
|
{
|
|
|
|
unsigned idx = 0;
|
|
|
|
unsigned *window_scale = NULL;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2017-05-15 03:06:23 +00:00
|
|
|
if (rarch_ctl(RARCH_CTL_GET_WINDOWED_SCALE, &window_scale))
|
2016-12-25 00:11:18 +00:00
|
|
|
{
|
|
|
|
if (!window_scale || *window_scale == 0)
|
|
|
|
return false;
|
|
|
|
|
2017-04-28 12:57:55 +00:00
|
|
|
configuration_set_float(settings, settings->floats.video_scale, *window_scale);
|
2016-12-25 00:11:18 +00:00
|
|
|
}
|
|
|
|
|
2017-04-27 22:53:06 +00:00
|
|
|
if (!settings->bools.video_fullscreen)
|
2016-12-25 00:11:18 +00:00
|
|
|
command_event(CMD_EVENT_REINIT, NULL);
|
|
|
|
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_WINDOWED_SCALE, &idx);
|
2016-12-25 00:11:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
/**
|
|
|
|
* command_event:
|
|
|
|
* @cmd : Event command index.
|
|
|
|
*
|
|
|
|
* Performs program event command with index @cmd.
|
|
|
|
*
|
|
|
|
* Returns: true (1) on success, otherwise false (0).
|
|
|
|
**/
|
|
|
|
bool command_event(enum event_command cmd, void *data)
|
|
|
|
{
|
2018-05-29 10:41:13 +00:00
|
|
|
bool boolean = false;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
switch (cmd)
|
|
|
|
{
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SET_PER_GAME_RESOLUTION:
|
2016-05-09 18:30:47 +00:00
|
|
|
#if defined(GEKKO)
|
|
|
|
{
|
|
|
|
unsigned width = 0, height = 0;
|
|
|
|
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (video_driver_get_video_output_size(&width, &height))
|
|
|
|
{
|
|
|
|
char msg[128] = {0};
|
|
|
|
|
|
|
|
video_driver_set_video_mode(width, height, true);
|
|
|
|
|
|
|
|
if (width == 0 || height == 0)
|
2016-10-28 14:09:52 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s: DEFAULT",
|
2016-10-20 16:23:34 +00:00
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION));
|
2016-05-09 18:30:47 +00:00
|
|
|
else
|
2016-10-20 16:23:34 +00:00
|
|
|
snprintf(msg, sizeof(msg),"%s: %dx%d",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION),
|
|
|
|
width, height);
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_LOAD_CORE_PERSIST:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_MENU
|
2017-05-28 15:21:57 +00:00
|
|
|
core_info_ctx_find_t info_find;
|
2017-11-26 21:38:12 +00:00
|
|
|
rarch_system_info_t *system_info = NULL;
|
|
|
|
struct retro_system_info *system = NULL;
|
|
|
|
const char *core_path = NULL;
|
2017-11-26 23:22:59 +00:00
|
|
|
system_info = runloop_get_system_info();
|
|
|
|
system = &system_info->info;
|
|
|
|
core_path = path_get(RARCH_PATH_CORE);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_DYNAMIC)
|
2017-11-24 05:40:13 +00:00
|
|
|
if (string_is_empty(core_path))
|
2017-05-28 15:21:57 +00:00
|
|
|
return false;
|
2016-09-12 16:16:42 +00:00
|
|
|
#endif
|
2017-11-24 05:40:13 +00:00
|
|
|
|
2018-04-30 18:33:05 +00:00
|
|
|
if (!libretro_get_system_info(
|
2017-11-24 05:40:13 +00:00
|
|
|
core_path,
|
2017-05-28 15:21:57 +00:00
|
|
|
system,
|
2018-04-30 18:33:05 +00:00
|
|
|
&system_info->load_no_content))
|
|
|
|
return false;
|
2017-11-24 05:40:13 +00:00
|
|
|
info_find.path = core_path;
|
2017-05-28 15:21:57 +00:00
|
|
|
|
|
|
|
if (!core_info_load(&info_find))
|
|
|
|
{
|
2016-09-11 19:03:31 +00:00
|
|
|
#ifdef HAVE_DYNAMIC
|
2017-05-28 15:21:57 +00:00
|
|
|
return false;
|
2016-09-11 19:03:31 +00:00
|
|
|
#endif
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_LOAD_CORE:
|
2018-04-30 18:33:05 +00:00
|
|
|
{
|
2019-02-07 00:01:11 +00:00
|
|
|
bool success = false;
|
2018-12-11 02:38:30 +00:00
|
|
|
subsystem_current_count = 0;
|
2018-10-30 02:23:53 +00:00
|
|
|
content_clear_subsystem();
|
2018-11-28 10:03:52 +00:00
|
|
|
success = command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL);
|
2018-09-15 05:19:51 +00:00
|
|
|
(void)success;
|
2018-04-30 18:33:05 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifndef HAVE_DYNAMIC
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_QUIT, NULL);
|
2018-04-30 18:33:05 +00:00
|
|
|
#else
|
|
|
|
if (!success)
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2018-04-30 18:33:05 +00:00
|
|
|
}
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_LOAD_STATE:
|
2017-05-30 00:58:59 +00:00
|
|
|
/* Immutable - disallow savestate load when
|
|
|
|
* we absolutely cannot change game state. */
|
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove OR below */
|
|
|
|
if (cheevos_hardcore_active || rcheevos_hardcore_active)
|
2018-05-13 22:30:30 +00:00
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!command_event_main_state(cmd))
|
|
|
|
return false;
|
|
|
|
break;
|
2016-06-03 04:33:52 +00:00
|
|
|
case CMD_EVENT_UNDO_LOAD_STATE:
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!command_event_main_state(cmd))
|
|
|
|
return false;
|
|
|
|
break;
|
2016-06-04 19:34:06 +00:00
|
|
|
case CMD_EVENT_UNDO_SAVE_STATE:
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!command_event_main_state(cmd))
|
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RESIZE_WINDOWED_SCALE:
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!command_event_resize_windowed_scale())
|
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_MENU_TOGGLE:
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_MENU
|
2017-01-22 23:37:39 +00:00
|
|
|
if (menu_driver_is_alive())
|
2017-05-15 02:31:40 +00:00
|
|
|
rarch_menu_running_finished();
|
2016-05-09 18:30:47 +00:00
|
|
|
else
|
2017-05-15 02:31:40 +00:00
|
|
|
rarch_menu_running();
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CONTROLLERS_INIT:
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_init_controllers();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RESET:
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove starting block bracket, settings init and tests */
|
|
|
|
{
|
2018-09-23 10:25:31 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
rcheevos_state_loaded_flag = cheevos_state_loaded_flag = false;
|
|
|
|
rcheevos_hardcore_paused = cheevos_hardcore_paused = false;
|
2018-09-23 10:25:31 +00:00
|
|
|
#endif
|
2019-03-17 01:13:57 +00:00
|
|
|
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET));
|
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
settings->bools.cheevos_rcheevos_enable ? rcheevos_set_cheats() : cheevos_set_cheats();
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2019-03-17 01:13:57 +00:00
|
|
|
core_reset();
|
2017-01-23 13:50:00 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
settings->bools.cheevos_rcheevos_enable ? rcheevos_reset_game() : cheevos_reset_game();
|
2017-02-15 19:40:37 +00:00
|
|
|
#endif
|
|
|
|
#if HAVE_NETWORKING
|
2019-03-17 01:13:57 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL);
|
2017-01-23 13:50:00 +00:00
|
|
|
#endif
|
2019-03-17 01:13:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SAVE_STATE:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove OR below */
|
|
|
|
if (cheevos_hardcore_active || rcheevos_hardcore_active)
|
2016-12-25 00:28:16 +00:00
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-28 11:43:47 +00:00
|
|
|
if (settings->bools.savestate_auto_index)
|
2017-04-23 15:36:25 +00:00
|
|
|
{
|
2017-04-28 17:12:48 +00:00
|
|
|
int new_state_slot = settings->ints.state_slot + 1;
|
|
|
|
configuration_set_int(settings, settings->ints.state_slot, new_state_slot);
|
2017-04-23 15:36:25 +00:00
|
|
|
}
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!command_event_main_state(cmd))
|
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SAVE_STATE_DECREMENT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
/* Slot -1 is (auto) slot. */
|
2017-04-28 17:12:48 +00:00
|
|
|
if (settings->ints.state_slot >= 0)
|
2017-04-23 15:36:25 +00:00
|
|
|
{
|
2017-04-28 17:12:48 +00:00
|
|
|
int new_state_slot = settings->ints.state_slot - 1;
|
|
|
|
configuration_set_int(settings, settings->ints.state_slot, new_state_slot);
|
2017-04-23 15:36:25 +00:00
|
|
|
}
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SAVE_STATE_INCREMENT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 17:12:48 +00:00
|
|
|
int new_state_slot = settings->ints.state_slot + 1;
|
|
|
|
configuration_set_int(settings, settings->ints.state_slot, new_state_slot);
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_TAKE_SCREENSHOT:
|
2017-05-13 17:37:16 +00:00
|
|
|
if (!take_screenshot(path_get(RARCH_PATH_BASENAME), false,
|
2018-08-19 03:08:55 +00:00
|
|
|
video_driver_cached_frame_has_valid_framebuffer(), false, true))
|
2016-05-09 18:30:47 +00:00
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_UNLOAD_CORE:
|
2016-12-25 00:24:17 +00:00
|
|
|
{
|
2017-01-25 14:51:57 +00:00
|
|
|
bool contentless = false;
|
|
|
|
bool is_inited = false;
|
2016-12-25 00:24:17 +00:00
|
|
|
content_ctx_info_t content_info = {0};
|
2017-01-25 14:51:57 +00:00
|
|
|
|
|
|
|
content_get_status(&contentless, &is_inited);
|
|
|
|
|
2019-02-21 15:48:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_CONTENT_RUNTIME_LOG_DEINIT, NULL);
|
2016-12-25 00:24:17 +00:00
|
|
|
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
|
|
|
|
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
|
|
|
|
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
|
2017-08-05 04:56:17 +00:00
|
|
|
command_event(CMD_EVENT_RESTORE_REMAPS, NULL);
|
2016-12-25 00:24:17 +00:00
|
|
|
|
2017-01-25 14:51:57 +00:00
|
|
|
if (is_inited)
|
2018-10-30 02:23:53 +00:00
|
|
|
{
|
2017-02-21 15:50:39 +00:00
|
|
|
if (!task_push_start_dummy_core(&content_info))
|
2016-12-25 00:24:17 +00:00
|
|
|
return false;
|
2018-10-30 02:23:53 +00:00
|
|
|
}
|
2018-09-09 21:41:50 +00:00
|
|
|
#ifdef HAVE_DISCORD
|
|
|
|
if (discord_is_inited)
|
|
|
|
{
|
|
|
|
discord_userdata_t userdata;
|
2019-02-07 00:01:11 +00:00
|
|
|
userdata.status = DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED;
|
|
|
|
command_event(CMD_EVENT_DISCORD_UPDATE, &userdata);
|
2018-09-09 21:41:50 +00:00
|
|
|
userdata.status = DISCORD_PRESENCE_MENU;
|
|
|
|
command_event(CMD_EVENT_DISCORD_UPDATE, &userdata);
|
|
|
|
}
|
2019-02-07 00:01:11 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_DYNAMIC
|
|
|
|
path_clear(RARCH_PATH_CORE);
|
|
|
|
rarch_ctl(RARCH_CTL_SYSTEM_INFO_FREE, NULL);
|
2018-09-09 21:41:50 +00:00
|
|
|
#endif
|
2018-10-30 02:23:53 +00:00
|
|
|
if (is_inited)
|
|
|
|
{
|
2018-12-11 02:38:30 +00:00
|
|
|
subsystem_current_count = 0;
|
2018-10-30 02:23:53 +00:00
|
|
|
content_clear_subsystem();
|
|
|
|
}
|
2016-12-25 00:24:17 +00:00
|
|
|
}
|
2016-09-05 16:46:28 +00:00
|
|
|
break;
|
2016-09-05 15:35:27 +00:00
|
|
|
case CMD_EVENT_QUIT:
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!retroarch_main_quit())
|
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE:
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove starting block bracket, settings init and test */
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
settings->bools.cheevos_rcheevos_enable ? rcheevos_toggle_hardcore_mode() : cheevos_toggle_hardcore_mode();
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2018-04-30 18:33:05 +00:00
|
|
|
/* this fallthrough is on purpose, it should do
|
2017-12-17 17:56:26 +00:00
|
|
|
a CMD_EVENT_REINIT too */
|
|
|
|
case CMD_EVENT_REINIT_FROM_TOGGLE:
|
|
|
|
retroarch_unset_forced_fullscreen();
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REINIT:
|
2018-05-29 10:41:13 +00:00
|
|
|
video_driver_reinit();
|
2017-12-29 22:03:25 +00:00
|
|
|
{
|
2018-05-29 10:41:13 +00:00
|
|
|
const input_driver_t *input_drv = input_get_ptr();
|
|
|
|
void *input_data = input_get_data();
|
|
|
|
/* Poll input to avoid possibly stale data to corrupt things. */
|
|
|
|
if (input_drv && input_drv->poll)
|
|
|
|
input_drv->poll(input_data);
|
|
|
|
}
|
|
|
|
command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, (void*)(intptr_t)-1);
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_MENU
|
2018-05-29 10:41:13 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2017-12-29 22:03:25 +00:00
|
|
|
menu_display_set_framebuffer_dirty_flag();
|
2018-01-03 09:51:21 +00:00
|
|
|
if (settings->bools.video_fullscreen)
|
|
|
|
video_driver_hide_mouse();
|
|
|
|
|
2017-12-29 22:03:25 +00:00
|
|
|
if (menu_driver_is_alive())
|
|
|
|
command_event(CMD_EVENT_VIDEO_SET_BLOCKING_STATE, NULL);
|
|
|
|
}
|
2018-05-29 10:41:13 +00:00
|
|
|
#endif
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CHEATS_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
cheat_manager_state_free();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CHEATS_INIT:
|
|
|
|
command_event(CMD_EVENT_CHEATS_DEINIT, NULL);
|
2017-05-07 16:28:07 +00:00
|
|
|
command_event_init_cheats();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CHEATS_APPLY:
|
2016-05-09 18:30:47 +00:00
|
|
|
cheat_manager_apply_cheats();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REWIND_DEINIT:
|
2016-12-25 18:28:26 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove OR below */
|
|
|
|
if (cheevos_hardcore_active || rcheevos_hardcore_active)
|
2018-05-13 22:30:30 +00:00
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2018-05-13 22:30:30 +00:00
|
|
|
state_manager_event_deinit();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REWIND_INIT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2016-12-25 18:28:26 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2017-01-09 01:49:39 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2019-03-17 01:13:57 +00:00
|
|
|
/* RCHEEVOS TODO: remove OR below */
|
|
|
|
if (cheevos_hardcore_active || rcheevos_hardcore_active)
|
2016-12-25 00:28:16 +00:00
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2017-08-12 14:47:13 +00:00
|
|
|
if (settings->bools.rewind_enable)
|
|
|
|
{
|
2017-07-11 02:51:56 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2017-08-13 00:50:19 +00:00
|
|
|
/* Only enable state manager if netplay is not underway
|
2017-08-12 14:47:13 +00:00
|
|
|
TODO: Add a setting for these tweaks */
|
|
|
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
2017-07-11 02:51:56 +00:00
|
|
|
#endif
|
2017-08-12 14:47:13 +00:00
|
|
|
{
|
2018-07-13 20:12:09 +00:00
|
|
|
state_manager_event_init((unsigned)settings->sizes.rewind_buffer_size);
|
2017-08-12 14:47:13 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REWIND_TOGGLE:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 11:43:47 +00:00
|
|
|
if (settings->bools.rewind_enable)
|
2016-12-25 00:28:16 +00:00
|
|
|
command_event(CMD_EVENT_REWIND_INIT, NULL);
|
|
|
|
else
|
|
|
|
command_event(CMD_EVENT_REWIND_DEINIT, NULL);
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUTOSAVE_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2016-09-28 05:17:14 +00:00
|
|
|
if (!rarch_ctl(RARCH_CTL_IS_SRAM_USED, NULL))
|
|
|
|
return false;
|
|
|
|
autosave_deinit();
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUTOSAVE_INIT:
|
|
|
|
command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2018-04-30 18:33:05 +00:00
|
|
|
{
|
2017-07-11 03:44:16 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2017-08-01 16:25:08 +00:00
|
|
|
/* Only enable state manager if netplay is not underway
|
2017-07-11 03:44:16 +00:00
|
|
|
TODO: Add a setting for these tweaks */
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
if (settings->uints.autosave_interval != 0
|
|
|
|
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (autosave_init())
|
|
|
|
runloop_set(RUNLOOP_ACTION_AUTOSAVE);
|
|
|
|
else
|
|
|
|
runloop_unset(RUNLOOP_ACTION_AUTOSAVE);
|
|
|
|
}
|
2018-04-30 18:33:05 +00:00
|
|
|
}
|
2017-05-07 15:52:48 +00:00
|
|
|
#endif
|
2017-05-07 20:44:07 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUTOSAVE_STATE:
|
2016-05-09 19:36:17 +00:00
|
|
|
command_event_save_auto_state();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUDIO_STOP:
|
2018-06-04 05:48:08 +00:00
|
|
|
midi_driver_set_all_sounds_off();
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!audio_driver_stop())
|
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUDIO_START:
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!audio_driver_start(rarch_ctl(RARCH_CTL_IS_SHUTDOWN, NULL)))
|
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUDIO_MUTE_TOGGLE:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-05-08 19:39:08 +00:00
|
|
|
bool audio_mute_enable = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE));
|
|
|
|
const char *msg = !audio_mute_enable ?
|
2016-05-09 18:30:47 +00:00
|
|
|
msg_hash_to_str(MSG_AUDIO_MUTED):
|
|
|
|
msg_hash_to_str(MSG_AUDIO_UNMUTED);
|
|
|
|
|
|
|
|
if (!audio_driver_toggle_mute())
|
|
|
|
{
|
|
|
|
RARCH_ERR("%s.\n",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-08 15:01:02 +00:00
|
|
|
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
|
|
|
if (!video_driver_has_widgets() || !menu_widgets_volume_update_and_show())
|
|
|
|
#endif
|
|
|
|
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2018-11-22 14:45:52 +00:00
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-03-09 21:03:17 +00:00
|
|
|
case CMD_EVENT_SEND_DEBUG_INFO:
|
|
|
|
rarch_send_debug_info();
|
|
|
|
break;
|
2018-11-29 12:12:11 +00:00
|
|
|
case CMD_EVENT_FPS_TOGGLE:
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
settings->bools.video_fps_show = !(settings->bools.video_fps_show);
|
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_OVERLAY_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2016-11-27 14:21:53 +00:00
|
|
|
input_overlay_free(overlay_ptr);
|
|
|
|
overlay_ptr = NULL;
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_OVERLAY_INIT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2019-02-15 15:50:25 +00:00
|
|
|
#if defined(GEKKO)
|
|
|
|
/* Avoid a crash at startup or even when toggling overlay in rgui */
|
|
|
|
uint64_t memory_used = frontend_driver_get_used_memory();
|
|
|
|
if(memory_used > (72 * 1024 * 1024))
|
|
|
|
break;
|
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2017-04-28 11:43:47 +00:00
|
|
|
if (settings->bools.input_overlay_enable)
|
2016-12-25 00:28:16 +00:00
|
|
|
task_push_overlay_load_default(input_overlay_loaded, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_OVERLAY_NEXT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2017-04-28 12:57:55 +00:00
|
|
|
input_overlay_next(overlay_ptr, settings->floats.input_overlay_opacity);
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_DSP_FILTER_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
audio_driver_dsp_filter_free();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_DSP_FILTER_INIT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL);
|
2017-04-28 22:39:29 +00:00
|
|
|
if (string_is_empty(settings->paths.path_audio_dsp_plugin))
|
2016-12-25 00:28:16 +00:00
|
|
|
break;
|
2017-04-28 22:39:29 +00:00
|
|
|
audio_driver_dsp_filter_init(settings->paths.path_audio_dsp_plugin);
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_GPU_RECORD_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
video_driver_gpu_record_deinit();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RECORD_DEINIT:
|
2018-09-16 02:09:41 +00:00
|
|
|
{
|
2018-09-18 05:30:46 +00:00
|
|
|
recording_set_state(false);
|
|
|
|
streaming_set_state(false);
|
2018-09-16 02:09:41 +00:00
|
|
|
if (!recording_deinit())
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RECORD_INIT:
|
2018-09-15 22:44:46 +00:00
|
|
|
{
|
2018-09-16 02:09:41 +00:00
|
|
|
recording_set_state(true);
|
|
|
|
if (!recording_init())
|
2018-09-18 05:04:18 +00:00
|
|
|
{
|
|
|
|
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
2018-09-15 22:44:46 +00:00
|
|
|
return false;
|
2018-09-18 05:04:18 +00:00
|
|
|
}
|
2018-09-15 22:44:46 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_HISTORY_DEINIT:
|
2016-07-30 20:47:43 +00:00
|
|
|
if (g_defaults.content_history)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2016-07-30 20:47:43 +00:00
|
|
|
playlist_write_file(g_defaults.content_history);
|
|
|
|
playlist_free(g_defaults.content_history);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
2016-07-30 20:47:43 +00:00
|
|
|
g_defaults.content_history = NULL;
|
|
|
|
|
2017-08-13 22:50:16 +00:00
|
|
|
if (g_defaults.content_favorites)
|
|
|
|
{
|
|
|
|
playlist_write_file(g_defaults.content_favorites);
|
|
|
|
playlist_free(g_defaults.content_favorites);
|
|
|
|
}
|
|
|
|
g_defaults.content_favorites = NULL;
|
|
|
|
|
2017-05-27 22:00:51 +00:00
|
|
|
if (g_defaults.music_history)
|
|
|
|
{
|
|
|
|
playlist_write_file(g_defaults.music_history);
|
|
|
|
playlist_free(g_defaults.music_history);
|
|
|
|
}
|
|
|
|
g_defaults.music_history = NULL;
|
|
|
|
|
2018-06-20 02:50:58 +00:00
|
|
|
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
|
2016-07-30 20:47:43 +00:00
|
|
|
if (g_defaults.video_history)
|
|
|
|
{
|
|
|
|
playlist_write_file(g_defaults.video_history);
|
|
|
|
playlist_free(g_defaults.video_history);
|
|
|
|
}
|
|
|
|
g_defaults.video_history = NULL;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_IMAGEVIEWER
|
|
|
|
if (g_defaults.image_history)
|
|
|
|
{
|
|
|
|
playlist_write_file(g_defaults.image_history);
|
|
|
|
playlist_free(g_defaults.image_history);
|
|
|
|
}
|
|
|
|
g_defaults.image_history = NULL;
|
|
|
|
#endif
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_HISTORY_INIT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2017-04-28 19:03:04 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
unsigned content_history_size = settings->uints.content_history_size;
|
|
|
|
|
2016-12-25 00:28:16 +00:00
|
|
|
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
|
2017-04-28 19:03:04 +00:00
|
|
|
|
2017-04-28 11:43:47 +00:00
|
|
|
if (!settings->bools.history_list_enable)
|
2016-12-25 00:28:16 +00:00
|
|
|
return false;
|
2016-07-30 20:47:43 +00:00
|
|
|
|
2016-12-25 00:28:16 +00:00
|
|
|
RARCH_LOG("%s: [%s].\n",
|
|
|
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_history);
|
2016-12-25 00:28:16 +00:00
|
|
|
g_defaults.content_history = playlist_init(
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_history,
|
2017-04-28 19:03:04 +00:00
|
|
|
content_history_size);
|
2016-07-30 20:47:43 +00:00
|
|
|
|
2017-08-12 15:10:14 +00:00
|
|
|
RARCH_LOG("%s: [%s].\n",
|
|
|
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
|
|
|
settings->paths.path_content_favorites);
|
|
|
|
g_defaults.content_favorites = playlist_init(
|
|
|
|
settings->paths.path_content_favorites,
|
|
|
|
content_history_size);
|
|
|
|
|
2016-12-25 00:28:16 +00:00
|
|
|
RARCH_LOG("%s: [%s].\n",
|
|
|
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_music_history);
|
2016-12-25 00:28:16 +00:00
|
|
|
g_defaults.music_history = playlist_init(
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_music_history,
|
2017-04-28 19:03:04 +00:00
|
|
|
content_history_size);
|
2016-07-30 20:47:43 +00:00
|
|
|
|
2018-06-20 02:50:58 +00:00
|
|
|
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
|
2016-12-25 00:28:16 +00:00
|
|
|
RARCH_LOG("%s: [%s].\n",
|
|
|
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_video_history);
|
2016-12-25 00:28:16 +00:00
|
|
|
g_defaults.video_history = playlist_init(
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_video_history,
|
2017-04-28 19:03:04 +00:00
|
|
|
content_history_size);
|
2016-07-30 20:47:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_IMAGEVIEWER
|
2016-12-25 00:28:16 +00:00
|
|
|
RARCH_LOG("%s: [%s].\n",
|
|
|
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_image_history);
|
2016-12-25 00:28:16 +00:00
|
|
|
g_defaults.image_history = playlist_init(
|
2017-04-28 22:39:29 +00:00
|
|
|
settings->paths.path_content_image_history,
|
2017-04-28 19:03:04 +00:00
|
|
|
content_history_size);
|
2016-07-30 20:47:43 +00:00
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CORE_INFO_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
core_info_deinit_list();
|
2018-08-12 14:33:24 +00:00
|
|
|
core_info_free_current_core();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CORE_INFO_INIT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2018-04-10 02:31:19 +00:00
|
|
|
char ext_name[255];
|
2016-12-25 00:28:16 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2018-04-10 04:50:47 +00:00
|
|
|
|
|
|
|
ext_name[0] = '\0';
|
|
|
|
|
2016-12-25 00:28:16 +00:00
|
|
|
command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2018-04-10 02:31:19 +00:00
|
|
|
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
|
|
|
|
return false;
|
|
|
|
|
2017-04-28 22:39:29 +00:00
|
|
|
if (!string_is_empty(settings->paths.directory_libretro))
|
2018-04-10 01:02:10 +00:00
|
|
|
core_info_init_list(settings->paths.path_libretro_info,
|
2018-04-10 02:31:19 +00:00
|
|
|
settings->paths.directory_libretro,
|
|
|
|
ext_name,
|
|
|
|
settings->bools.show_hidden_files
|
|
|
|
);
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CORE_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2016-06-23 05:40:51 +00:00
|
|
|
struct retro_hw_render_callback *hwr = NULL;
|
2019-02-12 05:32:01 +00:00
|
|
|
rarch_ctl(RARCH_CTL_CONTENT_RUNTIME_LOG_DEINIT, NULL);
|
2016-06-09 15:14:40 +00:00
|
|
|
content_reset_savestate_backups();
|
2016-06-23 05:40:51 +00:00
|
|
|
hwr = video_driver_get_hw_context();
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_deinit_core(true);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
if (hwr)
|
|
|
|
memset(hwr, 0, sizeof(*hwr));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_CORE_INIT:
|
2016-06-08 19:27:54 +00:00
|
|
|
content_reset_savestate_backups();
|
2016-05-09 19:36:17 +00:00
|
|
|
if (!command_event_init_core((enum rarch_core_type*)data))
|
2016-05-09 18:30:47 +00:00
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_VIDEO_APPLY_STATE_CHANGES:
|
2016-05-09 18:30:47 +00:00
|
|
|
video_driver_apply_state_changes();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_VIDEO_SET_NONBLOCKING_STATE:
|
2016-05-09 18:30:47 +00:00
|
|
|
boolean = true; /* fall-through */
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_VIDEO_SET_BLOCKING_STATE:
|
2016-05-09 18:30:47 +00:00
|
|
|
video_driver_set_nonblock_state(boolean);
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_VIDEO_SET_ASPECT_RATIO:
|
2016-05-09 18:30:47 +00:00
|
|
|
video_driver_set_aspect_ratio();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE:
|
2016-05-09 18:30:47 +00:00
|
|
|
boolean = true; /* fall-through */
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUDIO_SET_BLOCKING_STATE:
|
2016-05-09 18:30:47 +00:00
|
|
|
audio_driver_set_nonblocking_state(boolean);
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2016-12-25 00:28:16 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 12:57:55 +00:00
|
|
|
input_overlay_set_scale_factor(overlay_ptr, settings->floats.input_overlay_scale);
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_OVERLAY_SET_ALPHA_MOD:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2016-12-25 00:28:16 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 12:57:55 +00:00
|
|
|
input_overlay_set_alpha_mod(overlay_ptr, settings->floats.input_overlay_opacity);
|
2016-05-09 18:30:47 +00:00
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_AUDIO_REINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-05-28 13:03:03 +00:00
|
|
|
driver_uninit(DRIVER_AUDIO_MASK);
|
|
|
|
drivers_init(DRIVER_AUDIO_MASK);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RESET_CONTEXT:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
/* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we
|
|
|
|
* need to make sure to keep a copy */
|
|
|
|
struct retro_hw_render_callback hwr_copy;
|
2016-12-22 20:56:54 +00:00
|
|
|
struct retro_hw_render_callback *hwr = video_driver_get_hw_context();
|
2017-08-01 16:25:08 +00:00
|
|
|
const struct retro_hw_render_context_negotiation_interface *iface =
|
2016-12-22 20:56:54 +00:00
|
|
|
video_driver_get_context_negotiation_interface();
|
2016-05-09 18:30:47 +00:00
|
|
|
memcpy(&hwr_copy, hwr, sizeof(hwr_copy));
|
|
|
|
|
2017-05-28 13:03:03 +00:00
|
|
|
driver_uninit(DRIVERS_CMD_ALL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
|
|
|
memcpy(hwr, &hwr_copy, sizeof(*hwr));
|
2016-06-27 18:54:03 +00:00
|
|
|
video_driver_set_context_negotiation_interface(iface);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2017-05-28 13:03:03 +00:00
|
|
|
drivers_init(DRIVERS_CMD_ALL);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SHUTDOWN:
|
2016-05-09 18:30:47 +00:00
|
|
|
#if defined(__linux__) && !defined(ANDROID)
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_VALUE_SHUTTING_DOWN), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-12-22 20:56:54 +00:00
|
|
|
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
|
2016-05-11 18:53:28 +00:00
|
|
|
command_event(CMD_EVENT_QUIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
system("shutdown -P now");
|
|
|
|
#endif
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REBOOT:
|
2016-05-09 18:30:47 +00:00
|
|
|
#if defined(__linux__) && !defined(ANDROID)
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_VALUE_REBOOTING), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-12-22 20:56:54 +00:00
|
|
|
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
|
2016-05-11 18:53:28 +00:00
|
|
|
command_event(CMD_EVENT_QUIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
system("shutdown -r now");
|
|
|
|
#endif
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RESUME:
|
2017-05-15 02:31:40 +00:00
|
|
|
rarch_menu_running_finished();
|
2016-05-09 18:30:47 +00:00
|
|
|
if (ui_companion_is_on_foreground())
|
2018-04-30 18:33:05 +00:00
|
|
|
ui_companion_driver_toggle(false);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2017-08-13 22:29:38 +00:00
|
|
|
case CMD_EVENT_ADD_TO_FAVORITES:
|
2017-11-09 03:41:13 +00:00
|
|
|
{
|
2019-03-05 13:04:43 +00:00
|
|
|
struct string_list *str_list = (struct string_list*)data;
|
2019-03-02 14:08:48 +00:00
|
|
|
|
2019-03-05 13:04:43 +00:00
|
|
|
if (str_list)
|
2019-03-02 14:08:48 +00:00
|
|
|
{
|
2019-03-09 13:48:06 +00:00
|
|
|
if (str_list->size >= 6)
|
2019-03-05 13:04:43 +00:00
|
|
|
{
|
2019-04-12 16:50:27 +00:00
|
|
|
struct playlist_entry entry = {0};
|
|
|
|
|
|
|
|
entry.path = str_list->elems[0].data; /* content_path */
|
|
|
|
entry.label = str_list->elems[1].data; /* content_label */
|
|
|
|
entry.core_path = str_list->elems[2].data; /* core_path */
|
|
|
|
entry.core_name = str_list->elems[3].data; /* core_name */
|
|
|
|
entry.crc32 = str_list->elems[4].data; /* crc32 */
|
|
|
|
entry.db_name = str_list->elems[5].data; /* db_name */
|
|
|
|
|
2019-03-05 13:04:43 +00:00
|
|
|
/* Write playlist entry */
|
|
|
|
command_playlist_push_write(
|
|
|
|
g_defaults.content_favorites,
|
2019-04-12 16:50:27 +00:00
|
|
|
&entry
|
2019-03-05 13:04:43 +00:00
|
|
|
);
|
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_ADDED_TO_FAVORITES), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
}
|
2019-03-02 14:08:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-13 22:29:38 +00:00
|
|
|
break;
|
2017-11-09 03:41:13 +00:00
|
|
|
}
|
2018-03-18 20:34:57 +00:00
|
|
|
case CMD_EVENT_RESET_CORE_ASSOCIATION:
|
|
|
|
{
|
2018-03-24 15:11:10 +00:00
|
|
|
const char *core_name = "DETECT";
|
|
|
|
const char *core_path = "DETECT";
|
|
|
|
size_t *playlist_index = (size_t*)data;
|
2019-04-12 16:50:27 +00:00
|
|
|
struct playlist_entry entry = {0};
|
|
|
|
|
|
|
|
/* the update function reads our entry as const, so these casts are safe */
|
|
|
|
entry.core_path = (char*)core_path;
|
|
|
|
entry.core_name = (char*)core_name;
|
2018-03-18 20:34:57 +00:00
|
|
|
|
|
|
|
command_playlist_update_write(
|
|
|
|
NULL,
|
2018-03-24 14:15:41 +00:00
|
|
|
*playlist_index,
|
2019-04-12 16:50:27 +00:00
|
|
|
&entry);
|
2018-03-18 20:34:57 +00:00
|
|
|
|
2018-11-22 14:45:52 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_RESET_CORE_ASSOCIATION), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2018-03-18 20:34:57 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-30 18:33:05 +00:00
|
|
|
}
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RESTART_RETROARCH:
|
2016-05-09 18:30:47 +00:00
|
|
|
if (!frontend_driver_set_fork(FRONTEND_FORK_RESTART))
|
|
|
|
return false;
|
2016-10-08 00:51:09 +00:00
|
|
|
#ifndef HAVE_DYNAMIC
|
|
|
|
command_event(CMD_EVENT_QUIT, NULL);
|
|
|
|
#endif
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2018-10-01 00:13:53 +00:00
|
|
|
case CMD_EVENT_MENU_RESET_TO_DEFAULT_CONFIG:
|
|
|
|
config_set_defaults();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG:
|
2016-08-26 05:44:05 +00:00
|
|
|
command_event_save_current_config(OVERRIDE_NONE);
|
2016-08-25 05:54:39 +00:00
|
|
|
break;
|
2016-08-26 14:43:29 +00:00
|
|
|
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CORE:
|
2016-08-26 05:44:05 +00:00
|
|
|
command_event_save_current_config(OVERRIDE_CORE);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2018-05-14 03:33:06 +00:00
|
|
|
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CONTENT_DIR:
|
|
|
|
command_event_save_current_config(OVERRIDE_CONTENT_DIR);
|
|
|
|
break;
|
2016-08-26 14:43:29 +00:00
|
|
|
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_GAME:
|
|
|
|
command_event_save_current_config(OVERRIDE_GAME);
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_MENU_SAVE_CONFIG:
|
2016-05-09 18:41:59 +00:00
|
|
|
if (!command_event_save_core_config())
|
2016-05-09 18:30:47 +00:00
|
|
|
return false;
|
|
|
|
break;
|
2018-08-15 01:38:52 +00:00
|
|
|
case CMD_EVENT_SHADER_PRESET_LOADED:
|
|
|
|
ui_companion_event_command(cmd);
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SHADERS_APPLY_CHANGES:
|
2016-05-09 18:30:47 +00:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
menu_shader_manager_apply_changes();
|
|
|
|
#endif
|
2018-08-15 01:38:52 +00:00
|
|
|
ui_companion_event_command(cmd);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_PAUSE_CHECKS:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-01-23 14:19:46 +00:00
|
|
|
bool is_paused = false;
|
|
|
|
bool is_idle = false;
|
|
|
|
bool is_slowmotion = false;
|
2017-01-25 15:57:22 +00:00
|
|
|
bool is_perfcnt_enable = false;
|
2019-02-19 04:12:15 +00:00
|
|
|
#ifdef HAVE_DISCORD
|
|
|
|
discord_userdata_t userdata;
|
|
|
|
#endif
|
2017-01-23 14:19:46 +00:00
|
|
|
|
2017-01-25 15:57:22 +00:00
|
|
|
runloop_get_status(&is_paused, &is_idle, &is_slowmotion,
|
|
|
|
&is_perfcnt_enable);
|
2017-01-23 14:19:46 +00:00
|
|
|
|
|
|
|
if (is_paused)
|
|
|
|
{
|
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED));
|
|
|
|
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2019-04-08 14:44:21 +00:00
|
|
|
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
|
|
|
if (!video_driver_has_widgets() || !menu_widgets_set_paused(is_paused))
|
|
|
|
#endif
|
2019-02-08 06:26:43 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_PAUSED), 1,
|
|
|
|
1, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-10-28 14:09:52 +00:00
|
|
|
|
2017-01-25 16:52:58 +00:00
|
|
|
if (!is_idle)
|
2017-01-25 16:52:38 +00:00
|
|
|
video_driver_cached_frame();
|
2018-08-18 07:12:51 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_DISCORD
|
|
|
|
userdata.status = DISCORD_PRESENCE_GAME_PAUSED;
|
|
|
|
command_event(CMD_EVENT_DISCORD_UPDATE, &userdata);
|
|
|
|
#endif
|
2017-01-23 14:19:46 +00:00
|
|
|
}
|
|
|
|
else
|
2016-10-24 22:42:14 +00:00
|
|
|
{
|
2019-04-08 14:44:21 +00:00
|
|
|
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
|
|
|
if (video_driver_has_widgets())
|
|
|
|
menu_widgets_set_paused(is_paused);
|
|
|
|
#endif
|
2017-01-23 14:19:46 +00:00
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED));
|
|
|
|
command_event(CMD_EVENT_AUDIO_START, NULL);
|
2016-10-24 22:42:14 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_PAUSE_TOGGLE:
|
2017-05-15 03:06:23 +00:00
|
|
|
boolean = rarch_ctl(RARCH_CTL_IS_PAUSED, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
boolean = !boolean;
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_PAUSED, &boolean);
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_PAUSE_CHECKS, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_UNPAUSE:
|
2016-05-09 18:30:47 +00:00
|
|
|
boolean = false;
|
|
|
|
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_PAUSED, &boolean);
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_PAUSE_CHECKS, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_PAUSE:
|
2016-05-09 18:30:47 +00:00
|
|
|
boolean = true;
|
|
|
|
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_PAUSED, &boolean);
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_PAUSE_CHECKS, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_MENU_PAUSE_LIBRETRO:
|
2016-12-25 00:28:16 +00:00
|
|
|
#ifdef HAVE_MENU
|
2017-01-23 14:19:46 +00:00
|
|
|
if (menu_driver_is_alive())
|
|
|
|
{
|
2016-12-25 00:28:16 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 11:43:47 +00:00
|
|
|
if (settings->bools.menu_pause_libretro)
|
2017-01-23 14:19:46 +00:00
|
|
|
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
else
|
2017-01-23 14:19:46 +00:00
|
|
|
command_event(CMD_EVENT_AUDIO_START, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2017-04-28 11:43:47 +00:00
|
|
|
if (settings->bools.menu_pause_libretro)
|
2017-01-23 14:19:46 +00:00
|
|
|
command_event(CMD_EVENT_AUDIO_START, NULL);
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2017-01-23 14:19:46 +00:00
|
|
|
#endif
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SHADER_DIR_DEINIT:
|
2016-09-23 01:19:33 +00:00
|
|
|
dir_free_shader();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SHADER_DIR_INIT:
|
|
|
|
command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-09-23 01:19:33 +00:00
|
|
|
if (!dir_init_shader())
|
2016-05-09 18:30:47 +00:00
|
|
|
return false;
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_BSV_MOVIE_DEINIT:
|
2017-05-07 16:15:30 +00:00
|
|
|
bsv_movie_deinit();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_BSV_MOVIE_INIT:
|
|
|
|
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
2017-05-07 16:28:07 +00:00
|
|
|
bsv_movie_init();
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-09-29 19:07:10 +00:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-12-27 21:41:27 +00:00
|
|
|
case CMD_EVENT_NETPLAY_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
deinit_netplay();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_NETWORK_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
network_deinit();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_NETWORK_INIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
network_init();
|
|
|
|
break;
|
2017-05-22 03:21:11 +00:00
|
|
|
/* init netplay manually */
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_NETPLAY_INIT:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
2017-01-22 20:25:35 +00:00
|
|
|
char *hostname = (char *) data;
|
2016-12-27 21:41:27 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2017-01-22 20:25:35 +00:00
|
|
|
|
2016-12-25 00:28:16 +00:00
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
2017-01-22 20:25:35 +00:00
|
|
|
|
2017-08-01 16:25:08 +00:00
|
|
|
if (!init_netplay(NULL, hostname ? hostname :
|
2017-05-22 03:21:11 +00:00
|
|
|
settings->paths.netplay_server,
|
|
|
|
settings->uints.netplay_port))
|
2016-12-27 20:07:44 +00:00
|
|
|
{
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
2016-12-25 00:28:16 +00:00
|
|
|
return false;
|
2016-12-27 20:07:44 +00:00
|
|
|
}
|
2017-08-01 16:25:08 +00:00
|
|
|
|
|
|
|
/* Disable rewind & sram autosave if it was enabled
|
2017-07-11 00:30:55 +00:00
|
|
|
TODO: Add a setting for these tweaks */
|
|
|
|
state_manager_event_deinit();
|
2017-07-25 02:24:22 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2017-07-11 03:44:16 +00:00
|
|
|
autosave_deinit();
|
2017-07-25 02:24:22 +00:00
|
|
|
#endif
|
2016-12-27 21:41:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-05-22 03:21:11 +00:00
|
|
|
/* init netplay via lobby when content is loaded */
|
2016-12-27 21:41:27 +00:00
|
|
|
case CMD_EVENT_NETPLAY_INIT_DIRECT:
|
|
|
|
{
|
2017-05-27 17:59:34 +00:00
|
|
|
/* buf is expected to be address|port */
|
|
|
|
static struct string_list *hostname = NULL;
|
2019-02-07 04:38:46 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
char *buf = (char *)data;
|
|
|
|
|
|
|
|
RARCH_LOG("[netplay] buf %s\n", buf);
|
|
|
|
|
|
|
|
hostname = string_split(buf, "|");
|
2017-01-22 20:25:35 +00:00
|
|
|
|
2016-12-27 21:41:27 +00:00
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
2017-01-22 20:25:35 +00:00
|
|
|
|
2019-02-07 00:01:11 +00:00
|
|
|
RARCH_LOG("[netplay] connecting to %s:%d (direct)\n",
|
2017-08-01 16:25:08 +00:00
|
|
|
hostname->elems[0].data, !string_is_empty(hostname->elems[1].data)
|
2018-06-28 03:03:27 +00:00
|
|
|
? atoi(hostname->elems[1].data) : settings->uints.netplay_port);
|
2017-05-22 03:48:30 +00:00
|
|
|
|
2017-08-01 16:25:08 +00:00
|
|
|
if (!init_netplay(NULL, hostname->elems[0].data,
|
|
|
|
!string_is_empty(hostname->elems[1].data)
|
2018-06-28 03:03:27 +00:00
|
|
|
? atoi(hostname->elems[1].data) : settings->uints.netplay_port))
|
2016-12-27 21:41:27 +00:00
|
|
|
{
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
2017-05-27 17:59:34 +00:00
|
|
|
string_list_free(hostname);
|
2016-12-27 21:41:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-05-27 17:59:34 +00:00
|
|
|
|
|
|
|
string_list_free(hostname);
|
2017-07-11 00:30:55 +00:00
|
|
|
|
2017-08-01 16:25:08 +00:00
|
|
|
/* Disable rewind if it was enabled
|
2017-07-11 00:30:55 +00:00
|
|
|
TODO: Add a setting for these tweaks */
|
|
|
|
state_manager_event_deinit();
|
2017-07-25 02:24:22 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2017-07-11 03:44:16 +00:00
|
|
|
autosave_deinit();
|
2017-07-25 02:24:22 +00:00
|
|
|
#endif
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2017-05-27 17:59:34 +00:00
|
|
|
/* init netplay via lobby when content is not loaded */
|
2017-01-20 21:04:10 +00:00
|
|
|
case CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED:
|
|
|
|
{
|
2019-02-07 04:38:46 +00:00
|
|
|
static struct string_list *hostname = NULL;
|
2017-05-22 03:21:11 +00:00
|
|
|
/* buf is expected to be address|port */
|
2019-02-07 04:38:46 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
char *buf = (char *)data;
|
|
|
|
|
2019-02-07 00:01:11 +00:00
|
|
|
RARCH_LOG("[netplay] buf %s\n", buf);
|
2019-02-07 04:38:46 +00:00
|
|
|
|
|
|
|
hostname = string_split(buf, "|");
|
2017-01-20 21:04:10 +00:00
|
|
|
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
2017-05-27 17:59:34 +00:00
|
|
|
|
2019-02-07 00:01:11 +00:00
|
|
|
RARCH_LOG("[netplay] connecting to %s:%d (deferred)\n",
|
2017-08-01 16:25:08 +00:00
|
|
|
hostname->elems[0].data, !string_is_empty(hostname->elems[1].data)
|
2018-06-28 03:03:27 +00:00
|
|
|
? atoi(hostname->elems[1].data) : settings->uints.netplay_port);
|
2017-01-22 20:24:57 +00:00
|
|
|
|
2017-05-27 17:59:34 +00:00
|
|
|
if (!init_netplay_deferred(hostname->elems[0].data,
|
2017-08-01 16:25:08 +00:00
|
|
|
!string_is_empty(hostname->elems[1].data)
|
2018-06-28 03:03:27 +00:00
|
|
|
? atoi(hostname->elems[1].data) : settings->uints.netplay_port))
|
2017-01-20 21:04:10 +00:00
|
|
|
{
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
2017-05-22 03:21:11 +00:00
|
|
|
string_list_free(hostname);
|
2017-01-20 21:04:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-03-05 18:51:16 +00:00
|
|
|
|
|
|
|
string_list_free(hostname);
|
2017-07-11 00:30:55 +00:00
|
|
|
|
2017-08-01 16:25:08 +00:00
|
|
|
/* Disable rewind if it was enabled
|
2017-07-11 00:30:55 +00:00
|
|
|
TODO: Add a setting for these tweaks */
|
|
|
|
state_manager_event_deinit();
|
2017-07-25 02:24:22 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2017-07-11 03:44:16 +00:00
|
|
|
autosave_deinit();
|
2017-07-25 02:24:22 +00:00
|
|
|
#endif
|
2017-01-20 21:04:10 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-12-12 22:22:35 +00:00
|
|
|
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2019-03-09 22:48:03 +00:00
|
|
|
case CMD_EVENT_NETPLAY_ENABLE_HOST:
|
|
|
|
{
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
bool contentless = false;
|
|
|
|
bool is_inited = false;
|
|
|
|
|
|
|
|
content_get_status(&contentless, &is_inited);
|
|
|
|
|
|
|
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL);
|
|
|
|
|
|
|
|
/* If we haven't yet started, this will load on its own */
|
|
|
|
if (!is_inited)
|
|
|
|
{
|
|
|
|
runloop_msg_queue_push(
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED),
|
|
|
|
1, 480, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable Netplay itself */
|
|
|
|
if (!command_event(CMD_EVENT_NETPLAY_INIT, NULL))
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_EVENT_NETPLAY_DISCONNECT:
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISCONNECT, NULL);
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL);
|
|
|
|
|
|
|
|
/* Re-enable rewind if it was enabled
|
|
|
|
TODO: Add a setting for these tweaks */
|
|
|
|
if (settings->bools.rewind_enable)
|
|
|
|
command_event(CMD_EVENT_REWIND_INIT, NULL);
|
|
|
|
if (settings->uints.autosave_interval != 0)
|
|
|
|
command_event(CMD_EVENT_AUTOSAVE_INIT, NULL);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2019-03-11 17:04:06 +00:00
|
|
|
case CMD_EVENT_NETPLAY_HOST_TOGGLE:
|
|
|
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL))
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DISCONNECT, NULL);
|
|
|
|
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
|
|
|
!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) &&
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL))
|
|
|
|
command_event(CMD_EVENT_NETPLAY_DISCONNECT, NULL);
|
|
|
|
else
|
|
|
|
command_event(CMD_EVENT_NETPLAY_ENABLE_HOST, NULL);
|
|
|
|
|
|
|
|
break;
|
2016-12-27 21:41:27 +00:00
|
|
|
#else
|
|
|
|
case CMD_EVENT_NETPLAY_DEINIT:
|
|
|
|
case CMD_EVENT_NETWORK_DEINIT:
|
|
|
|
case CMD_EVENT_NETWORK_INIT:
|
|
|
|
case CMD_EVENT_NETPLAY_INIT:
|
|
|
|
case CMD_EVENT_NETPLAY_INIT_DIRECT:
|
2017-01-20 21:04:10 +00:00
|
|
|
case CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED:
|
2016-12-27 21:41:27 +00:00
|
|
|
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
2019-03-11 17:04:06 +00:00
|
|
|
case CMD_EVENT_NETPLAY_HOST_TOGGLE:
|
2019-03-11 17:33:24 +00:00
|
|
|
case CMD_EVENT_NETPLAY_DISCONNECT:
|
2016-12-27 21:41:27 +00:00
|
|
|
return false;
|
|
|
|
#endif
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_FULLSCREEN_TOGGLE:
|
2016-12-25 00:28:16 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2018-04-30 18:33:05 +00:00
|
|
|
bool new_fullscreen_state = !settings->bools.video_fullscreen
|
2017-12-17 17:56:26 +00:00
|
|
|
&& !retroarch_is_forced_fullscreen();
|
2018-12-12 00:34:12 +00:00
|
|
|
|
2016-12-25 00:28:16 +00:00
|
|
|
if (!video_driver_has_windowed())
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2018-12-12 00:34:12 +00:00
|
|
|
retroarch_set_switching_display_mode();
|
|
|
|
|
2017-12-17 17:56:26 +00:00
|
|
|
/* we toggled manually, write the new value to settings */
|
2017-04-27 22:53:06 +00:00
|
|
|
configuration_set_bool(settings, settings->bools.video_fullscreen,
|
2017-04-23 15:36:25 +00:00
|
|
|
new_fullscreen_state);
|
|
|
|
|
2017-12-17 17:56:26 +00:00
|
|
|
/* we toggled manually, the cli arg is irrelevant now */
|
|
|
|
if (retroarch_is_forced_fullscreen())
|
|
|
|
retroarch_unset_forced_fullscreen();
|
|
|
|
|
|
|
|
/* If we go fullscreen we drop all drivers and
|
|
|
|
* reinitialize to be safe. */
|
2016-12-25 00:28:16 +00:00
|
|
|
command_event(CMD_EVENT_REINIT, NULL);
|
2017-04-27 22:53:06 +00:00
|
|
|
if (settings->bools.video_fullscreen)
|
2016-12-25 00:28:16 +00:00
|
|
|
video_driver_hide_mouse();
|
|
|
|
else
|
|
|
|
video_driver_show_mouse();
|
2018-12-12 00:34:12 +00:00
|
|
|
|
|
|
|
retroarch_unset_switching_display_mode();
|
2016-12-25 00:28:16 +00:00
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_COMMAND_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
input_driver_deinit_command();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_COMMAND_INIT:
|
|
|
|
command_event(CMD_EVENT_COMMAND_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
input_driver_init_command();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REMOTE_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
input_driver_deinit_remote();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_REMOTE_INIT:
|
|
|
|
command_event(CMD_EVENT_REMOTE_DEINIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
input_driver_init_remote();
|
|
|
|
break;
|
2017-09-08 03:30:42 +00:00
|
|
|
case CMD_EVENT_MAPPER_DEINIT:
|
|
|
|
input_driver_deinit_mapper();
|
|
|
|
break;
|
|
|
|
case CMD_EVENT_MAPPER_INIT:
|
|
|
|
command_event(CMD_EVENT_MAPPER_DEINIT, NULL);
|
2017-11-24 21:18:08 +00:00
|
|
|
input_driver_init_mapper();
|
2018-07-15 03:49:50 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_LOG_FILE_DEINIT:
|
2016-05-09 18:30:47 +00:00
|
|
|
retro_main_log_file_deinit();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_DISK_APPEND_IMAGE:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
const char *path = (const char*)data;
|
|
|
|
if (string_is_empty(path))
|
|
|
|
return false;
|
2018-07-15 03:49:50 +00:00
|
|
|
if (!command_event_disk_control_append_image(path))
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
2018-07-15 03:49:50 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_DISK_EJECT_TOGGLE:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *info = runloop_get_system_info();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
if (info && info->disk_control_cb.get_num_images)
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2016-12-25 00:19:38 +00:00
|
|
|
const struct retro_disk_control_callback *control =
|
|
|
|
(const struct retro_disk_control_callback*)
|
|
|
|
&info->disk_control_cb;
|
|
|
|
|
|
|
|
if (control)
|
|
|
|
{
|
|
|
|
bool new_state = !control->get_eject_state();
|
|
|
|
command_event_disk_control_set_eject(new_state, true);
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
2016-12-25 00:19:38 +00:00
|
|
|
else
|
|
|
|
runloop_msg_queue_push(
|
|
|
|
msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS),
|
2018-11-22 14:45:52 +00:00
|
|
|
1, 120, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_DISK_NEXT:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *info = runloop_get_system_info();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
if (info && info->disk_control_cb.get_num_images)
|
|
|
|
{
|
|
|
|
const struct retro_disk_control_callback *control =
|
|
|
|
(const struct retro_disk_control_callback*)
|
|
|
|
&info->disk_control_cb;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
if (!control)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!control->get_eject_state())
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
command_event_check_disk_next(control);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
runloop_msg_queue_push(
|
|
|
|
msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS),
|
2018-11-22 14:45:52 +00:00
|
|
|
1, 120, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_DISK_PREV:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2017-04-23 14:41:26 +00:00
|
|
|
rarch_system_info_t *info = runloop_get_system_info();
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
if (info && info->disk_control_cb.get_num_images)
|
|
|
|
{
|
|
|
|
const struct retro_disk_control_callback *control =
|
|
|
|
(const struct retro_disk_control_callback*)
|
|
|
|
&info->disk_control_cb;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
if (!control)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!control->get_eject_state())
|
|
|
|
return false;
|
2016-05-09 18:30:47 +00:00
|
|
|
|
2016-12-25 00:19:38 +00:00
|
|
|
command_event_check_disk_prev(control);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
runloop_msg_queue_push(
|
|
|
|
msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS),
|
2018-11-22 14:45:52 +00:00
|
|
|
1, 120, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_RUMBLE_STOP:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
2016-12-25 00:24:17 +00:00
|
|
|
unsigned i;
|
|
|
|
for (i = 0; i < MAX_USERS; i++)
|
|
|
|
{
|
|
|
|
input_driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0);
|
|
|
|
input_driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0);
|
|
|
|
}
|
2016-05-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_GRAB_MOUSE_TOGGLE:
|
2016-05-09 18:30:47 +00:00
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
static bool grab_mouse_state = false;
|
|
|
|
|
|
|
|
grab_mouse_state = !grab_mouse_state;
|
|
|
|
|
|
|
|
if (grab_mouse_state)
|
|
|
|
ret = input_driver_grab_mouse();
|
|
|
|
else
|
|
|
|
ret = input_driver_ungrab_mouse();
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
RARCH_LOG("%s: %s.\n",
|
|
|
|
msg_hash_to_str(MSG_GRAB_MOUSE_STATE),
|
|
|
|
grab_mouse_state ? "yes" : "no");
|
|
|
|
|
|
|
|
if (grab_mouse_state)
|
|
|
|
video_driver_hide_mouse();
|
|
|
|
else
|
|
|
|
video_driver_show_mouse();
|
|
|
|
}
|
|
|
|
break;
|
2018-04-30 18:33:05 +00:00
|
|
|
case CMD_EVENT_UI_COMPANION_TOGGLE:
|
2018-07-15 03:49:50 +00:00
|
|
|
ui_companion_driver_toggle(true);
|
|
|
|
break;
|
2016-12-06 05:32:28 +00:00
|
|
|
case CMD_EVENT_GAME_FOCUS_TOGGLE:
|
|
|
|
{
|
|
|
|
static bool game_focus_state = false;
|
2017-01-02 01:16:29 +00:00
|
|
|
intptr_t mode = (intptr_t)data;
|
2017-08-01 16:25:08 +00:00
|
|
|
|
2016-12-06 05:32:28 +00:00
|
|
|
/* mode = -1: restores current game focus state
|
|
|
|
* mode = 1: force set game focus, instead of toggling
|
|
|
|
* any other: toggle
|
|
|
|
*/
|
|
|
|
if (mode == 1)
|
|
|
|
game_focus_state = true;
|
|
|
|
else if (mode != -1)
|
|
|
|
game_focus_state = !game_focus_state;
|
|
|
|
|
|
|
|
RARCH_LOG("%s: %s.\n",
|
|
|
|
"Game focus is: ",
|
|
|
|
game_focus_state ? "on" : "off");
|
|
|
|
|
2016-12-11 05:39:30 +00:00
|
|
|
if (game_focus_state)
|
|
|
|
{
|
2016-12-06 05:32:28 +00:00
|
|
|
input_driver_grab_mouse();
|
|
|
|
video_driver_hide_mouse();
|
|
|
|
input_driver_set_hotkey_block();
|
|
|
|
input_driver_keyboard_mapping_set_block(1);
|
2016-12-11 05:39:30 +00:00
|
|
|
if (mode != -1)
|
2016-12-22 22:36:11 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_GAME_FOCUS_ON),
|
2018-11-22 14:45:52 +00:00
|
|
|
1, 120, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-12-11 05:39:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-06 05:32:28 +00:00
|
|
|
input_driver_ungrab_mouse();
|
|
|
|
video_driver_show_mouse();
|
|
|
|
input_driver_unset_hotkey_block();
|
|
|
|
input_driver_keyboard_mapping_set_block(0);
|
2016-12-11 05:39:30 +00:00
|
|
|
if (mode != -1)
|
2016-12-22 22:36:11 +00:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_GAME_FOCUS_OFF),
|
2018-11-22 14:45:52 +00:00
|
|
|
1, 120, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
2016-12-06 05:32:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG:
|
2016-05-09 18:30:47 +00:00
|
|
|
rarch_perf_log();
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_VOLUME_UP:
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_set_volume(0.5f);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_VOLUME_DOWN:
|
2016-05-09 18:41:59 +00:00
|
|
|
command_event_set_volume(-0.5f);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2017-06-08 20:58:43 +00:00
|
|
|
case CMD_EVENT_MIXER_VOLUME_UP:
|
|
|
|
command_event_set_mixer_volume(0.5f);
|
|
|
|
break;
|
|
|
|
case CMD_EVENT_MIXER_VOLUME_DOWN:
|
|
|
|
command_event_set_mixer_volume(-0.5f);
|
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_SET_FRAME_LIMIT:
|
2017-05-15 03:06:23 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_FRAME_LIMIT, NULL);
|
2016-05-09 18:30:47 +00:00
|
|
|
break;
|
2016-05-20 22:54:29 +00:00
|
|
|
case CMD_EVENT_DISABLE_OVERRIDES:
|
|
|
|
command_event_disable_overrides();
|
|
|
|
break;
|
2017-08-05 04:56:17 +00:00
|
|
|
case CMD_EVENT_RESTORE_REMAPS:
|
|
|
|
command_event_restore_remaps();
|
2017-08-06 13:31:38 +00:00
|
|
|
break;
|
2016-07-30 19:36:01 +00:00
|
|
|
case CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET:
|
|
|
|
command_event_restore_default_shader_preset();
|
|
|
|
break;
|
2018-05-29 10:41:13 +00:00
|
|
|
case CMD_EVENT_DISCORD_INIT:
|
2018-05-29 16:55:02 +00:00
|
|
|
#ifdef HAVE_DISCORD
|
2018-05-29 10:41:13 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!settings->bools.discord_enable)
|
|
|
|
return false;
|
2018-12-24 19:28:36 +00:00
|
|
|
if (discord_is_ready())
|
2018-05-29 10:41:13 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
discord_init();
|
|
|
|
}
|
2018-05-29 16:55:02 +00:00
|
|
|
#endif
|
2018-05-29 10:41:13 +00:00
|
|
|
break;
|
|
|
|
case CMD_EVENT_DISCORD_DEINIT:
|
2018-05-29 16:55:02 +00:00
|
|
|
#ifdef HAVE_DISCORD
|
2018-12-24 19:28:36 +00:00
|
|
|
if (!discord_is_ready())
|
2018-05-29 10:41:13 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
discord_shutdown();
|
2018-05-29 16:55:02 +00:00
|
|
|
#endif
|
2018-05-29 10:41:13 +00:00
|
|
|
break;
|
|
|
|
case CMD_EVENT_DISCORD_UPDATE:
|
2018-05-29 16:55:02 +00:00
|
|
|
#ifdef HAVE_DISCORD
|
2018-12-24 19:28:36 +00:00
|
|
|
if (!data || !discord_is_ready())
|
2018-05-29 10:41:13 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
{
|
|
|
|
discord_userdata_t *userdata = (discord_userdata_t*)data;
|
|
|
|
discord_update(userdata->status);
|
|
|
|
}
|
2018-05-29 16:55:02 +00:00
|
|
|
#endif
|
2018-05-29 10:41:13 +00:00
|
|
|
break;
|
2016-05-09 18:51:53 +00:00
|
|
|
case CMD_EVENT_NONE:
|
2016-05-09 18:30:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|