Add RGUI menu toggle config.
This commit is contained in:
parent
f1bfaaf420
commit
4f2de6d578
|
@ -149,7 +149,8 @@ typedef enum
|
||||||
RGUI_SETTINGS_BIND_DPAD_EMULATION,
|
RGUI_SETTINGS_BIND_DPAD_EMULATION,
|
||||||
|
|
||||||
// Match up with libretro order for simplicity.
|
// Match up with libretro order for simplicity.
|
||||||
RGUI_SETTINGS_BIND_B,
|
RGUI_SETTINGS_BIND_BEGIN,
|
||||||
|
RGUI_SETTINGS_BIND_B = RGUI_SETTINGS_BIND_BEGIN,
|
||||||
RGUI_SETTINGS_BIND_Y,
|
RGUI_SETTINGS_BIND_Y,
|
||||||
RGUI_SETTINGS_BIND_SELECT,
|
RGUI_SETTINGS_BIND_SELECT,
|
||||||
RGUI_SETTINGS_BIND_START,
|
RGUI_SETTINGS_BIND_START,
|
||||||
|
@ -165,8 +166,19 @@ typedef enum
|
||||||
RGUI_SETTINGS_BIND_R2,
|
RGUI_SETTINGS_BIND_R2,
|
||||||
RGUI_SETTINGS_BIND_L3,
|
RGUI_SETTINGS_BIND_L3,
|
||||||
RGUI_SETTINGS_BIND_R3,
|
RGUI_SETTINGS_BIND_R3,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_LEFT_X_PLUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_LEFT_X_MINUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_PLUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_MINUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_PLUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_MINUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_PLUS,
|
||||||
|
RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_MINUS,
|
||||||
|
RGUI_SETTINGS_BIND_LAST = RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_MINUS,
|
||||||
|
RGUI_SETTINGS_BIND_MENU_TOGGLE = RGUI_SETTINGS_BIND_BEGIN + RARCH_MENU_TOGGLE,
|
||||||
RGUI_SETTINGS_CUSTOM_BIND,
|
RGUI_SETTINGS_CUSTOM_BIND,
|
||||||
RGUI_SETTINGS_CUSTOM_BIND_ALL,
|
RGUI_SETTINGS_CUSTOM_BIND_ALL,
|
||||||
|
RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL,
|
||||||
|
|
||||||
RGUI_SETTINGS_CORE_OPTION_NONE = 0xffff,
|
RGUI_SETTINGS_CORE_OPTION_NONE = 0xffff,
|
||||||
RGUI_SETTINGS_CORE_OPTION_START = 0x10000
|
RGUI_SETTINGS_CORE_OPTION_START = 0x10000
|
||||||
|
@ -198,7 +210,6 @@ struct rgui_bind_state_port
|
||||||
bool buttons[RGUI_MAX_BUTTONS];
|
bool buttons[RGUI_MAX_BUTTONS];
|
||||||
int16_t axes[RGUI_MAX_AXES];
|
int16_t axes[RGUI_MAX_AXES];
|
||||||
uint16_t hats[RGUI_MAX_HATS];
|
uint16_t hats[RGUI_MAX_HATS];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rgui_bind_axis_state
|
struct rgui_bind_axis_state
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "../../compat/posix_string.h"
|
#include "../../compat/posix_string.h"
|
||||||
#include "../../gfx/shader_parse.h"
|
#include "../../gfx/shader_parse.h"
|
||||||
#include "../../performance.h"
|
#include "../../performance.h"
|
||||||
|
#include "../../input/input_common.h"
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
#include "../../gfx/gl_common.h"
|
#include "../../gfx/gl_common.h"
|
||||||
|
@ -684,13 +685,26 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
|
||||||
if (action == RGUI_ACTION_OK)
|
if (action == RGUI_ACTION_OK)
|
||||||
{
|
{
|
||||||
rgui->binds.target = &g_settings.input.binds[port][0];
|
rgui->binds.target = &g_settings.input.binds[port][0];
|
||||||
rgui->binds.begin = RGUI_SETTINGS_BIND_B;
|
rgui->binds.begin = RGUI_SETTINGS_BIND_BEGIN;
|
||||||
rgui->binds.last = RGUI_SETTINGS_BIND_R3;
|
rgui->binds.last = RGUI_SETTINGS_BIND_LAST;
|
||||||
rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_BIND, rgui->selection_ptr);
|
rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_BIND, rgui->selection_ptr);
|
||||||
menu_poll_bind_get_rested_axes(&rgui->binds);
|
menu_poll_bind_get_rested_axes(&rgui->binds);
|
||||||
menu_poll_bind_state(&rgui->binds);
|
menu_poll_bind_state(&rgui->binds);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL:
|
||||||
|
if (action == RGUI_ACTION_OK)
|
||||||
|
{
|
||||||
|
struct retro_keybind *target = &g_settings.input.binds[port][0];
|
||||||
|
rgui->binds.begin = RGUI_SETTINGS_BIND_BEGIN;
|
||||||
|
rgui->binds.last = RGUI_SETTINGS_BIND_LAST;
|
||||||
|
for (unsigned i = RGUI_SETTINGS_BIND_BEGIN; i < RGUI_SETTINGS_BIND_LAST; i++, target++)
|
||||||
|
{
|
||||||
|
target->joykey = NO_BTN;
|
||||||
|
target->joyaxis = AXIS_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RGUI_SETTINGS_BIND_UP:
|
case RGUI_SETTINGS_BIND_UP:
|
||||||
case RGUI_SETTINGS_BIND_DOWN:
|
case RGUI_SETTINGS_BIND_DOWN:
|
||||||
case RGUI_SETTINGS_BIND_LEFT:
|
case RGUI_SETTINGS_BIND_LEFT:
|
||||||
|
@ -707,6 +721,15 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
|
||||||
case RGUI_SETTINGS_BIND_R2:
|
case RGUI_SETTINGS_BIND_R2:
|
||||||
case RGUI_SETTINGS_BIND_L3:
|
case RGUI_SETTINGS_BIND_L3:
|
||||||
case RGUI_SETTINGS_BIND_R3:
|
case RGUI_SETTINGS_BIND_R3:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_X_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_X_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_MENU_TOGGLE:
|
||||||
if (driver.input->set_keybinds)
|
if (driver.input->set_keybinds)
|
||||||
{
|
{
|
||||||
unsigned keybind_action = KEYBINDS_ACTION_NONE;
|
unsigned keybind_action = KEYBINDS_ACTION_NONE;
|
||||||
|
@ -721,11 +744,11 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
|
||||||
// FIXME: The array indices here look totally wrong ... Fixed it so it looks kind of sane for now.
|
// FIXME: The array indices here look totally wrong ... Fixed it so it looks kind of sane for now.
|
||||||
if (keybind_action != KEYBINDS_ACTION_NONE)
|
if (keybind_action != KEYBINDS_ACTION_NONE)
|
||||||
driver.input->set_keybinds(driver.input_data, g_settings.input.device[port], port,
|
driver.input->set_keybinds(driver.input_data, g_settings.input.device[port], port,
|
||||||
setting - RGUI_SETTINGS_BIND_B, keybind_action);
|
setting - RGUI_SETTINGS_BIND_BEGIN, keybind_action);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct retro_keybind *bind = &g_settings.input.binds[port][setting - RGUI_SETTINGS_BIND_B];
|
struct retro_keybind *bind = &g_settings.input.binds[port][setting - RGUI_SETTINGS_BIND_BEGIN];
|
||||||
if (action == RGUI_ACTION_OK)
|
if (action == RGUI_ACTION_OK)
|
||||||
{
|
{
|
||||||
rgui->binds.begin = setting;
|
rgui->binds.begin = setting;
|
||||||
|
@ -1514,6 +1537,7 @@ static void rgui_settings_path_populate_entries(rgui_handle_t *rgui)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move to some extern. Maybe in input_common.c?
|
||||||
static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
|
static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
|
||||||
{
|
{
|
||||||
rgui_list_clear(rgui->selection_buf);
|
rgui_list_clear(rgui->selection_buf);
|
||||||
|
@ -1529,24 +1553,15 @@ static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
|
||||||
if (driver.input && driver.input->set_keybinds)
|
if (driver.input && driver.input->set_keybinds)
|
||||||
rgui_list_push(rgui->selection_buf, "DPad Emulation", RGUI_SETTINGS_BIND_DPAD_EMULATION, 0);
|
rgui_list_push(rgui->selection_buf, "DPad Emulation", RGUI_SETTINGS_BIND_DPAD_EMULATION, 0);
|
||||||
else
|
else
|
||||||
rgui_list_push(rgui->selection_buf, "Configure All", RGUI_SETTINGS_CUSTOM_BIND_ALL, 0); // This doesn't make sense on anything else than PC.
|
{
|
||||||
|
rgui_list_push(rgui->selection_buf, "Configure All (RetroPad)", RGUI_SETTINGS_CUSTOM_BIND_ALL, 0); // This doesn't make sense on anything else than PC.
|
||||||
|
rgui_list_push(rgui->selection_buf, "Default All (RetroPad)", RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL, 0); // This doesn't make sense on anything else than PC.
|
||||||
|
}
|
||||||
|
|
||||||
rgui_list_push(rgui->selection_buf, "Up", RGUI_SETTINGS_BIND_UP, 0);
|
rgui_list_push(rgui->selection_buf, "RGUI Menu Toggle", RGUI_SETTINGS_BIND_MENU_TOGGLE, 0);
|
||||||
rgui_list_push(rgui->selection_buf, "Down", RGUI_SETTINGS_BIND_DOWN, 0);
|
unsigned last = (driver.input && driver.input->set_keybinds) ? RGUI_SETTINGS_BIND_R3 : RGUI_SETTINGS_BIND_LAST;
|
||||||
rgui_list_push(rgui->selection_buf, "Left", RGUI_SETTINGS_BIND_LEFT, 0);
|
for (unsigned i = RGUI_SETTINGS_BIND_BEGIN; i <= last; i++)
|
||||||
rgui_list_push(rgui->selection_buf, "Right", RGUI_SETTINGS_BIND_RIGHT, 0);
|
rgui_list_push(rgui->selection_buf, input_bind_to_str[i - RGUI_SETTINGS_BIND_BEGIN], i, 0);
|
||||||
rgui_list_push(rgui->selection_buf, "A (right)", RGUI_SETTINGS_BIND_A, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "B (down)", RGUI_SETTINGS_BIND_B, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "X (top)", RGUI_SETTINGS_BIND_X, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "Y (left)", RGUI_SETTINGS_BIND_Y, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "Start", RGUI_SETTINGS_BIND_START, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "Select", RGUI_SETTINGS_BIND_SELECT, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "L", RGUI_SETTINGS_BIND_L, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "R", RGUI_SETTINGS_BIND_R, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "L2", RGUI_SETTINGS_BIND_L2, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "R2", RGUI_SETTINGS_BIND_R2, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "L3", RGUI_SETTINGS_BIND_L3, 0);
|
|
||||||
rgui_list_push(rgui->selection_buf, "R3", RGUI_SETTINGS_BIND_R3, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This only makes sense for PC so far.
|
// This only makes sense for PC so far.
|
||||||
|
@ -1557,27 +1572,8 @@ static int rgui_custom_bind_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||||
|
|
||||||
render_text(rgui);
|
render_text(rgui);
|
||||||
|
|
||||||
static const char *rgui_key_to_str[] = {
|
|
||||||
"B (down)",
|
|
||||||
"Y (left)",
|
|
||||||
"Select",
|
|
||||||
"Start",
|
|
||||||
"D-pad Up",
|
|
||||||
"D-pad Down",
|
|
||||||
"D-pad Left",
|
|
||||||
"D-pad Right",
|
|
||||||
"A (right)",
|
|
||||||
"X (top)",
|
|
||||||
"L (trigger)",
|
|
||||||
"R (trigger)",
|
|
||||||
"L2 (trigger)",
|
|
||||||
"R2 (trigger)",
|
|
||||||
"L3 (thumb)",
|
|
||||||
"R3 (thumb)",
|
|
||||||
};
|
|
||||||
|
|
||||||
char msg[256];
|
char msg[256];
|
||||||
snprintf(msg, sizeof(msg), "[%s] press joypad (RETURN to skip)", rgui_key_to_str[rgui->binds.begin - RGUI_SETTINGS_BIND_B]);
|
snprintf(msg, sizeof(msg), "[%s] press joypad (RETURN to skip)", input_bind_to_str[rgui->binds.begin - RGUI_SETTINGS_BIND_BEGIN]);
|
||||||
render_messagebox(rgui, msg);
|
render_messagebox(rgui, msg);
|
||||||
|
|
||||||
struct rgui_bind_state binds = rgui->binds;
|
struct rgui_bind_state binds = rgui->binds;
|
||||||
|
|
|
@ -304,7 +304,13 @@ static void render_text(rgui_handle_t *rgui)
|
||||||
rgui_list_get_at_offset(rgui->selection_buf, i, &path, &type);
|
rgui_list_get_at_offset(rgui->selection_buf, i, &path, &type);
|
||||||
char message[256];
|
char message[256];
|
||||||
char type_str[256];
|
char type_str[256];
|
||||||
unsigned w = (menu_type == RGUI_SETTINGS_INPUT_OPTIONS || menu_type == RGUI_SETTINGS_PATH_OPTIONS || menu_type == RGUI_SETTINGS_CUSTOM_BIND) ? 24 : 19;
|
|
||||||
|
unsigned w = 19;
|
||||||
|
if (menu_type == RGUI_SETTINGS_INPUT_OPTIONS || menu_type == RGUI_SETTINGS_CUSTOM_BIND)
|
||||||
|
w = 21;
|
||||||
|
else if (menu_type == RGUI_SETTINGS_PATH_OPTIONS)
|
||||||
|
w = 24;
|
||||||
|
|
||||||
unsigned port = rgui->current_pad;
|
unsigned port = rgui->current_pad;
|
||||||
|
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
|
@ -535,6 +541,7 @@ static void render_text(rgui_handle_t *rgui)
|
||||||
case RGUI_SETTINGS_PATH_OPTIONS:
|
case RGUI_SETTINGS_PATH_OPTIONS:
|
||||||
case RGUI_SETTINGS_OPTIONS:
|
case RGUI_SETTINGS_OPTIONS:
|
||||||
case RGUI_SETTINGS_CUSTOM_BIND_ALL:
|
case RGUI_SETTINGS_CUSTOM_BIND_ALL:
|
||||||
|
case RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL:
|
||||||
strlcpy(type_str, "...", sizeof(type_str));
|
strlcpy(type_str, "...", sizeof(type_str));
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
|
@ -626,6 +633,15 @@ static void render_text(rgui_handle_t *rgui)
|
||||||
case RGUI_SETTINGS_BIND_R2:
|
case RGUI_SETTINGS_BIND_R2:
|
||||||
case RGUI_SETTINGS_BIND_L3:
|
case RGUI_SETTINGS_BIND_L3:
|
||||||
case RGUI_SETTINGS_BIND_R3:
|
case RGUI_SETTINGS_BIND_R3:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_X_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_X_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_PLUS:
|
||||||
|
case RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_MINUS:
|
||||||
|
case RGUI_SETTINGS_BIND_MENU_TOGGLE:
|
||||||
{
|
{
|
||||||
unsigned id = type - RGUI_SETTINGS_BIND_B;
|
unsigned id = type - RGUI_SETTINGS_BIND_B;
|
||||||
struct platform_bind key_label;
|
struct platform_bind key_label;
|
||||||
|
|
|
@ -794,6 +794,77 @@ const struct input_key_map input_config_key_map[] = {
|
||||||
{ NULL, RETROK_UNKNOWN },
|
{ NULL, RETROK_UNKNOWN },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *input_bind_to_str[] = {
|
||||||
|
"B (down)",
|
||||||
|
"Y (left)",
|
||||||
|
"Select",
|
||||||
|
"Start",
|
||||||
|
"D-pad Up",
|
||||||
|
"D-pad Down",
|
||||||
|
"D-pad Left",
|
||||||
|
"D-pad Right",
|
||||||
|
"A (right)",
|
||||||
|
"X (top)",
|
||||||
|
"L (trigger)",
|
||||||
|
"R (trigger)",
|
||||||
|
"L2 (trigger)",
|
||||||
|
"R2 (trigger)",
|
||||||
|
"L3 (thumb)",
|
||||||
|
"R3 (thumb)",
|
||||||
|
"Left analog X+ (right)",
|
||||||
|
"Left analog X- (left)",
|
||||||
|
"Left analog Y+ (down)",
|
||||||
|
"Left analog Y- (up)",
|
||||||
|
"Right analog X+ (right)",
|
||||||
|
"Right analog X- (left)",
|
||||||
|
"Right analog Y+ (down)",
|
||||||
|
"Right analog Y- (up)",
|
||||||
|
#ifdef RARCH_CONSOLE
|
||||||
|
"Left analog X D-pad left",
|
||||||
|
"Left analog X D-pad right",
|
||||||
|
"Left analog Y D-pad up",
|
||||||
|
"Left analog Y D-pad down",
|
||||||
|
"Right analog X D-pad left",
|
||||||
|
"Right analog X D-pad right",
|
||||||
|
"Right analog Y D-pad up",
|
||||||
|
"Right analog Y D-pad down",
|
||||||
|
#endif
|
||||||
|
|
||||||
|
"Turbo enable",
|
||||||
|
"Fast forward",
|
||||||
|
"Fast forward hold",
|
||||||
|
"Load state",
|
||||||
|
"Save state",
|
||||||
|
"Fullscreen toggle",
|
||||||
|
"Quit RetroArch",
|
||||||
|
"State slot (+)",
|
||||||
|
"State slot (-)",
|
||||||
|
"Rewind",
|
||||||
|
"Movie record toggle",
|
||||||
|
"Pause toggle",
|
||||||
|
"Frame advance",
|
||||||
|
"Reset game",
|
||||||
|
"Next shader",
|
||||||
|
"Previous shader",
|
||||||
|
"Cheat index (+)",
|
||||||
|
"Cheat index (-)",
|
||||||
|
"Cheat toggle",
|
||||||
|
"Take screenshot",
|
||||||
|
"DSP plugin config",
|
||||||
|
"Mute audio",
|
||||||
|
"Netplay flip players",
|
||||||
|
"Slow motion",
|
||||||
|
"Hotkey enable",
|
||||||
|
"Volume (+)",
|
||||||
|
"Volume (-)",
|
||||||
|
"Next overlay",
|
||||||
|
"Disk eject toggle",
|
||||||
|
"Disk next",
|
||||||
|
"Grab mouse toggle",
|
||||||
|
"RGUI menu toggle",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static enum retro_key find_sk_bind(const char *str)
|
static enum retro_key find_sk_bind(const char *str)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; input_config_key_map[i].str; i++)
|
for (size_t i = 0; input_config_key_map[i].str; i++)
|
||||||
|
|
|
@ -133,6 +133,7 @@ struct input_bind_map
|
||||||
unsigned retro_key;
|
unsigned retro_key;
|
||||||
};
|
};
|
||||||
extern const struct input_bind_map input_config_bind_map[];
|
extern const struct input_bind_map input_config_bind_map[];
|
||||||
|
extern const char *input_bind_to_str[];
|
||||||
|
|
||||||
struct input_key_map
|
struct input_key_map
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue