Create EVENT_CMD_DISK_APPEND_IMAGE

This commit is contained in:
twinaphex 2016-01-27 20:04:34 +01:00
parent 1d47300f0f
commit 6f0c4e03d5
3 changed files with 16 additions and 12 deletions

View File

@ -16,6 +16,7 @@
#include <ctype.h>
#include <compat/strl.h>
#include <string/stdstring.h>
#include "command_event.h"
@ -174,7 +175,7 @@ static void event_disk_control_set_index(unsigned idx)
*
* Appends disk image to disk image list.
**/
void event_disk_control_append_image(const char *path)
static bool event_disk_control_append_image(const char *path)
{
unsigned new_idx;
char msg[128] = {0};
@ -190,14 +191,14 @@ void event_disk_control_append_image(const char *path)
&sysinfo->disk_control;
if (!control)
return;
return false;
event_disk_control_set_eject(true, false);
control->add_image_index();
new_idx = control->get_num_images();
if (!new_idx)
return;
return false;
new_idx--;
info.path = path;
@ -224,6 +225,8 @@ void event_disk_control_append_image(const char *path)
event_cmd_ctl(EVENT_CMD_AUTOSAVE_INIT, NULL);
event_disk_control_set_index(new_idx);
event_disk_control_set_eject(false, false);
return true;
}
/**
@ -1551,6 +1554,13 @@ bool event_cmd_ctl(enum event_command cmd, void *data)
case EVENT_CMD_LOG_FILE_DEINIT:
retro_main_log_file_deinit();
break;
case EVENT_CMD_DISK_APPEND_IMAGE:
{
const char *path = (const char*)data;
if (string_is_empty(path))
return false;
return event_disk_control_append_image(path);
}
case EVENT_CMD_DISK_EJECT_TOGGLE:
if (info && info->disk_control.get_num_images)
{

View File

@ -196,6 +196,8 @@ enum event_command
EVENT_CMD_DISK_NEXT,
/* Cycle to previous disk. */
EVENT_CMD_DISK_PREV,
/* Appends disk image to disk image list. */
EVENT_CMD_DISK_APPEND_IMAGE,
/* Stops rumbling. */
EVENT_CMD_RUMBLE_STOP,
/* Toggles mouse grab. */
@ -209,14 +211,6 @@ enum event_command
EVENT_CMD_VOLUME_DOWN
};
/**
* 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);
/**
* event_command:
* @cmd : Command index.

View File

@ -766,7 +766,7 @@ static int generic_action_ok(const char *path,
case ACTION_OK_APPEND_DISK_IMAGE:
flush_char = NULL;
flush_type = 49;
event_disk_control_append_image(action_path);
event_cmd_ctl(EVENT_CMD_DISK_APPEND_IMAGE, action_path);
event_cmd_ctl(EVENT_CMD_RESUME, NULL);
break;
case ACTION_OK_SET_PATH: