mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-18 17:04:34 +00:00
fix disk_next, add option for disk_prev
This commit is contained in:
parent
da3734e8c7
commit
7249ebc00c
@ -209,6 +209,7 @@ static const struct cmd_map map[] = {
|
||||
{ "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 },
|
||||
{ "MENU_TOGGLE", RARCH_MENU_TOGGLE },
|
||||
};
|
||||
|
@ -687,6 +687,7 @@ static const struct retro_keybind retro_keybinds_1[] = {
|
||||
{ true, RARCH_OVERLAY_NEXT, RETRO_LBL_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_DISK_EJECT_TOGGLE, RETRO_LBL_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_DISK_NEXT, RETRO_LBL_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_DISK_PREV, RETRO_LBL_DISK_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_GRAB_MOUSE_TOGGLE, RETRO_LBL_GRAB_MOUSE_TOGGLE, RETROK_F11, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_MENU_TOGGLE, RETRO_LBL_MENU_TOGGLE, RETROK_F1, NO_BTN, 0, AXIS_NONE },
|
||||
};
|
||||
|
1
driver.h
1
driver.h
@ -126,6 +126,7 @@ enum
|
||||
RARCH_OVERLAY_NEXT,
|
||||
RARCH_DISK_EJECT_TOGGLE,
|
||||
RARCH_DISK_NEXT,
|
||||
RARCH_DISK_PREV,
|
||||
RARCH_GRAB_MOUSE_TOGGLE,
|
||||
|
||||
RARCH_MENU_TOGGLE,
|
||||
|
@ -159,6 +159,7 @@ enum basic_event
|
||||
RARCH_CMD_LOG_FILE_DEINIT,
|
||||
RARCH_CMD_DISK_EJECT_TOGGLE,
|
||||
RARCH_CMD_DISK_NEXT,
|
||||
RARCH_CMD_DISK_PREV,
|
||||
RARCH_CMD_RUMBLE_STOP,
|
||||
};
|
||||
|
||||
|
@ -1259,6 +1259,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = {
|
||||
DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, "Overlay next"),
|
||||
DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, "Disk eject toggle"),
|
||||
DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, "Disk next"),
|
||||
DECLARE_META_BIND(2, disk_prev, RARCH_DISK_NEXT, "Disk prev"),
|
||||
DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, "Grab mouse toggle"),
|
||||
#ifdef HAVE_MENU
|
||||
DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, "Menu toggle"),
|
||||
|
@ -72,6 +72,7 @@
|
||||
#define RETRO_LBL_OVERLAY_NEXT "Next Overlay"
|
||||
#define RETRO_LBL_DISK_EJECT_TOGGLE "Disk Eject Toggle"
|
||||
#define RETRO_LBL_DISK_NEXT "Disk Swap Next"
|
||||
#define RETRO_LBL_DISK_PREV "Disk Swap Previous"
|
||||
#define RETRO_LBL_GRAB_MOUSE_TOGGLE "Grab mouse toggle"
|
||||
#define RETRO_LBL_MENU_TOGGLE "Menu toggle"
|
||||
|
||||
|
35
retroarch.c
35
retroarch.c
@ -1719,10 +1719,24 @@ static void check_disk_next(
|
||||
unsigned current = control->get_image_index();
|
||||
if (num_disks && num_disks != UINT_MAX)
|
||||
{
|
||||
/* Use "no disk" state when index == num_disks. */
|
||||
unsigned next_index = current >= num_disks ?
|
||||
0 : ((current + 1) % (num_disks + 1));
|
||||
rarch_disk_control_set_index(next_index);
|
||||
unsigned new_index = current;
|
||||
current < num_disks - 1 ? new_index++ : new_index;
|
||||
rarch_disk_control_set_index(new_index);
|
||||
}
|
||||
else
|
||||
RARCH_ERR("Got invalid disk index from libretro.\n");
|
||||
}
|
||||
|
||||
static void check_disk_prev(
|
||||
const struct retro_disk_control_callback *control)
|
||||
{
|
||||
unsigned num_disks = control->get_num_images();
|
||||
unsigned current = control->get_image_index();
|
||||
if (num_disks && num_disks != UINT_MAX)
|
||||
{
|
||||
unsigned new_index = current;
|
||||
current > 0 ? new_index-- : new_index;
|
||||
rarch_disk_control_set_index(new_index);
|
||||
}
|
||||
else
|
||||
RARCH_ERR("Got invalid disk index from libretro.\n");
|
||||
@ -2602,10 +2616,21 @@ bool rarch_main_command(unsigned cmd)
|
||||
(const struct retro_disk_control_callback*)
|
||||
&g_extern.system.disk_control;
|
||||
|
||||
if (!control)
|
||||
if (control->get_eject_state())
|
||||
check_disk_next(control);
|
||||
}
|
||||
break;
|
||||
case RARCH_CMD_DISK_PREV:
|
||||
if (g_extern.system.disk_control.get_num_images)
|
||||
{
|
||||
const struct retro_disk_control_callback *control =
|
||||
(const struct retro_disk_control_callback*)
|
||||
&g_extern.system.disk_control;
|
||||
|
||||
if (control->get_eject_state())
|
||||
check_disk_prev(control);
|
||||
}
|
||||
break;
|
||||
case RARCH_CMD_RUMBLE_STOP:
|
||||
{
|
||||
int i;
|
||||
|
@ -489,6 +489,8 @@ static int do_state_checks(
|
||||
rarch_main_command(RARCH_CMD_DISK_EJECT_TOGGLE);
|
||||
else if (BIT64_GET(trigger_input, RARCH_DISK_NEXT))
|
||||
rarch_main_command(RARCH_CMD_DISK_NEXT);
|
||||
else if (BIT64_GET(trigger_input, RARCH_DISK_PREV))
|
||||
rarch_main_command(RARCH_CMD_DISK_PREV);
|
||||
|
||||
if (BIT64_GET(trigger_input, RARCH_RESET))
|
||||
rarch_main_command(RARCH_CMD_RESET);
|
||||
|
Loading…
x
Reference in New Issue
Block a user