2015-04-13 09:15:40 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2015-10-20 00:43:21 +00:00
|
|
|
*
|
2015-04-13 09:15:40 +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/>.
|
|
|
|
*/
|
|
|
|
|
2015-10-27 23:55:11 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2015-06-13 17:12:10 +00:00
|
|
|
#include <compat/strl.h>
|
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
#include "command_event.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
|
2015-12-05 08:09:31 +00:00
|
|
|
#include "frontend/frontend_driver.h"
|
2015-11-23 18:40:09 +00:00
|
|
|
#include "audio/audio_driver.h"
|
2015-12-05 15:12:29 +00:00
|
|
|
#include "record/record_driver.h"
|
2015-11-30 18:23:13 +00:00
|
|
|
#include "autosave.h"
|
2015-12-11 12:56:00 +00:00
|
|
|
#include "core_info.h"
|
2015-12-01 02:33:50 +00:00
|
|
|
#include "cheats.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
#include "general.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
#include "performance.h"
|
|
|
|
#include "dynamic.h"
|
|
|
|
#include "content.h"
|
2015-12-01 00:47:26 +00:00
|
|
|
#include "movie.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
#include "screenshot.h"
|
2015-07-01 20:14:37 +00:00
|
|
|
#include "msg_hash.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
#include "retroarch.h"
|
2015-11-30 21:29:16 +00:00
|
|
|
#include "rewind.h"
|
2015-12-06 18:31:47 +00:00
|
|
|
#include "system.h"
|
2015-05-24 02:19:32 +00:00
|
|
|
#include "dir_list_special.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-10-16 16:04:59 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
|
|
|
#include "cheevos.h"
|
|
|
|
#endif
|
|
|
|
|
2015-12-24 20:17:44 +00:00
|
|
|
#include "libretro_private.h"
|
|
|
|
#include "libretro_version_1.h"
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "verbosity.h"
|
2015-11-30 14:35:57 +00:00
|
|
|
#include "runloop.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
#include "configuration.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
#include "input/input_remapping.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
2015-12-05 12:22:50 +00:00
|
|
|
#include "menu/menu_driver.h"
|
2015-05-18 21:04:14 +00:00
|
|
|
#include "menu/menu_display.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
#include "menu/menu_shader.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-23 20:25:28 +00:00
|
|
|
#include "netplay/netplay.h"
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETWORKING
|
|
|
|
#include <net/net_compat.h>
|
|
|
|
#endif
|
|
|
|
|
2015-04-13 09:37:38 +00:00
|
|
|
/**
|
|
|
|
* event_disk_control_set_eject:
|
|
|
|
* @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.
|
|
|
|
**/
|
|
|
|
static void event_disk_control_set_eject(bool new_state, bool print_log)
|
|
|
|
{
|
2015-12-10 21:30:25 +00:00
|
|
|
char msg[128] = {0};
|
|
|
|
bool error = false;
|
|
|
|
rarch_system_info_t *info = NULL;
|
|
|
|
const struct retro_disk_control_callback *control = NULL;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
control = (const struct retro_disk_control_callback*)&info->disk_control;
|
2015-04-13 09:37:38 +00:00
|
|
|
|
2015-06-25 10:45:23 +00:00
|
|
|
if (!control || !control->get_num_images)
|
2015-04-13 09:37:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (control->set_eject_state(new_state))
|
2015-07-01 20:40:10 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s %s",
|
|
|
|
new_state ? "Ejected" : "Closed",
|
|
|
|
msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY));
|
2015-04-13 09:37:38 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
error = true;
|
2015-07-01 20:40:10 +00:00
|
|
|
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));
|
2015-04-13 09:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*msg)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
else
|
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
|
|
|
|
/* Only noise in menu. */
|
|
|
|
if (print_log)
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2015-04-13 09:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_disk_control_set_index:
|
|
|
|
* @idx : Index of disk to set as current.
|
|
|
|
*
|
|
|
|
* Sets current disk to @index.
|
|
|
|
**/
|
|
|
|
static void event_disk_control_set_index(unsigned idx)
|
|
|
|
{
|
|
|
|
unsigned num_disks;
|
2015-12-06 12:28:20 +00:00
|
|
|
bool error = false;
|
|
|
|
char msg[128] = {0};
|
2015-12-10 21:30:25 +00:00
|
|
|
rarch_system_info_t *info = NULL;
|
|
|
|
const struct retro_disk_control_callback *control = NULL;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
control = (const struct retro_disk_control_callback*)&info->disk_control;
|
2015-04-13 09:37:38 +00:00
|
|
|
|
2015-06-25 10:45:23 +00:00
|
|
|
if (!control || !control->get_num_images)
|
2015-04-13 09:37:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
num_disks = control->get_num_images();
|
|
|
|
|
|
|
|
if (control->set_image_index(idx))
|
|
|
|
{
|
|
|
|
if (idx < num_disks)
|
|
|
|
snprintf(msg, sizeof(msg), "Setting disk %u of %u in tray.",
|
|
|
|
idx + 1, num_disks);
|
|
|
|
else
|
2015-07-01 21:00:23 +00:00
|
|
|
strlcpy(msg,
|
|
|
|
msg_hash_to_str(MSG_REMOVED_DISK_FROM_TRAY),
|
|
|
|
sizeof(msg));
|
2015-04-13 09:37:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (idx < num_disks)
|
|
|
|
snprintf(msg, sizeof(msg), "Failed to set disk %u of %u.",
|
|
|
|
idx + 1, num_disks);
|
|
|
|
else
|
2015-07-01 21:00:23 +00:00
|
|
|
strlcpy(msg,
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_REMOVE_DISK_FROM_TRAY),
|
|
|
|
sizeof(msg));
|
2015-04-13 09:37:38 +00:00
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*msg)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
else
|
|
|
|
RARCH_LOG("%s\n", msg);
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2015-04-13 09:37:38 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
2015-07-28 01:06:45 +00:00
|
|
|
/**
|
|
|
|
* event_disk_control_append_image:
|
|
|
|
* @path : Path to disk image.
|
|
|
|
*
|
|
|
|
* Appends disk image to disk image list.
|
|
|
|
**/
|
|
|
|
void event_disk_control_append_image(const char *path)
|
|
|
|
{
|
|
|
|
unsigned new_idx;
|
2015-12-10 21:30:25 +00:00
|
|
|
char msg[128] = {0};
|
|
|
|
struct retro_game_info info = {0};
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
const struct retro_disk_control_callback *control = NULL;
|
|
|
|
rarch_system_info_t *sysinfo = NULL;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo);
|
|
|
|
|
|
|
|
if (sysinfo)
|
|
|
|
control = (const struct retro_disk_control_callback*)&sysinfo->disk_control;
|
2015-07-28 01:06:45 +00:00
|
|
|
|
|
|
|
if (!control)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event_disk_control_set_eject(true, false);
|
|
|
|
|
|
|
|
control->add_image_index();
|
|
|
|
new_idx = control->get_num_images();
|
|
|
|
if (!new_idx)
|
|
|
|
return;
|
|
|
|
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);
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 0, 180, true);
|
2015-07-28 01:06:45 +00:00
|
|
|
|
|
|
|
event_command(EVENT_CMD_AUTOSAVE_DEINIT);
|
|
|
|
|
|
|
|
/* TODO: Need to figure out what to do with subsystems case. */
|
|
|
|
if (!*global->subsystem)
|
|
|
|
{
|
|
|
|
/* 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. */
|
|
|
|
rarch_set_paths(path);
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL);
|
2015-07-28 01:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event_command(EVENT_CMD_AUTOSAVE_INIT);
|
|
|
|
event_disk_control_set_index(new_idx);
|
|
|
|
event_disk_control_set_eject(false, false);
|
|
|
|
}
|
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
/**
|
|
|
|
* event_check_disk_prev:
|
|
|
|
* @control : Handle to disk control handle.
|
|
|
|
*
|
|
|
|
* Perform disk cycle to previous index action (Core Disk Options).
|
|
|
|
**/
|
|
|
|
static void event_check_disk_prev(
|
|
|
|
const struct retro_disk_control_callback *control)
|
|
|
|
{
|
2015-06-25 13:42:05 +00:00
|
|
|
unsigned num_disks = 0;
|
|
|
|
unsigned current = 0;
|
|
|
|
bool disk_prev_enable = false;
|
|
|
|
|
2015-12-09 09:59:27 +00:00
|
|
|
if (!control || !control->get_num_images)
|
2015-06-25 13:42:05 +00:00
|
|
|
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;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!disk_prev_enable)
|
|
|
|
{
|
2015-07-01 21:00:23 +00:00
|
|
|
RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX));
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current > 0)
|
|
|
|
current--;
|
2015-04-13 09:37:38 +00:00
|
|
|
event_disk_control_set_index(current);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_check_disk_next:
|
|
|
|
* @control : Handle to disk control handle.
|
|
|
|
*
|
|
|
|
* Perform disk cycle to next index action (Core Disk Options).
|
|
|
|
**/
|
|
|
|
static void event_check_disk_next(
|
|
|
|
const struct retro_disk_control_callback *control)
|
|
|
|
{
|
2015-06-25 13:42:05 +00:00
|
|
|
unsigned num_disks = 0;
|
|
|
|
unsigned current = 0;
|
|
|
|
bool disk_next_enable = false;
|
|
|
|
|
2015-12-09 09:59:27 +00:00
|
|
|
if (!control || !control->get_num_images)
|
2015-06-25 13:42:05 +00:00
|
|
|
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;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!disk_next_enable)
|
|
|
|
{
|
2015-07-01 21:00:23 +00:00
|
|
|
RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX));
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current < num_disks - 1)
|
|
|
|
current++;
|
2015-04-13 09:37:38 +00:00
|
|
|
event_disk_control_set_index(current);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_set_volume:
|
|
|
|
* @gain : amount of gain to be applied to current volume level.
|
|
|
|
*
|
|
|
|
* Adjusts the current audio volume level.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
static void event_set_volume(float gain)
|
|
|
|
{
|
2015-12-09 09:59:27 +00:00
|
|
|
char msg[128];
|
2015-06-12 15:10:16 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
settings->audio.volume += gain;
|
|
|
|
settings->audio.volume = max(settings->audio.volume, -80.0f);
|
|
|
|
settings->audio.volume = min(settings->audio.volume, 12.0f);
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume);
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2015-04-13 09:15:40 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
|
2015-05-19 19:18:07 +00:00
|
|
|
audio_driver_set_volume_gain(db_to_gain(settings->audio.volume));
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_init_controllers:
|
|
|
|
*
|
|
|
|
* Initialize libretro controllers.
|
|
|
|
**/
|
|
|
|
static void event_init_controllers(void)
|
|
|
|
{
|
|
|
|
unsigned i;
|
2015-12-09 09:59:27 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-12-10 21:30:25 +00:00
|
|
|
rarch_system_info_t *info = NULL;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_USERS; i++)
|
|
|
|
{
|
|
|
|
const char *ident = NULL;
|
|
|
|
const struct retro_controller_description *desc = NULL;
|
|
|
|
unsigned device = settings->input.libretro_device[i];
|
|
|
|
|
2015-06-25 10:45:23 +00:00
|
|
|
if (i < info->num_ports)
|
2015-04-13 09:15:40 +00:00
|
|
|
desc = libretro_find_controller_description(
|
2015-06-25 10:45:23 +00:00
|
|
|
&info->ports[i], device);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (desc)
|
|
|
|
ident = desc->desc;
|
|
|
|
|
|
|
|
if (!ident)
|
|
|
|
{
|
|
|
|
/* If we're trying to connect a completely unknown device,
|
|
|
|
* revert back to JOYPAD. */
|
2015-05-08 00:59:06 +00:00
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE)
|
|
|
|
{
|
|
|
|
/* Do not fix settings->input.libretro_device[i],
|
|
|
|
* 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:
|
|
|
|
RARCH_LOG("Disconnecting device from port %u.\n", i + 1);
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_set_controller_port_device(i, device);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Some cores do not properly range check port argument.
|
|
|
|
* This is broken behavior of course, but avoid breaking
|
|
|
|
* cores needlessly. */
|
|
|
|
RARCH_LOG("Connecting %s (ID: %u) to port %u.\n", ident,
|
|
|
|
device, i + 1);
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_set_controller_port_device(i, device);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_deinit_core(bool reinit)
|
|
|
|
{
|
2015-10-16 16:04:59 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
|
|
|
/* Unload the achievements from memory. */
|
|
|
|
cheevos_unload();
|
|
|
|
#endif
|
|
|
|
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_unload_game();
|
|
|
|
core.retro_deinit();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (reinit)
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_DRIVERS_DEINIT);
|
2015-05-08 00:59:06 +00:00
|
|
|
|
2015-05-25 23:29:52 +00:00
|
|
|
/* auto overrides: reload the original config */
|
2015-12-10 20:43:44 +00:00
|
|
|
if(runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
|
|
|
config_unload_override();
|
2015-12-10 20:43:44 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
2015-05-08 00:59:06 +00:00
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
uninit_libretro_sym();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_init_cheats(void)
|
|
|
|
{
|
|
|
|
bool allow_cheats = true;
|
2015-11-30 23:04:04 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:38:24 +00:00
|
|
|
allow_cheats &= !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
2015-11-30 23:04:04 +00:00
|
|
|
allow_cheats &= !bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!allow_cheats)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* TODO/FIXME - add some stuff here. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool event_load_save_files(void)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2015-06-25 14:17:46 +00:00
|
|
|
if (!global)
|
|
|
|
return false;
|
2015-07-27 15:18:10 +00:00
|
|
|
if (!global->savefiles || global->sram.load_disable)
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < global->savefiles->size; i++)
|
|
|
|
load_ram_file(global->savefiles->elems[i].data,
|
|
|
|
global->savefiles->elems[i].attr.i);
|
2015-05-08 00:59:06 +00:00
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_load_auto_state(void)
|
|
|
|
{
|
|
|
|
bool ret;
|
2015-12-06 12:28:20 +00:00
|
|
|
char msg[128] = {0};
|
2015-06-12 15:10:16 +00:00
|
|
|
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
|
2015-04-13 09:15:40 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-07-27 15:18:10 +00:00
|
|
|
if (global->netplay.enable && !global->netplay.is_spectate)
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!settings->savestate_auto_load)
|
|
|
|
return;
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
2015-04-13 09:15:40 +00:00
|
|
|
".auto", sizeof(savestate_name_auto));
|
|
|
|
|
|
|
|
if (!path_file_exists(savestate_name_auto))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ret = load_state(savestate_name_auto);
|
|
|
|
|
|
|
|
RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto);
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg), "Auto-loading savestate from \"%s\" %s.",
|
|
|
|
savestate_name_auto, ret ? "succeeded" : "failed");
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, false);
|
2015-04-13 09:15:40 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_set_savestate_auto_index(void)
|
|
|
|
{
|
|
|
|
size_t i;
|
2015-06-12 15:10:16 +00:00
|
|
|
char state_dir[PATH_MAX_LENGTH] = {0};
|
|
|
|
char state_base[PATH_MAX_LENGTH] = {0};
|
|
|
|
struct string_list *dir_list = NULL;
|
|
|
|
unsigned max_idx = 0;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!settings->savestate_auto_index)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
fill_pathname_basedir(state_dir, global->name.savestate,
|
2015-04-13 09:15:40 +00:00
|
|
|
sizeof(state_dir));
|
2015-07-27 15:18:10 +00:00
|
|
|
fill_pathname_base(state_base, global->name.savestate,
|
2015-04-13 09:15:40 +00:00
|
|
|
sizeof(state_base));
|
|
|
|
|
2015-10-26 20:30:58 +00:00
|
|
|
if (!(dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL)))
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < dir_list->size; i++)
|
|
|
|
{
|
|
|
|
unsigned idx;
|
2015-12-06 12:28:20 +00:00
|
|
|
char elem_base[128] = {0};
|
2015-06-12 15:10:16 +00:00
|
|
|
const char *end = NULL;
|
|
|
|
const char *dir_elem = dir_list->elems[i].data;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
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);
|
2015-09-05 12:31:07 +00:00
|
|
|
while ((end > dir_elem) && isdigit((int)end[-1]))
|
2015-04-13 09:15:40 +00:00
|
|
|
end--;
|
|
|
|
|
|
|
|
idx = strtoul(end, NULL, 0);
|
|
|
|
if (idx > max_idx)
|
|
|
|
max_idx = idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir_list_free(dir_list);
|
|
|
|
|
|
|
|
settings->state_slot = max_idx;
|
|
|
|
RARCH_LOG("Found last state slot: #%d\n", settings->state_slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool event_init_content(void)
|
|
|
|
{
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
/* No content to be loaded for dummy core,
|
|
|
|
* just successfully exit. */
|
2015-10-20 00:43:21 +00:00
|
|
|
if (global->inited.core.type == CORE_TYPE_DUMMY)
|
2015-04-22 21:15:19 +00:00
|
|
|
return true;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (!global->inited.core.no_content)
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!init_content_file())
|
|
|
|
return false;
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (global->inited.core.no_content)
|
2015-04-13 09:15:40 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
event_set_savestate_auto_index();
|
|
|
|
|
|
|
|
if (event_load_save_files())
|
2015-07-01 20:14:37 +00:00
|
|
|
RARCH_LOG("%s.\n",
|
|
|
|
msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD));
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
event_load_auto_state();
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_BSV_MOVIE_INIT);
|
|
|
|
event_command(EVENT_CMD_NETPLAY_INIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool event_init_core(void)
|
|
|
|
{
|
2015-04-22 21:15:19 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-04-18 01:07:15 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2015-05-08 01:16:51 +00:00
|
|
|
/* auto overrides: apply overrides */
|
2015-04-18 01:07:15 +00:00
|
|
|
if(settings->auto_overrides_enable)
|
|
|
|
{
|
|
|
|
if (config_load_override())
|
2015-12-10 20:43:44 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
2015-04-18 01:07:15 +00:00
|
|
|
else
|
2015-12-10 20:43:44 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2015-04-18 01:07:15 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-07-05 19:49:08 +00:00
|
|
|
/* reset video format to libretro's default */
|
|
|
|
video_driver_set_pixel_format(RETRO_PIXEL_FORMAT_0RGB1555);
|
|
|
|
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_set_environment(rarch_environment_cb);
|
2015-05-07 23:06:14 +00:00
|
|
|
|
2015-05-08 01:16:51 +00:00
|
|
|
/* auto-remap: apply remap files */
|
2015-04-18 01:10:26 +00:00
|
|
|
if(settings->auto_remaps_enable)
|
|
|
|
config_load_remap();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-05-08 01:16:51 +00:00
|
|
|
/* per-core saves: reset redirection paths */
|
2015-10-20 00:43:21 +00:00
|
|
|
if((settings->sort_savestates_enable || settings->sort_savefiles_enable) && !global->inited.core.no_content)
|
2015-12-07 13:30:36 +00:00
|
|
|
rarch_ctl(RARCH_CTL_SET_PATHS_REDIRECT, NULL);
|
2015-05-07 23:06:14 +00:00
|
|
|
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_VERIFY_API_VERSION, NULL);
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_init();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
global->sram.use = (global->inited.core.type == CORE_TYPE_PLAIN) &&
|
|
|
|
!global->inited.core.no_content;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!event_init_content())
|
|
|
|
return false;
|
|
|
|
|
2015-12-05 15:54:03 +00:00
|
|
|
retro_init_libretro_cbs(&retro_ctx);
|
2015-04-22 21:15:19 +00:00
|
|
|
rarch_init_system_av_info();
|
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool event_save_auto_state(void)
|
|
|
|
{
|
|
|
|
bool ret;
|
2015-06-12 15:10:16 +00:00
|
|
|
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
|
2015-04-13 09:15:40 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2015-10-20 00:43:21 +00:00
|
|
|
if (!settings->savestate_auto_save ||
|
2015-07-27 15:18:10 +00:00
|
|
|
(global->inited.core.type == CORE_TYPE_DUMMY) ||
|
|
|
|
global->inited.core.no_content)
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
2015-04-13 09:15:40 +00:00
|
|
|
".auto", sizeof(savestate_name_auto));
|
|
|
|
|
|
|
|
ret = save_state(savestate_name_auto);
|
|
|
|
RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ?
|
|
|
|
"succeeded" : "failed");
|
2015-05-08 00:59:06 +00:00
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_init_remapping(void)
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-11-15 21:02:24 +00:00
|
|
|
const char *path = settings->input.remapping_path;
|
|
|
|
config_file_t *conf = config_file_new(path);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-11-15 21:02:24 +00:00
|
|
|
if (!settings->input.remap_binds_enable || !conf)
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
|
2015-11-15 21:02:24 +00:00
|
|
|
input_remapping_load_file(conf, path);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_save_core_config:
|
|
|
|
*
|
|
|
|
* Saves a new (core) configuration to a file. Filename is based
|
|
|
|
* on heuristics to avoid typing.
|
|
|
|
*
|
|
|
|
* Returns: true (1) on success, otherwise false (0).
|
|
|
|
**/
|
|
|
|
static bool event_save_core_config(void)
|
|
|
|
{
|
2015-06-12 15:10:16 +00:00
|
|
|
char config_dir[PATH_MAX_LENGTH] = {0};
|
|
|
|
char config_name[PATH_MAX_LENGTH] = {0};
|
|
|
|
char config_path[PATH_MAX_LENGTH] = {0};
|
2015-12-06 12:28:20 +00:00
|
|
|
char msg[128] = {0};
|
2015-06-12 15:10:16 +00:00
|
|
|
bool ret = false;
|
|
|
|
bool found_path = false;
|
|
|
|
bool overrides_active = false;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
*config_dir = '\0';
|
|
|
|
|
|
|
|
if (*settings->menu_config_directory)
|
|
|
|
strlcpy(config_dir, settings->menu_config_directory,
|
|
|
|
sizeof(config_dir));
|
2015-07-27 15:18:10 +00:00
|
|
|
else if (*global->path.config) /* Fallback */
|
|
|
|
fill_pathname_basedir(config_dir, global->path.config,
|
2015-04-13 09:15:40 +00:00
|
|
|
sizeof(config_dir));
|
|
|
|
else
|
|
|
|
{
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(MSG_CONFIG_DIRECTORY_NOT_SET, 1, 180, true);
|
2015-07-01 20:14:37 +00:00
|
|
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Infer file name based on libretro core. */
|
|
|
|
if (*settings->libretro && path_file_exists(settings->libretro))
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
/* In case of collision, find an alternative name. */
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
2015-06-12 15:10:16 +00:00
|
|
|
char tmp[64] = {0};
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
fill_pathname_base(config_name, settings->libretro,
|
|
|
|
sizeof(config_name));
|
|
|
|
path_remove_extension(config_name);
|
|
|
|
fill_pathname_join(config_path, config_dir, config_name,
|
|
|
|
sizeof(config_path));
|
|
|
|
|
|
|
|
*tmp = '\0';
|
|
|
|
|
|
|
|
if (i)
|
|
|
|
snprintf(tmp, sizeof(tmp), "-%u.cfg", i);
|
|
|
|
else
|
|
|
|
strlcpy(tmp, ".cfg", sizeof(tmp));
|
|
|
|
|
|
|
|
strlcat(config_path, tmp, sizeof(config_path));
|
|
|
|
|
|
|
|
if (!path_file_exists(config_path))
|
|
|
|
{
|
|
|
|
found_path = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fallback to system time... */
|
|
|
|
if (!found_path)
|
|
|
|
{
|
|
|
|
RARCH_WARN("Cannot infer new config path. Use current time.\n");
|
|
|
|
fill_dated_filename(config_name, "cfg", sizeof(config_name));
|
|
|
|
fill_pathname_join(config_path, config_dir, config_name,
|
|
|
|
sizeof(config_path));
|
|
|
|
}
|
|
|
|
|
2015-04-17 23:52:10 +00:00
|
|
|
/* Overrides block config file saving, make it appear as overrides weren't enabled for a manual save */
|
2015-12-10 20:43:44 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
|
2015-04-17 23:52:10 +00:00
|
|
|
{
|
2015-12-10 20:43:44 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
|
|
|
overrides_active = true;
|
2015-04-17 23:52:10 +00:00
|
|
|
}
|
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
if ((ret = config_save_file(config_path)))
|
|
|
|
{
|
2015-07-27 15:18:10 +00:00
|
|
|
strlcpy(global->path.config, config_path,
|
|
|
|
sizeof(global->path.config));
|
2015-04-13 09:15:40 +00:00
|
|
|
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".",
|
|
|
|
config_path);
|
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".",
|
|
|
|
config_path);
|
|
|
|
RARCH_ERR("%s\n", msg);
|
|
|
|
}
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2015-12-10 20:43:44 +00:00
|
|
|
|
|
|
|
if (overrides_active)
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL);
|
|
|
|
else
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-11-11 01:57:20 +00:00
|
|
|
/**
|
|
|
|
* event_save_current_config:
|
|
|
|
*
|
|
|
|
* Saves current configuration file to disk, and (optionally)
|
|
|
|
* autosave state.
|
|
|
|
**/
|
|
|
|
void event_save_current_config(void)
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
if (settings->config_save_on_exit && *global->path.config)
|
|
|
|
{
|
|
|
|
/* Save last core-specific config to the default config location,
|
|
|
|
* needed on consoles for core switching and reusing last good
|
|
|
|
* config for new cores.
|
|
|
|
*/
|
|
|
|
config_save_file(global->path.config);
|
|
|
|
|
|
|
|
/* Flush out the core specific config. */
|
|
|
|
if (*global->path.core_specific_config &&
|
|
|
|
settings->core_specific_config)
|
|
|
|
config_save_file(global->path.core_specific_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
event_command(EVENT_CMD_AUTOSAVE_STATE);
|
|
|
|
}
|
|
|
|
|
2015-04-13 09:15:40 +00:00
|
|
|
/**
|
|
|
|
* event_save_state
|
|
|
|
* @path : Path to state.
|
2015-06-02 16:28:51 +00:00
|
|
|
* @s : Message.
|
|
|
|
* @len : Size of @s.
|
2015-04-13 09:15:40 +00:00
|
|
|
*
|
|
|
|
* Saves a state with path being @path.
|
|
|
|
**/
|
|
|
|
static void event_save_state(const char *path,
|
2015-06-02 16:28:51 +00:00
|
|
|
char *s, size_t len)
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!save_state(path))
|
|
|
|
{
|
2015-07-02 22:16:46 +00:00
|
|
|
snprintf(s, len, "%s \"%s\".",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO),
|
|
|
|
path);
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->state_slot < 0)
|
2015-07-01 20:14:37 +00:00
|
|
|
snprintf(s, len, "%s #-1 (auto).", msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT));
|
2015-04-13 09:15:40 +00:00
|
|
|
else
|
2015-07-01 20:14:37 +00:00
|
|
|
snprintf(s, len, "%s #%d.", msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT),
|
|
|
|
settings->state_slot);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* event_load_state
|
|
|
|
* @path : Path to state.
|
2015-06-02 16:28:51 +00:00
|
|
|
* @s : Message.
|
|
|
|
* @len : Size of @s.
|
2015-04-13 09:15:40 +00:00
|
|
|
*
|
|
|
|
* Loads a state with path being @path.
|
|
|
|
**/
|
2015-06-02 16:28:51 +00:00
|
|
|
static void event_load_state(const char *path, char *s, size_t len)
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!load_state(path))
|
|
|
|
{
|
2015-07-01 20:14:37 +00:00
|
|
|
snprintf(s, len, "%s \"%s\".",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
|
|
|
|
path);
|
2015-04-13 09:15:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->state_slot < 0)
|
2015-07-01 20:14:37 +00:00
|
|
|
snprintf(s, len, "%s #-1 (auto).", msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT));
|
2015-04-13 09:15:40 +00:00
|
|
|
else
|
2015-07-01 20:14:37 +00:00
|
|
|
snprintf(s, len, "%s #%d.", msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT),
|
|
|
|
settings->state_slot);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void event_main_state(unsigned cmd)
|
|
|
|
{
|
2015-06-12 15:10:16 +00:00
|
|
|
char path[PATH_MAX_LENGTH] = {0};
|
2015-12-06 12:28:20 +00:00
|
|
|
char msg[128] = {0};
|
2015-06-12 15:10:16 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (settings->state_slot > 0)
|
|
|
|
snprintf(path, sizeof(path), "%s%d",
|
2015-07-27 15:18:10 +00:00
|
|
|
global->name.savestate, settings->state_slot);
|
2015-04-13 09:15:40 +00:00
|
|
|
else if (settings->state_slot < 0)
|
2015-07-01 20:14:37 +00:00
|
|
|
fill_pathname_join_delim(path,
|
2015-07-27 15:18:10 +00:00
|
|
|
global->name.savestate, "auto", '.', sizeof(path));
|
2015-04-13 09:15:40 +00:00
|
|
|
else
|
2015-07-27 15:18:10 +00:00
|
|
|
strlcpy(path, global->name.savestate, sizeof(path));
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-10-06 17:34:09 +00:00
|
|
|
if (core.retro_serialize_size())
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-07-01 20:14:37 +00:00
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
case EVENT_CMD_SAVE_STATE:
|
|
|
|
event_save_state(path, msg, sizeof(msg));
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_LOAD_STATE:
|
|
|
|
event_load_state(path, msg, sizeof(msg));
|
|
|
|
break;
|
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
else
|
2015-07-01 20:14:37 +00:00
|
|
|
strlcpy(msg, msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg));
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 2, 180, true);
|
2015-04-13 09:15:40 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
}
|
|
|
|
|
2015-10-27 23:55:11 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-04-13 09:15:40 +00:00
|
|
|
static bool event_update_system_info(struct retro_system_info *_info,
|
|
|
|
bool *load_no_content)
|
|
|
|
{
|
2015-12-11 12:51:17 +00:00
|
|
|
core_info_list_t *core_info_list = NULL;
|
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_DYNAMIC)
|
|
|
|
if (!(*settings->libretro))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
libretro_get_system_info(settings->libretro, _info,
|
|
|
|
load_no_content);
|
|
|
|
#endif
|
2015-12-11 12:28:23 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_GET, &core_info);
|
2015-12-11 12:51:17 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &core_info_list);
|
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return false;
|
2015-12-11 12:28:23 +00:00
|
|
|
|
2015-12-11 12:51:17 +00:00
|
|
|
if (!core_info_list_get_info(core_info_list,
|
2015-12-11 12:28:23 +00:00
|
|
|
core_info, settings->libretro))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-10-27 23:55:11 +00:00
|
|
|
#endif
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-13 09:26:02 +00:00
|
|
|
* event_command:
|
2015-04-13 09:15:40 +00:00
|
|
|
* @cmd : Event command index.
|
|
|
|
*
|
2015-06-30 13:26:14 +00:00
|
|
|
* Performs program event command with index @cmd.
|
2015-04-13 09:15:40 +00:00
|
|
|
*
|
|
|
|
* Returns: true (1) on success, otherwise false (0).
|
|
|
|
**/
|
2015-04-20 16:40:46 +00:00
|
|
|
bool event_command(enum event_command cmd)
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-12-10 21:30:25 +00:00
|
|
|
unsigned i = 0;
|
|
|
|
bool boolean = false;
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
rarch_system_info_t *info = NULL;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
(void)i;
|
|
|
|
|
|
|
|
switch (cmd)
|
|
|
|
{
|
2015-12-12 16:25:03 +00:00
|
|
|
case EVENT_CMD_MENU_REFRESH:
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_REFRESH, NULL);
|
|
|
|
#endif
|
|
|
|
break;
|
2015-11-21 07:56:24 +00:00
|
|
|
case EVENT_CMD_SET_PER_GAME_RESOLUTION:
|
2015-11-21 08:31:08 +00:00
|
|
|
#if defined(GEKKO)
|
2015-11-21 07:56:24 +00:00
|
|
|
{
|
|
|
|
unsigned width = 0, height = 0;
|
|
|
|
|
|
|
|
event_command(EVENT_CMD_VIDEO_SET_ASPECT_RATIO);
|
|
|
|
|
|
|
|
if (video_driver_get_video_output_size(&width, &height))
|
|
|
|
{
|
2015-12-06 12:28:20 +00:00
|
|
|
char msg[128] = {0};
|
|
|
|
|
2015-11-21 07:56:24 +00:00
|
|
|
video_driver_set_video_mode(width, height, true);
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg),"Resolution: %dx%d",width, height);
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 100, true);
|
2015-11-21 07:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-21 08:31:08 +00:00
|
|
|
#endif
|
2015-11-21 07:56:24 +00:00
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_LOAD_CONTENT_PERSIST:
|
|
|
|
#ifdef HAVE_DYNAMIC
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_CORE);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
2015-06-23 04:44:29 +00:00
|
|
|
#ifdef HAVE_FFMPEG
|
|
|
|
case EVENT_CMD_LOAD_CONTENT_FFMPEG:
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_LOAD_CONTENT_FFMPEG, NULL);
|
2015-06-23 04:44:29 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2015-06-28 15:21:32 +00:00
|
|
|
case EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER:
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, NULL);
|
2015-06-28 15:21:32 +00:00
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_LOAD_CONTENT:
|
2015-11-18 10:43:25 +00:00
|
|
|
{
|
2015-04-13 09:15:40 +00:00
|
|
|
#ifdef HAVE_DYNAMIC
|
2015-11-18 10:43:25 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_CONTENT_PERSIST);
|
2015-04-13 09:15:40 +00:00
|
|
|
#else
|
2015-11-18 10:43:25 +00:00
|
|
|
char *fullpath = NULL;
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
|
2015-11-18 10:43:25 +00:00
|
|
|
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH,
|
|
|
|
(void*)settings->libretro);
|
|
|
|
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)fullpath);
|
|
|
|
event_command(EVENT_CMD_QUIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
2015-11-18 10:43:25 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_LOAD_CORE_DEINIT:
|
2015-10-27 23:55:11 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-10 22:08:34 +00:00
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_LOAD_CORE_PERSIST:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_CORE_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_MENU
|
2015-12-07 15:11:53 +00:00
|
|
|
bool *ptr = NULL;
|
2015-12-10 22:08:34 +00:00
|
|
|
struct retro_system_info *system = NULL;
|
|
|
|
|
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system);
|
|
|
|
|
2015-12-07 15:11:53 +00:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_LOAD_NO_CONTENT_GET, &ptr))
|
2015-12-10 22:08:34 +00:00
|
|
|
event_update_system_info(system, ptr);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_LOAD_CORE:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_CORE_PERSIST);
|
2015-04-13 09:15:40 +00:00
|
|
|
#ifndef HAVE_DYNAMIC
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_QUIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_LOAD_STATE:
|
2015-10-20 00:43:21 +00:00
|
|
|
/* Immutable - disallow savestate load when
|
2015-04-13 09:15:40 +00:00
|
|
|
* we absolutely cannot change game state. */
|
2015-11-30 23:04:04 +00:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:38:24 +00:00
|
|
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
event_main_state(cmd);
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_RESIZE_WINDOWED_SCALE:
|
2015-11-18 10:55:11 +00:00
|
|
|
{
|
|
|
|
unsigned idx = 0;
|
2015-12-01 02:46:56 +00:00
|
|
|
unsigned *window_scale = NULL;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_GET_WINDOWED_SCALE, &window_scale);
|
|
|
|
|
|
|
|
if (*window_scale == 0)
|
2015-11-18 10:55:11 +00:00
|
|
|
return false;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-12-01 02:46:56 +00:00
|
|
|
settings->video.scale = *window_scale;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-11-18 10:55:11 +00:00
|
|
|
if (!settings->video.fullscreen)
|
|
|
|
event_command(EVENT_CMD_REINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx);
|
2015-11-18 10:55:11 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_MENU_TOGGLE:
|
2015-10-09 18:40:05 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-05 12:49:22 +00:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
else
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
2015-10-09 18:40:05 +00:00
|
|
|
#endif
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_CONTROLLERS_INIT:
|
|
|
|
event_init_controllers();
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_RESET:
|
2015-07-02 16:27:20 +00:00
|
|
|
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET));
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(MSG_RESET, 1, 120, true);
|
2015-10-30 01:25:41 +00:00
|
|
|
|
2015-10-27 17:50:41 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2015-12-07 12:30:03 +00:00
|
|
|
cheevos_set_cheats();
|
2015-10-27 17:50:41 +00:00
|
|
|
#endif
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_reset();
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
/* bSNES since v073r01 resets controllers to JOYPAD
|
|
|
|
* after a reset, so just enforce it here. */
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_CONTROLLERS_INIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_SAVE_STATE:
|
|
|
|
if (settings->savestate_auto_index)
|
|
|
|
settings->state_slot++;
|
|
|
|
|
|
|
|
event_main_state(cmd);
|
|
|
|
break;
|
2015-09-01 23:15:10 +00:00
|
|
|
case EVENT_CMD_SAVE_STATE_DECREMENT:
|
|
|
|
/* Slot -1 is (auto) slot. */
|
|
|
|
if (settings->state_slot >= 0)
|
|
|
|
settings->state_slot--;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_SAVE_STATE_INCREMENT:
|
|
|
|
settings->state_slot++;
|
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_TAKE_SCREENSHOT:
|
|
|
|
if (!take_screenshot())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_UNLOAD_CORE:
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL);
|
2015-05-23 15:38:14 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_CORE_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_QUIT:
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_QUIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_REINIT:
|
2015-05-20 17:56:12 +00:00
|
|
|
{
|
|
|
|
const struct retro_hw_render_callback *hw_render =
|
|
|
|
(const struct retro_hw_render_callback*)video_driver_callback();
|
|
|
|
|
2015-11-29 19:44:51 +00:00
|
|
|
if (hw_render->cache_context)
|
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT, NULL);
|
|
|
|
else
|
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, NULL);
|
|
|
|
|
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, NULL);
|
2015-05-20 17:56:12 +00:00
|
|
|
event_command(EVENT_CMD_RESET_CONTEXT);
|
2015-11-29 19:44:51 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-05-20 17:56:12 +00:00
|
|
|
/* Poll input to avoid possibly stale data to corrupt things. */
|
2015-11-25 19:39:46 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_POLL, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
2015-09-25 11:27:15 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, NULL);
|
2015-05-11 16:46:06 +00:00
|
|
|
|
2015-12-05 12:49:22 +00:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-05-20 17:56:12 +00:00
|
|
|
event_command(EVENT_CMD_VIDEO_SET_BLOCKING_STATE);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
2015-05-20 17:56:12 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_CHEATS_DEINIT:
|
2015-12-01 01:43:34 +00:00
|
|
|
cheat_manager_state_free();
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_CHEATS_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_CHEATS_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
event_init_cheats();
|
|
|
|
break;
|
2015-09-01 23:10:44 +00:00
|
|
|
case EVENT_CMD_CHEATS_APPLY:
|
2015-12-01 01:43:34 +00:00
|
|
|
cheat_manager_apply_cheats();
|
2015-09-01 23:10:44 +00:00
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_REMAPPING_DEINIT:
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_REMAPPING_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_REMAPPING_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
event_init_remapping();
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_REWIND_DEINIT:
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:38:24 +00:00
|
|
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
#endif
|
2015-11-30 21:25:13 +00:00
|
|
|
state_manager_event_deinit();
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_REWIND_INIT:
|
2015-12-05 15:51:02 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:38:24 +00:00
|
|
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
2015-12-05 15:51:02 +00:00
|
|
|
#endif
|
2015-09-05 17:24:21 +00:00
|
|
|
init_rewind();
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_REWIND_TOGGLE:
|
|
|
|
if (settings->rewind_enable)
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_REWIND_INIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
else
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_REWIND_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUTOSAVE_DEINIT:
|
|
|
|
#ifdef HAVE_THREADS
|
2015-11-30 18:23:13 +00:00
|
|
|
autosave_event_deinit();
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUTOSAVE_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUTOSAVE_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2015-11-30 18:23:13 +00:00
|
|
|
autosave_event_init();
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUTOSAVE_STATE:
|
|
|
|
event_save_auto_state();
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUDIO_STOP:
|
2015-11-22 13:17:46 +00:00
|
|
|
if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
2015-11-22 13:23:29 +00:00
|
|
|
if (!audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUDIO_START:
|
2015-11-23 18:22:18 +00:00
|
|
|
if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
2015-11-22 13:23:29 +00:00
|
|
|
if (!settings->audio.mute_enable && !audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
|
|
|
RARCH_ERR("Failed to start audio driver. Will continue without audio.\n");
|
2015-11-29 20:34:45 +00:00
|
|
|
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUDIO_MUTE_TOGGLE:
|
|
|
|
{
|
|
|
|
const char *msg = !settings->audio.mute_enable ?
|
2015-07-01 20:14:37 +00:00
|
|
|
msg_hash_to_str(MSG_AUDIO_MUTED):
|
|
|
|
msg_hash_to_str(MSG_AUDIO_UNMUTED);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-11-22 13:30:31 +00:00
|
|
|
if (!audio_driver_ctl(RARCH_AUDIO_CTL_MUTE_TOGGLE, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-07-01 20:14:37 +00:00
|
|
|
RARCH_ERR("%s.\n",
|
|
|
|
msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO));
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2015-04-13 09:15:40 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_OVERLAY_DEINIT:
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-11-23 17:15:19 +00:00
|
|
|
input_overlay_free();
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_OVERLAY_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_OVERLAY_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-11-23 17:15:19 +00:00
|
|
|
input_overlay_init();
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_OVERLAY_NEXT:
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_next(settings->input.overlay_opacity);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_DSP_FILTER_DEINIT:
|
2015-05-19 19:18:07 +00:00
|
|
|
audio_driver_dsp_filter_free();
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_DSP_FILTER_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_DSP_FILTER_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
if (!*settings->audio.dsp_plugin)
|
|
|
|
break;
|
2015-05-19 19:18:07 +00:00
|
|
|
audio_driver_dsp_filter_init(settings->audio.dsp_plugin);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_GPU_RECORD_DEINIT:
|
2015-12-06 14:22:20 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_RECORD_DEINIT:
|
|
|
|
if (!recording_deinit())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_RECORD_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_HISTORY_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
if (!recording_init())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_HISTORY_DEINIT:
|
|
|
|
if (g_defaults.history)
|
2015-06-09 20:44:03 +00:00
|
|
|
{
|
|
|
|
content_playlist_write_file(g_defaults.history);
|
2015-04-13 09:15:40 +00:00
|
|
|
content_playlist_free(g_defaults.history);
|
2015-06-09 20:44:03 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
g_defaults.history = NULL;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_HISTORY_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_HISTORY_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
if (!settings->history_list_enable)
|
|
|
|
return false;
|
2015-07-02 22:16:46 +00:00
|
|
|
RARCH_LOG("%s: [%s].\n",
|
|
|
|
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
|
|
|
settings->content_history_path);
|
2015-04-13 09:15:40 +00:00
|
|
|
g_defaults.history = content_playlist_init(
|
|
|
|
settings->content_history_path,
|
|
|
|
settings->content_history_size);
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_CORE_INFO_DEINIT:
|
2015-12-11 12:33:07 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_FREE, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_CORE_INFO_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_CORE_INFO_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (*settings->libretro_directory)
|
2015-12-11 12:51:17 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_INIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_CORE_DEINIT:
|
2015-07-01 20:14:37 +00:00
|
|
|
{
|
|
|
|
struct retro_hw_render_callback *cb = video_driver_callback();
|
|
|
|
event_deinit_core(true);
|
2015-05-23 19:26:50 +00:00
|
|
|
|
2015-07-01 20:14:37 +00:00
|
|
|
if (cb)
|
|
|
|
memset(cb, 0, sizeof(*cb));
|
2015-05-23 19:26:50 +00:00
|
|
|
|
2015-07-01 20:14:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_CORE_INIT:
|
|
|
|
if (!event_init_core())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_VIDEO_APPLY_STATE_CHANGES:
|
2015-11-20 14:55:09 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_APPLY_STATE_CHANGES, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE:
|
|
|
|
boolean = true; /* fall-through */
|
|
|
|
case EVENT_CMD_VIDEO_SET_BLOCKING_STATE:
|
2015-11-20 16:22:19 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE, &boolean);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_VIDEO_SET_ASPECT_RATIO:
|
2015-11-20 17:45:00 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_SET_ASPECT_RATIO, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE:
|
|
|
|
boolean = true; /* fall-through */
|
|
|
|
case EVENT_CMD_AUDIO_SET_BLOCKING_STATE:
|
2015-11-22 14:16:03 +00:00
|
|
|
audio_driver_set_nonblocking_state(boolean);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_OVERLAY_SET_SCALE_FACTOR:
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_set_scale_factor(settings->input.overlay_scale);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_OVERLAY_SET_ALPHA_MOD:
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_set_alpha_mod(settings->input.overlay_opacity);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_DRIVERS_DEINIT:
|
2015-12-11 10:21:17 +00:00
|
|
|
{
|
|
|
|
int flags = DRIVERS_CMD_ALL;
|
2015-12-11 10:23:32 +00:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags);
|
2015-12-11 10:21:17 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_DRIVERS_INIT:
|
2015-12-11 10:21:17 +00:00
|
|
|
{
|
|
|
|
int flags = DRIVERS_CMD_ALL;
|
|
|
|
driver_ctl(RARCH_DRIVER_CTL_INIT, &flags);
|
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_AUDIO_REINIT:
|
2015-12-11 10:21:17 +00:00
|
|
|
{
|
|
|
|
int flags = DRIVER_AUDIO;
|
2015-12-11 10:23:32 +00:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags);
|
2015-12-11 10:21:17 +00:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_INIT, &flags);
|
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_RESET_CONTEXT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_DRIVERS_DEINIT);
|
|
|
|
event_command(EVENT_CMD_DRIVERS_INIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_QUIT_RETROARCH:
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
2015-10-23 08:24:47 +00:00
|
|
|
case EVENT_CMD_SHUTDOWN:
|
2015-11-01 10:18:28 +00:00
|
|
|
#if defined(__linux__) && !defined(ANDROID)
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push("Shutting down...", 1, 180, true);
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL);
|
2015-10-23 08:24:47 +00:00
|
|
|
system("shutdown -P now");
|
2015-11-01 10:18:28 +00:00
|
|
|
#endif
|
2015-10-23 08:24:47 +00:00
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_RESUME:
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_RESTART_RETROARCH:
|
2015-11-18 10:43:25 +00:00
|
|
|
{
|
2015-04-13 09:15:40 +00:00
|
|
|
#if defined(GEKKO) && defined(HW_RVL)
|
2015-11-18 10:43:25 +00:00
|
|
|
char new_path[PATH_MAX_LENGTH];
|
|
|
|
fill_pathname_join(new_path, g_defaults.dir.core, SALAMANDER_FILE, sizeof(new_path));
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, new_path);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
2015-12-05 06:57:45 +00:00
|
|
|
frontend_driver_set_fork(true, false);
|
2015-11-18 10:43:25 +00:00
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
2015-11-11 01:57:20 +00:00
|
|
|
case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG:
|
|
|
|
event_save_current_config();
|
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_MENU_SAVE_CONFIG:
|
|
|
|
if (!event_save_core_config())
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_SHADERS_APPLY_CHANGES:
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
menu_shader_manager_apply_changes();
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_PAUSE_CHECKS:
|
2015-11-30 21:25:13 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-07-01 20:14:37 +00:00
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED));
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUDIO_STOP);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (settings->video.black_frame_insertion)
|
2015-11-20 14:34:10 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-01 20:14:37 +00:00
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED));
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUDIO_START);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_PAUSE_TOGGLE:
|
2015-11-30 21:25:13 +00:00
|
|
|
boolean = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
|
2015-09-26 11:12:26 +00:00
|
|
|
boolean = !boolean;
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean);
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_PAUSE_CHECKS);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_UNPAUSE:
|
2015-09-26 11:12:26 +00:00
|
|
|
boolean = false;
|
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean);
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_PAUSE_CHECKS);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_PAUSE:
|
2015-09-26 11:12:26 +00:00
|
|
|
boolean = true;
|
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean);
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_PAUSE_CHECKS);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_MENU_PAUSE_LIBRETRO:
|
2015-10-09 18:40:05 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-05 12:49:22 +00:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
|
|
|
if (settings->menu.pause_libretro)
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUDIO_STOP);
|
2015-04-13 09:15:40 +00:00
|
|
|
else
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUDIO_START);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (settings->menu.pause_libretro)
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUDIO_START);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
2015-10-09 18:40:05 +00:00
|
|
|
#endif
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_SHADER_DIR_DEINIT:
|
2015-12-07 13:45:15 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SHADER_DIR_DEINIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_SHADER_DIR_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_SHADER_DIR_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-12-07 13:45:15 +00:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_SHADER_DIR_INIT, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_SAVEFILES:
|
2015-12-09 09:59:27 +00:00
|
|
|
if (!global->savefiles || !global->sram.use)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < global->savefiles->size; i++)
|
|
|
|
{
|
|
|
|
unsigned type = global->savefiles->elems[i].attr.i;
|
|
|
|
const char *path = global->savefiles->elems[i].data;
|
|
|
|
RARCH_LOG("%s #%u %s \"%s\".\n",
|
|
|
|
msg_hash_to_str(MSG_SAVING_RAM_TYPE),
|
|
|
|
type,
|
|
|
|
msg_hash_to_str(MSG_TO),
|
|
|
|
path);
|
|
|
|
save_ram_file(path, type);
|
|
|
|
}
|
|
|
|
return true;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_SAVEFILES_DEINIT:
|
|
|
|
if (!global)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (global->savefiles)
|
|
|
|
string_list_free(global->savefiles);
|
|
|
|
global->savefiles = NULL;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_SAVEFILES_INIT:
|
2015-07-27 15:18:10 +00:00
|
|
|
global->sram.use = global->sram.use && !global->sram.save_disable
|
2015-04-13 09:15:40 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:38:24 +00:00
|
|
|
&& (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL) || !global->netplay.is_client)
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (!global->sram.use)
|
2015-07-02 22:16:46 +00:00
|
|
|
RARCH_LOG("%s\n",
|
|
|
|
msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED));
|
2015-04-13 09:15:40 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
if (global->sram.use)
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_AUTOSAVE_INIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_BSV_MOVIE_DEINIT:
|
2015-11-30 23:04:04 +00:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_DEINIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_BSV_MOVIE_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_BSV_MOVIE_DEINIT);
|
2015-11-30 23:04:04 +00:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_NETPLAY_DEINIT:
|
|
|
|
#ifdef HAVE_NETPLAY
|
|
|
|
deinit_netplay();
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_NETWORK_DEINIT:
|
|
|
|
#ifdef HAVE_NETWORKING
|
|
|
|
network_deinit();
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_NETWORK_INIT:
|
|
|
|
#ifdef HAVE_NETWORKING
|
|
|
|
network_init();
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_NETPLAY_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_NETPLAY_DEINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
|
|
|
if (!init_netplay())
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_NETPLAY_FLIP_PLAYERS:
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:38:24 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_FULLSCREEN_TOGGLE:
|
2015-11-20 14:20:54 +00:00
|
|
|
if (!video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
2015-10-20 00:43:21 +00:00
|
|
|
/* If we go fullscreen we drop all drivers and
|
2015-04-13 09:15:40 +00:00
|
|
|
* reinitialize to be safe. */
|
|
|
|
settings->video.fullscreen = !settings->video.fullscreen;
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_REINIT);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_COMMAND_DEINIT:
|
2015-11-30 21:56:41 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_COMMAND_DEINIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_COMMAND_INIT:
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_COMMAND_DEINIT);
|
2015-11-30 21:56:41 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_COMMAND_INIT, NULL);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
2015-11-30 21:56:41 +00:00
|
|
|
case EVENT_CMD_REMOTE_DEINIT:
|
2015-11-30 22:06:47 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_REMOTE_DEINIT, NULL);
|
2015-11-30 21:56:41 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_REMOTE_INIT:
|
|
|
|
event_command(EVENT_CMD_REMOTE_DEINIT);
|
2015-11-30 22:06:47 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_REMOTE_INIT, NULL);
|
2015-11-30 21:56:41 +00:00
|
|
|
break;
|
2015-04-13 09:15:40 +00:00
|
|
|
case EVENT_CMD_TEMPORARY_CONTENT_DEINIT:
|
2015-11-30 18:09:12 +00:00
|
|
|
content_temporary_free();
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT:
|
|
|
|
if (!global)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (global->subsystem_fullpaths)
|
|
|
|
string_list_free(global->subsystem_fullpaths);
|
|
|
|
global->subsystem_fullpaths = NULL;
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_LOG_FILE_DEINIT:
|
2015-11-23 14:45:02 +00:00
|
|
|
retro_main_log_file_deinit();
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_DISK_EJECT_TOGGLE:
|
2015-10-23 08:24:47 +00:00
|
|
|
if (info && info->disk_control.get_num_images)
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-10-20 00:43:21 +00:00
|
|
|
const struct retro_disk_control_callback *control =
|
2015-04-13 09:15:40 +00:00
|
|
|
(const struct retro_disk_control_callback*)
|
2015-10-23 08:24:47 +00:00
|
|
|
&info->disk_control;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (control)
|
2015-12-09 09:59:27 +00:00
|
|
|
{
|
|
|
|
bool new_state = !control->get_eject_state();
|
|
|
|
event_disk_control_set_eject(new_state, true);
|
|
|
|
}
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
else
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(
|
2015-07-02 22:16:46 +00:00
|
|
|
MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS,
|
2015-07-01 20:14:37 +00:00
|
|
|
1, 120, true);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_DISK_NEXT:
|
2015-10-23 08:24:47 +00:00
|
|
|
if (info && info->disk_control.get_num_images)
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-10-20 00:43:21 +00:00
|
|
|
const struct retro_disk_control_callback *control =
|
2015-04-13 09:15:40 +00:00
|
|
|
(const struct retro_disk_control_callback*)
|
2015-10-23 08:24:47 +00:00
|
|
|
&info->disk_control;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!control)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!control->get_eject_state())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
event_check_disk_next(control);
|
|
|
|
}
|
|
|
|
else
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(
|
2015-07-02 22:16:46 +00:00
|
|
|
MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS,
|
2015-07-01 20:14:37 +00:00
|
|
|
1, 120, true);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_DISK_PREV:
|
2015-10-23 08:24:47 +00:00
|
|
|
if (info && info->disk_control.get_num_images)
|
2015-04-13 09:15:40 +00:00
|
|
|
{
|
2015-10-20 00:43:21 +00:00
|
|
|
const struct retro_disk_control_callback *control =
|
2015-04-13 09:15:40 +00:00
|
|
|
(const struct retro_disk_control_callback*)
|
2015-10-23 08:24:47 +00:00
|
|
|
&info->disk_control;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
if (!control)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!control->get_eject_state())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
event_check_disk_prev(control);
|
|
|
|
}
|
|
|
|
else
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(
|
2015-07-02 22:16:46 +00:00
|
|
|
MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS,
|
2015-07-01 20:14:37 +00:00
|
|
|
1, 120, true);
|
2015-04-13 09:15:40 +00:00
|
|
|
break;
|
|
|
|
case EVENT_CMD_RUMBLE_STOP:
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_GRAB_MOUSE_TOGGLE:
|
|
|
|
{
|
|
|
|
static bool grab_mouse_state = false;
|
2015-11-20 16:26:39 +00:00
|
|
|
bool grab_mouse_state_tmp;
|
2015-04-13 09:15:40 +00:00
|
|
|
|
|
|
|
grab_mouse_state = !grab_mouse_state;
|
|
|
|
|
2015-11-29 17:27:24 +00:00
|
|
|
if (!input_driver_grab_mouse(grab_mouse_state))
|
2015-04-13 09:15:40 +00:00
|
|
|
return false;
|
|
|
|
|
2015-07-01 20:14:37 +00:00
|
|
|
RARCH_LOG("%s: %s.\n",
|
|
|
|
msg_hash_to_str(MSG_GRAB_MOUSE_STATE),
|
2015-04-13 09:15:40 +00:00
|
|
|
grab_mouse_state ? "yes" : "no");
|
|
|
|
|
2015-11-20 16:26:39 +00:00
|
|
|
grab_mouse_state_tmp = !grab_mouse_state;
|
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_SHOW_MOUSE, &grab_mouse_state_tmp);
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG:
|
|
|
|
rarch_perf_log();
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_VOLUME_UP:
|
|
|
|
event_set_volume(0.5f);
|
|
|
|
break;
|
|
|
|
case EVENT_CMD_VOLUME_DOWN:
|
|
|
|
event_set_volume(-0.5f);
|
|
|
|
break;
|
2015-08-27 12:25:57 +00:00
|
|
|
case EVENT_CMD_SET_FRAME_LIMIT:
|
2015-12-04 08:54:12 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL);
|
2015-08-27 12:25:57 +00:00
|
|
|
break;
|
2015-04-20 16:40:46 +00:00
|
|
|
case EVENT_CMD_NONE:
|
2015-04-20 17:08:58 +00:00
|
|
|
default:
|
2015-07-01 20:14:37 +00:00
|
|
|
return false;
|
2015-04-13 09:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|