mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
(Disk Control Interface) Enable 'Load New Disc' while disk tray is open
This commit is contained in:
parent
a00ab53ef6
commit
0c18da5d49
@ -489,6 +489,7 @@ bool disk_control_append_image(
|
|||||||
disk_control_interface_t *disk_control,
|
disk_control_interface_t *disk_control,
|
||||||
const char *image_path)
|
const char *image_path)
|
||||||
{
|
{
|
||||||
|
bool initial_disk_ejected = false;
|
||||||
unsigned initial_index = 0;
|
unsigned initial_index = 0;
|
||||||
unsigned new_index = 0;
|
unsigned new_index = 0;
|
||||||
const char *image_filename = NULL;
|
const char *image_filename = NULL;
|
||||||
@ -518,11 +519,15 @@ bool disk_control_append_image(
|
|||||||
if (string_is_empty(image_filename))
|
if (string_is_empty(image_filename))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* Get initial disk eject state */
|
||||||
|
initial_disk_ejected = disk_control_get_eject_state(disk_control);
|
||||||
|
|
||||||
/* Cache initial image index */
|
/* Cache initial image index */
|
||||||
initial_index = disk_control->cb.get_image_index();
|
initial_index = disk_control->cb.get_image_index();
|
||||||
|
|
||||||
/* Eject disk */
|
/* If tray is currently closed, eject disk */
|
||||||
if (!disk_control_set_eject_state(disk_control, true, false))
|
if (!initial_disk_ejected &&
|
||||||
|
!disk_control_set_eject_state(disk_control, true, false))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Append image */
|
/* Append image */
|
||||||
@ -542,8 +547,10 @@ bool disk_control_append_image(
|
|||||||
if (!disk_control_set_index(disk_control, new_index, false))
|
if (!disk_control_set_index(disk_control, new_index, false))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Insert disk */
|
/* If tray was initially closed, insert disk
|
||||||
if (!disk_control_set_eject_state(disk_control, false, false))
|
* (i.e. leave system in the state we found it) */
|
||||||
|
if (!initial_disk_ejected &&
|
||||||
|
!disk_control_set_eject_state(disk_control, false, false))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Display log */
|
/* Display log */
|
||||||
@ -573,7 +580,8 @@ error:
|
|||||||
if (!disk_control->cb.get_eject_state())
|
if (!disk_control->cb.get_eject_state())
|
||||||
disk_control_set_eject_state(disk_control, true, false);
|
disk_control_set_eject_state(disk_control, true, false);
|
||||||
disk_control_set_index(disk_control, initial_index, false);
|
disk_control_set_index(disk_control, initial_index, false);
|
||||||
disk_control_set_eject_state(disk_control, false, false);
|
if (!initial_disk_ejected)
|
||||||
|
disk_control_set_eject_state(disk_control, false, false);
|
||||||
|
|
||||||
snprintf(
|
snprintf(
|
||||||
msg, sizeof(msg), "%s: %s",
|
msg, sizeof(msg), "%s: %s",
|
||||||
|
@ -6068,6 +6068,10 @@ MSG_HASH(
|
|||||||
MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND,
|
MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND,
|
||||||
"Eject current disc, select a new disc from the filesystem then insert it and close the virtual disc tray. NOTE: This is a legacy feature. It is instead recommended to load multi-disc titles via M3U playlists, which allow disc selection using the 'Eject/Insert Disc' and 'Current Disc Index' options."
|
"Eject current disc, select a new disc from the filesystem then insert it and close the virtual disc tray. NOTE: This is a legacy feature. It is instead recommended to load multi-disc titles via M3U playlists, which allow disc selection using the 'Eject/Insert Disc' and 'Current Disc Index' options."
|
||||||
)
|
)
|
||||||
|
MSG_HASH(
|
||||||
|
MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND_TRAY_OPEN,
|
||||||
|
"Select a new disc from the filesystem and insert it without closing the virtual disc tray. NOTE: This is a legacy feature. It is instead recommended to load multi-disc titles via M3U playlists, which allow disc selection using the 'Current Disc Index' option."
|
||||||
|
)
|
||||||
MSG_HASH(
|
MSG_HASH(
|
||||||
MENU_ENUM_LABEL_VALUE_DISK_INDEX,
|
MENU_ENUM_LABEL_VALUE_DISK_INDEX,
|
||||||
"Current Disc Index"
|
"Current Disc Index"
|
||||||
|
@ -99,7 +99,6 @@ enum
|
|||||||
ACTION_OK_LOAD_RECORD_CONFIGFILE,
|
ACTION_OK_LOAD_RECORD_CONFIGFILE,
|
||||||
ACTION_OK_LOAD_REMAPPING_FILE,
|
ACTION_OK_LOAD_REMAPPING_FILE,
|
||||||
ACTION_OK_LOAD_CHEAT_FILE,
|
ACTION_OK_LOAD_CHEAT_FILE,
|
||||||
ACTION_OK_APPEND_DISK_IMAGE,
|
|
||||||
ACTION_OK_SUBSYSTEM_ADD,
|
ACTION_OK_SUBSYSTEM_ADD,
|
||||||
ACTION_OK_LOAD_CONFIG_FILE,
|
ACTION_OK_LOAD_CONFIG_FILE,
|
||||||
ACTION_OK_LOAD_CORE,
|
ACTION_OK_LOAD_CORE,
|
||||||
@ -1767,19 +1766,6 @@ static int generic_action_ok(const char *path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_OK_APPEND_DISK_IMAGE:
|
|
||||||
{
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume;
|
|
||||||
|
|
||||||
flush_char = msg_hash_to_str(
|
|
||||||
MENU_ENUM_LABEL_DISK_OPTIONS);
|
|
||||||
command_event(CMD_EVENT_DISK_APPEND_IMAGE, action_path);
|
|
||||||
|
|
||||||
if (menu_insert_disk_resume)
|
|
||||||
generic_action_ok_command(CMD_EVENT_RESUME);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ACTION_OK_SUBSYSTEM_ADD:
|
case ACTION_OK_SUBSYSTEM_ADD:
|
||||||
flush_type = MENU_SETTINGS;
|
flush_type = MENU_SETTINGS;
|
||||||
content_add_subsystem(action_path);
|
content_add_subsystem(action_path);
|
||||||
@ -1876,7 +1862,6 @@ DEFAULT_ACTION_OK_SET(action_ok_set_path_video_layout,ACTION_OK_SET_PATH_VIDEO_L
|
|||||||
DEFAULT_ACTION_OK_SET(action_ok_set_path, ACTION_OK_SET_PATH, MSG_UNKNOWN)
|
DEFAULT_ACTION_OK_SET(action_ok_set_path, ACTION_OK_SET_PATH, MSG_UNKNOWN)
|
||||||
DEFAULT_ACTION_OK_SET(action_ok_load_core, ACTION_OK_LOAD_CORE, MSG_UNKNOWN)
|
DEFAULT_ACTION_OK_SET(action_ok_load_core, ACTION_OK_LOAD_CORE, MSG_UNKNOWN)
|
||||||
DEFAULT_ACTION_OK_SET(action_ok_config_load, ACTION_OK_LOAD_CONFIG_FILE, MSG_UNKNOWN)
|
DEFAULT_ACTION_OK_SET(action_ok_config_load, ACTION_OK_LOAD_CONFIG_FILE, MSG_UNKNOWN)
|
||||||
DEFAULT_ACTION_OK_SET(action_ok_disk_image_append, ACTION_OK_APPEND_DISK_IMAGE, MSG_UNKNOWN)
|
|
||||||
DEFAULT_ACTION_OK_SET(action_ok_subsystem_add, ACTION_OK_SUBSYSTEM_ADD, MSG_UNKNOWN)
|
DEFAULT_ACTION_OK_SET(action_ok_subsystem_add, ACTION_OK_SUBSYSTEM_ADD, MSG_UNKNOWN)
|
||||||
DEFAULT_ACTION_OK_SET(action_ok_cheat_file_load, ACTION_OK_LOAD_CHEAT_FILE, MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS)
|
DEFAULT_ACTION_OK_SET(action_ok_cheat_file_load, ACTION_OK_LOAD_CHEAT_FILE, MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS)
|
||||||
DEFAULT_ACTION_OK_SET(action_ok_cheat_file_load_append, ACTION_OK_LOAD_CHEAT_FILE_APPEND, MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS)
|
DEFAULT_ACTION_OK_SET(action_ok_cheat_file_load_append, ACTION_OK_LOAD_CHEAT_FILE_APPEND, MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS)
|
||||||
@ -6154,6 +6139,61 @@ static int action_ok_disk_cycle_tray_status(const char *path,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int action_ok_disk_image_append(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
rarch_system_info_t *sys_info = runloop_get_system_info();
|
||||||
|
menu_handle_t *menu = menu_driver_get_ptr();
|
||||||
|
const char *menu_path = NULL;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
#ifdef HAVE_AUDIOMIXER
|
||||||
|
bool audio_enable_menu = settings->bools.audio_enable_menu;
|
||||||
|
bool audio_enable_menu_ok = settings->bools.audio_enable_menu_ok;
|
||||||
|
#endif
|
||||||
|
bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume;
|
||||||
|
char image_path[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
|
image_path[0] = '\0';
|
||||||
|
|
||||||
|
if (!menu)
|
||||||
|
return menu_cbs_exit();
|
||||||
|
|
||||||
|
#ifdef HAVE_AUDIOMIXER
|
||||||
|
if (audio_enable_menu && audio_enable_menu_ok)
|
||||||
|
audio_driver_mixer_play_menu_sound(AUDIO_MIXER_SYSTEM_SLOT_OK);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Get file path of new disk image */
|
||||||
|
menu_entries_get_last_stack(&menu_path,
|
||||||
|
NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if (!string_is_empty(menu_path))
|
||||||
|
{
|
||||||
|
if (!string_is_empty(path))
|
||||||
|
fill_pathname_join(image_path,
|
||||||
|
menu_path, path, sizeof(image_path));
|
||||||
|
else
|
||||||
|
strlcpy(image_path, menu_path, sizeof(image_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append image */
|
||||||
|
command_event(CMD_EVENT_DISK_APPEND_IMAGE, image_path);
|
||||||
|
|
||||||
|
/* In all cases, return to the disk options menu */
|
||||||
|
menu_entries_flush_stack(msg_hash_to_str(MENU_ENUM_LABEL_DISK_OPTIONS), 0);
|
||||||
|
|
||||||
|
/* > If disk tray is open, reset menu selection to
|
||||||
|
* the 'insert disk' option
|
||||||
|
* > If disk try is closed and user has enabled
|
||||||
|
* 'menu_insert_disk_resume', resume running content */
|
||||||
|
if (sys_info && disk_control_get_eject_state(&sys_info->disk_control))
|
||||||
|
menu_navigation_set_selection(0);
|
||||||
|
else if (menu_insert_disk_resume)
|
||||||
|
generic_action_ok_command(CMD_EVENT_RESUME);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int action_ok_manual_content_scan_start(const char *path,
|
static int action_ok_manual_content_scan_start(const char *path,
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
{
|
{
|
||||||
|
@ -584,7 +584,6 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_latency_frames,
|
|||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_latency_frames_range, MENU_ENUM_SUBLABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE)
|
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_latency_frames_range, MENU_ENUM_SUBLABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE)
|
||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_tray_eject, MENU_ENUM_SUBLABEL_DISK_TRAY_EJECT)
|
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_tray_eject, MENU_ENUM_SUBLABEL_DISK_TRAY_EJECT)
|
||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_tray_insert, MENU_ENUM_SUBLABEL_DISK_TRAY_INSERT)
|
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_tray_insert, MENU_ENUM_SUBLABEL_DISK_TRAY_INSERT)
|
||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_image_append, MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND)
|
|
||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_index, MENU_ENUM_SUBLABEL_DISK_INDEX)
|
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_index, MENU_ENUM_SUBLABEL_DISK_INDEX)
|
||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_options, MENU_ENUM_SUBLABEL_DISK_OPTIONS)
|
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_disk_options, MENU_ENUM_SUBLABEL_DISK_OPTIONS)
|
||||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_throttle_framerate, MENU_ENUM_SUBLABEL_MENU_ENUM_THROTTLE_FRAMERATE)
|
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_throttle_framerate, MENU_ENUM_SUBLABEL_MENU_ENUM_THROTTLE_FRAMERATE)
|
||||||
@ -951,6 +950,25 @@ static int action_bind_sublabel_subsystem_load(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int action_bind_sublabel_disk_image_append(
|
||||||
|
file_list_t *list,
|
||||||
|
unsigned type, unsigned i,
|
||||||
|
const char *label, const char *path,
|
||||||
|
char *s, size_t len)
|
||||||
|
{
|
||||||
|
rarch_system_info_t *sys_info = runloop_get_system_info();
|
||||||
|
enum msg_hash_enums enum_idx = MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND;
|
||||||
|
|
||||||
|
/* Check whether disk is currently ejected */
|
||||||
|
if (sys_info &&
|
||||||
|
disk_control_get_eject_state(&sys_info->disk_control))
|
||||||
|
enum_idx = MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND_TRAY_OPEN;
|
||||||
|
|
||||||
|
strlcpy(s, msg_hash_to_str(enum_idx), len);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int action_bind_sublabel_remap_kbd_sublabel(
|
static int action_bind_sublabel_remap_kbd_sublabel(
|
||||||
file_list_t *list,
|
file_list_t *list,
|
||||||
unsigned type, unsigned i,
|
unsigned type, unsigned i,
|
||||||
|
@ -3620,19 +3620,19 @@ static unsigned menu_displaylist_parse_disk_options(
|
|||||||
if (!disk_control_append_enabled(&sys_info->disk_control))
|
if (!disk_control_append_enabled(&sys_info->disk_control))
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
/* Append image does the following:
|
/* Always show a 'DISK_IMAGE_APPEND' entry
|
||||||
* > Open tray
|
* > If tray is currently shut, this will:
|
||||||
* > Append disk image
|
* - Open tray
|
||||||
* > Close tray
|
* - Append disk image
|
||||||
* It therefore only makes sense to show this option
|
* - Close tray
|
||||||
* if a disk is currently inserted */
|
* > If tray is currently open, this will
|
||||||
if (!disk_ejected)
|
* only append a disk image */
|
||||||
if (menu_entries_append_enum(list,
|
if (menu_entries_append_enum(list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISK_IMAGE_APPEND),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISK_IMAGE_APPEND),
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_DISK_IMAGE_APPEND),
|
msg_hash_to_str(MENU_ENUM_LABEL_DISK_IMAGE_APPEND),
|
||||||
MENU_ENUM_LABEL_DISK_IMAGE_APPEND,
|
MENU_ENUM_LABEL_DISK_IMAGE_APPEND,
|
||||||
MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_IMAGE_APPEND, 0, 0))
|
MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_IMAGE_APPEND, 0, 0))
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -1967,6 +1967,9 @@ enum msg_hash_enums
|
|||||||
MENU_LABEL(SHUTDOWN),
|
MENU_LABEL(SHUTDOWN),
|
||||||
MENU_LABEL(REBOOT),
|
MENU_LABEL(REBOOT),
|
||||||
MENU_LABEL(DISK_IMAGE_APPEND),
|
MENU_LABEL(DISK_IMAGE_APPEND),
|
||||||
|
|
||||||
|
MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND_TRAY_OPEN,
|
||||||
|
|
||||||
MENU_LABEL(SUBSYSTEM_ADD),
|
MENU_LABEL(SUBSYSTEM_ADD),
|
||||||
MENU_LABEL(SUBSYSTEM_LOAD),
|
MENU_LABEL(SUBSYSTEM_LOAD),
|
||||||
MENU_LABEL(CORE_LIST),
|
MENU_LABEL(CORE_LIST),
|
||||||
|
37
retroarch.c
37
retroarch.c
@ -15308,11 +15308,40 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
break;
|
break;
|
||||||
case CMD_EVENT_DISK_APPEND_IMAGE:
|
case CMD_EVENT_DISK_APPEND_IMAGE:
|
||||||
{
|
{
|
||||||
const char *path = (const char*)data;
|
const char *path = (const char*)data;
|
||||||
if (string_is_empty(path))
|
rarch_system_info_t *sys_info = &p_rarch->runloop_system;
|
||||||
return false;
|
|
||||||
if (!command_event_disk_control_append_image(p_rarch, path))
|
if (string_is_empty(path) || !sys_info)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (disk_control_enabled(&sys_info->disk_control))
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
#if defined(HAVE_MENU)
|
||||||
|
bool refresh = false;
|
||||||
|
/* Get initial disk eject state */
|
||||||
|
bool initial_disk_ejected = disk_control_get_eject_state(&sys_info->disk_control);
|
||||||
|
#endif
|
||||||
|
/* Append disk image */
|
||||||
|
success = command_event_disk_control_append_image(p_rarch, path);
|
||||||
|
|
||||||
|
#if defined(HAVE_MENU)
|
||||||
|
/* Appending a disk image may or may not affect
|
||||||
|
* the disk tray eject status. If status has changed,
|
||||||
|
* must refresh the disk options menu */
|
||||||
|
if (initial_disk_ejected != disk_control_get_eject_state(&sys_info->disk_control))
|
||||||
|
{
|
||||||
|
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
|
||||||
|
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
runloop_msg_queue_push(
|
||||||
|
msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS),
|
||||||
|
1, 120, true,
|
||||||
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_DISK_EJECT_TOGGLE:
|
case CMD_EVENT_DISK_EJECT_TOGGLE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user