Report autoconfigured binds in RGUI.
This commit is contained in:
parent
82422946d6
commit
9bf32df360
|
@ -522,6 +522,8 @@ static int menu_info_screen_iterate(unsigned action)
|
||||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||||
driver.menu_ctx->render();
|
driver.menu_ctx->render();
|
||||||
|
|
||||||
|
// FIXME: This is unused code, why was it even here?
|
||||||
|
#if 0
|
||||||
static const unsigned binds[] = {
|
static const unsigned binds[] = {
|
||||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||||
|
@ -545,9 +547,11 @@ static int menu_info_screen_iterate(unsigned action)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const struct retro_keybind *bind = &g_settings.input.binds[0][binds[i]];
|
const struct retro_keybind *bind = &g_settings.input.binds[0][binds[i]];
|
||||||
input_get_bind_string(desc[i], bind, sizeof(desc[i]));
|
const struct retro_keybind *auto_bind = input_get_auto_bind(0, binds[i]);
|
||||||
|
input_get_bind_string(desc[i], bind, auto_bind, sizeof(desc[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (driver.menu->info_selection)
|
switch (driver.menu->info_selection)
|
||||||
{
|
{
|
||||||
|
@ -1484,7 +1488,8 @@ static int menu_start_screen_iterate(unsigned action)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const struct retro_keybind *bind = &g_settings.input.binds[0][binds[i]];
|
const struct retro_keybind *bind = &g_settings.input.binds[0][binds[i]];
|
||||||
input_get_bind_string(desc[i], bind, sizeof(desc[i]));
|
const struct retro_keybind *auto_bind = input_get_auto_bind(0, binds[i]);
|
||||||
|
input_get_bind_string(desc[i], bind, auto_bind, sizeof(desc[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4997,7 +5002,10 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
|
||||||
menu_common_setting_set_label_perf(type_str, type_str_size, w, type, perf_counters_libretro,
|
menu_common_setting_set_label_perf(type_str, type_str_size, w, type, perf_counters_libretro,
|
||||||
type - RGUI_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN);
|
type - RGUI_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN);
|
||||||
else if (type >= RGUI_SETTINGS_BIND_BEGIN && type <= RGUI_SETTINGS_BIND_ALL_LAST)
|
else if (type >= RGUI_SETTINGS_BIND_BEGIN && type <= RGUI_SETTINGS_BIND_ALL_LAST)
|
||||||
input_get_bind_string(type_str, &g_settings.input.binds[driver.menu->current_pad][type - RGUI_SETTINGS_BIND_BEGIN], type_str_size);
|
{
|
||||||
|
const struct retro_keybind *auto_bind = input_get_auto_bind(driver.menu->current_pad, type - RGUI_SETTINGS_BIND_BEGIN);
|
||||||
|
input_get_bind_string(type_str, &g_settings.input.binds[driver.menu->current_pad][type - RGUI_SETTINGS_BIND_BEGIN], auto_bind, type_str_size);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
@ -1225,18 +1225,23 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, const c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t size)
|
const struct retro_keybind *input_get_auto_bind(unsigned port, unsigned id)
|
||||||
|
{
|
||||||
|
int joy_index = g_settings.input.joypad_map[port];
|
||||||
|
if (joy_index < 0)
|
||||||
|
return NULL;
|
||||||
|
return &g_settings.input.autoconf_binds[joy_index][id];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void input_get_bind_string_joykey(char *buf, const char *prefix, const struct retro_keybind *bind, size_t size)
|
||||||
{
|
{
|
||||||
*buf = '\0';
|
|
||||||
if (bind->joykey != NO_BTN)
|
|
||||||
{
|
|
||||||
if (driver.input->set_keybinds)
|
if (driver.input->set_keybinds)
|
||||||
{
|
{
|
||||||
struct platform_bind key_label;
|
struct platform_bind key_label;
|
||||||
strlcpy(key_label.desc, "Unknown", sizeof(key_label.desc));
|
strlcpy(key_label.desc, "Unknown", sizeof(key_label.desc));
|
||||||
key_label.joykey = bind->joykey;
|
key_label.joykey = bind->joykey;
|
||||||
driver.input->set_keybinds(&key_label, 0, 0, 0, (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL));
|
driver.input->set_keybinds(&key_label, 0, 0, 0, (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL));
|
||||||
snprintf(buf, size, "%s (btn) ", key_label.desc);
|
snprintf(buf, size, "%s%s (btn) ", prefix, key_label.desc);
|
||||||
}
|
}
|
||||||
else if (GET_HAT_DIR(bind->joykey))
|
else if (GET_HAT_DIR(bind->joykey))
|
||||||
{
|
{
|
||||||
|
@ -1249,13 +1254,14 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t s
|
||||||
case HAT_RIGHT_MASK: dir = "right"; break;
|
case HAT_RIGHT_MASK: dir = "right"; break;
|
||||||
default: dir = "?"; break;
|
default: dir = "?"; break;
|
||||||
}
|
}
|
||||||
snprintf(buf, size, "Hat #%u %s ", (unsigned)GET_HAT(bind->joykey), dir);
|
snprintf(buf, size, "%sHat #%u %s ", prefix, (unsigned)GET_HAT(bind->joykey), dir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(buf, size, "%u (btn) ", (unsigned)bind->joykey);
|
snprintf(buf, size, "%s%u (btn) ", prefix, (unsigned)bind->joykey);
|
||||||
}
|
}
|
||||||
else if (bind->joyaxis != AXIS_NONE)
|
|
||||||
{
|
static void input_get_bind_string_joyaxis(char *buf, const char *prefix, const struct retro_keybind *bind, size_t size)
|
||||||
|
{
|
||||||
unsigned axis = 0;
|
unsigned axis = 0;
|
||||||
char dir = '\0';
|
char dir = '\0';
|
||||||
if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
|
if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
|
||||||
|
@ -1268,8 +1274,21 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t s
|
||||||
dir = '+';
|
dir = '+';
|
||||||
axis = AXIS_POS_GET(bind->joyaxis);
|
axis = AXIS_POS_GET(bind->joyaxis);
|
||||||
}
|
}
|
||||||
snprintf(buf, size, "%c%u (axis) ", dir, axis);
|
snprintf(buf, size, "%s%c%u (axis) ", prefix, dir, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void input_get_bind_string(char *buf, const struct retro_keybind *bind,
|
||||||
|
const struct retro_keybind *auto_bind, size_t size)
|
||||||
|
{
|
||||||
|
*buf = '\0';
|
||||||
|
if (bind->joykey != NO_BTN)
|
||||||
|
input_get_bind_string_joykey(buf, "", bind, size);
|
||||||
|
else if (bind->joyaxis != AXIS_NONE)
|
||||||
|
input_get_bind_string_joyaxis(buf, "", bind, size);
|
||||||
|
else if (auto_bind && auto_bind->joykey != NO_BTN)
|
||||||
|
input_get_bind_string_joykey(buf, "Auto: ", auto_bind, size);
|
||||||
|
else if (auto_bind && auto_bind->joyaxis != AXIS_NONE)
|
||||||
|
input_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size);
|
||||||
|
|
||||||
#ifndef RARCH_CONSOLE
|
#ifndef RARCH_CONSOLE
|
||||||
char key[64];
|
char key[64];
|
||||||
|
|
|
@ -143,7 +143,9 @@ struct input_bind_map
|
||||||
|
|
||||||
extern const struct input_bind_map input_config_bind_map[];
|
extern const struct input_bind_map input_config_bind_map[];
|
||||||
|
|
||||||
void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t size);
|
const struct retro_keybind *input_get_auto_bind(unsigned port, unsigned id);
|
||||||
|
// auto_bind can be NULL.
|
||||||
|
void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size);
|
||||||
|
|
||||||
struct input_key_map
|
struct input_key_map
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue