mirror of
https://github.com/izzy2lost/RetroArch.git
synced 2026-03-26 16:42:27 -07:00
Input binding rework (#15603)
* Input binding rework * Controller info logging cleanup
This commit is contained in:
+2
-2
@@ -1520,8 +1520,8 @@
|
||||
#define DEFAULT_INPUT_MAX_USERS 8
|
||||
#endif
|
||||
|
||||
#define DEFAULT_INPUT_BIND_TIMEOUT 5
|
||||
#define DEFAULT_INPUT_BIND_HOLD 2
|
||||
#define DEFAULT_INPUT_BIND_TIMEOUT 3
|
||||
#define DEFAULT_INPUT_BIND_HOLD 1
|
||||
#define DEFAULT_INPUT_POLL_TYPE_BEHAVIOR 2
|
||||
#define DEFAULT_INPUT_HOTKEY_BLOCK_DELAY 5
|
||||
|
||||
|
||||
+28
-41
@@ -97,10 +97,10 @@ const unsigned input_config_bind_order[24] = {
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_X,
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_Y,
|
||||
RETRO_DEVICE_ID_JOYPAD_X,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_L,
|
||||
@@ -3024,18 +3024,20 @@ void input_config_get_bind_string(
|
||||
|
||||
if (bind && bind->joykey != NO_BTN)
|
||||
input_config_get_bind_string_joykey(
|
||||
input_descriptor_label_show, buf, "", bind, size);
|
||||
input_descriptor_label_show,
|
||||
buf, "", bind, size);
|
||||
else if (bind && bind->joyaxis != AXIS_NONE)
|
||||
input_config_get_bind_string_joyaxis(
|
||||
input_descriptor_label_show,
|
||||
buf, "", bind, size);
|
||||
else if (auto_bind && auto_bind->joykey != NO_BTN)
|
||||
input_config_get_bind_string_joykey(
|
||||
input_descriptor_label_show, buf, "Auto: ", auto_bind, size);
|
||||
input_descriptor_label_show,
|
||||
buf, "(Auto)", auto_bind, size);
|
||||
else if (auto_bind && auto_bind->joyaxis != AXIS_NONE)
|
||||
input_config_get_bind_string_joyaxis(
|
||||
input_descriptor_label_show,
|
||||
buf, "Auto: ", auto_bind, size);
|
||||
buf, "(Auto)", auto_bind, size);
|
||||
|
||||
if (*buf)
|
||||
delim = 1;
|
||||
@@ -3118,7 +3120,7 @@ void input_config_get_bind_string(
|
||||
|
||||
void input_config_get_bind_string_joykey(
|
||||
bool input_descriptor_label_show,
|
||||
char *buf, const char *prefix,
|
||||
char *buf, const char *suffix,
|
||||
const struct retro_keybind *bind, size_t size)
|
||||
{
|
||||
if (GET_HAT_DIR(bind->joykey))
|
||||
@@ -3127,39 +3129,32 @@ void input_config_get_bind_string_joykey(
|
||||
&& !string_is_empty(bind->joykey_label)
|
||||
&& input_descriptor_label_show)
|
||||
{
|
||||
size_t len = fill_pathname_join_delim(buf, prefix,
|
||||
bind->joykey_label, ' ', size);
|
||||
strlcpy(buf + len, " (hat)", size - len);
|
||||
size_t len = fill_pathname_join_delim(buf,
|
||||
bind->joykey_label, suffix, ' ', size);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t len = strlcpy(buf, prefix, size);
|
||||
len += snprintf(buf + len, size - len, "Hat #%u ",
|
||||
(unsigned)GET_HAT(bind->joykey));
|
||||
size_t len = snprintf(buf, size,
|
||||
"Hat #%u ", (unsigned)GET_HAT(bind->joykey));
|
||||
|
||||
switch (GET_HAT_DIR(bind->joykey))
|
||||
{
|
||||
case HAT_UP_MASK:
|
||||
len += strlcpy(buf + len, "up (", size - len);
|
||||
len += strlcpy(buf + len, "Up", size - len);
|
||||
break;
|
||||
case HAT_DOWN_MASK:
|
||||
len += strlcpy(buf + len, "down (", size - len);
|
||||
len += strlcpy(buf + len, "Down", size - len);
|
||||
break;
|
||||
case HAT_LEFT_MASK:
|
||||
len += strlcpy(buf + len, "left (", size - len);
|
||||
len += strlcpy(buf + len, "Left", size - len);
|
||||
break;
|
||||
case HAT_RIGHT_MASK:
|
||||
len += strlcpy(buf + len, "right (", size - len);
|
||||
len += strlcpy(buf + len, "Right", size - len);
|
||||
break;
|
||||
default:
|
||||
len += strlcpy(buf + len, "? (", size - len);
|
||||
len += strlcpy(buf + len, "?", size - len);
|
||||
break;
|
||||
}
|
||||
len += strlcpy(buf + len,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
|
||||
size - len);
|
||||
buf[ len] = ')';
|
||||
buf[++len] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3168,43 +3163,35 @@ void input_config_get_bind_string_joykey(
|
||||
!string_is_empty(bind->joykey_label)
|
||||
&& input_descriptor_label_show)
|
||||
{
|
||||
size_t len = fill_pathname_join_delim(buf, prefix,
|
||||
bind->joykey_label, ' ', size);
|
||||
strlcpy(buf + len, " (btn)", size - len);
|
||||
size_t len = fill_pathname_join_delim(buf,
|
||||
bind->joykey_label, suffix, ' ', size);
|
||||
}
|
||||
else
|
||||
snprintf(buf, size, "%s%u (%s)", prefix, (unsigned)bind->joykey,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
|
||||
snprintf(buf, size, "%s%u",
|
||||
"Button ", (unsigned)bind->joykey);
|
||||
}
|
||||
}
|
||||
|
||||
void input_config_get_bind_string_joyaxis(
|
||||
bool input_descriptor_label_show,
|
||||
char *buf, const char *prefix,
|
||||
char *buf, const char *suffix,
|
||||
const struct retro_keybind *bind, size_t size)
|
||||
{
|
||||
if (bind->joyaxis_label &&
|
||||
!string_is_empty(bind->joyaxis_label)
|
||||
&& input_descriptor_label_show)
|
||||
{
|
||||
size_t len = fill_pathname_join_delim(buf, prefix,
|
||||
bind->joyaxis_label, ' ', size);
|
||||
strlcpy(buf + len, " (axis)", size - len);
|
||||
size_t len = fill_pathname_join_delim(buf,
|
||||
bind->joyaxis_label, suffix, ' ', size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
|
||||
{
|
||||
unsigned axis = AXIS_NEG_GET(bind->joyaxis);
|
||||
snprintf(buf, size, "%s-%u (%s)", prefix, axis,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
|
||||
}
|
||||
snprintf(buf, size, "%s-%u",
|
||||
"Axis ", (unsigned)AXIS_NEG_GET(bind->joyaxis));
|
||||
else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE)
|
||||
{
|
||||
unsigned axis = AXIS_POS_GET(bind->joyaxis);
|
||||
snprintf(buf, size, "%s+%u (%s)", prefix, axis,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
|
||||
}
|
||||
snprintf(buf, size, "%s+%u",
|
||||
"Axis ", (unsigned)AXIS_POS_GET(bind->joyaxis));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,8 @@ enum input_driver_state_flags
|
||||
INP_FLAG_OLD_ANALOG_DPAD_MODE_SET = (1 << 7),
|
||||
INP_FLAG_OLD_LIBRETRO_DEVICE_SET = (1 << 8),
|
||||
INP_FLAG_REMAPPING_CACHE_ACTIVE = (1 << 9),
|
||||
INP_FLAG_DEFERRED_WAIT_KEYS = (1 << 10)
|
||||
INP_FLAG_DEFERRED_WAIT_KEYS = (1 << 10),
|
||||
INP_FLAG_WAIT_INPUT_RELEASE = (1 << 11)
|
||||
};
|
||||
|
||||
#ifdef HAVE_BSV_MOVIE
|
||||
|
||||
@@ -1891,10 +1891,6 @@ MSG_HASH(
|
||||
"input_touch_vmouse_gesture"
|
||||
)
|
||||
#endif
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_BIND_MODE,
|
||||
"input_bind_mode"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT,
|
||||
"input_bind_timeout"
|
||||
|
||||
+17
-1
@@ -3162,6 +3162,22 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
|
||||
"Amount of seconds to hold an input to bind it."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INPUT_BIND_PRESS,
|
||||
"Press keyboard, mouse or controller"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INPUT_BIND_RELEASE,
|
||||
"Release keys and buttons!"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INPUT_BIND_TIMEOUT,
|
||||
"Timeout"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INPUT_BIND_HOLD,
|
||||
"Hold"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_TURBO_PERIOD,
|
||||
"Turbo Period"
|
||||
@@ -10550,7 +10566,7 @@ MSG_HASH(
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_KEY,
|
||||
"(Key: %s)"
|
||||
"Key %s"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT,
|
||||
|
||||
@@ -2406,13 +2406,13 @@ static uintptr_t ozone_entries_icon_get_texture(
|
||||
if (type == (input_id + 3))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_R];
|
||||
if (type == (input_id + 4))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R];
|
||||
if (type == (input_id + 5))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D];
|
||||
if (type == (input_id + 5))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R];
|
||||
if (type == (input_id + 6))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_U];
|
||||
if (type == (input_id + 7))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_L];
|
||||
if (type == (input_id + 7))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_U];
|
||||
if (type == (input_id + 8))
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_SELECT];
|
||||
if (type == (input_id + 9))
|
||||
|
||||
+4
-4
@@ -3554,13 +3554,13 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb,
|
||||
else if (type == (input_id + 3))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_DPAD_R];
|
||||
else if (type == (input_id + 4))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_R];
|
||||
else if (type == (input_id + 5))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_D];
|
||||
else if (type == (input_id + 5))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_R];
|
||||
else if (type == (input_id + 6))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_U];
|
||||
else if (type == (input_id + 7))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_L];
|
||||
else if (type == (input_id + 7))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_U];
|
||||
else if (type == (input_id + 8))
|
||||
return xmb->textures.list[XMB_TEXTURE_INPUT_SELECT];
|
||||
else if (type == (input_id + 9))
|
||||
|
||||
@@ -7601,7 +7601,6 @@ unsigned menu_displaylist_build_list(
|
||||
#endif
|
||||
{MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT, PARSE_ONLY_UINT, true },
|
||||
{MENU_ENUM_LABEL_INPUT_BIND_HOLD, PARSE_ONLY_UINT, true },
|
||||
{MENU_ENUM_LABEL_INPUT_BIND_MODE, PARSE_ONLY_UINT, true },
|
||||
{MENU_ENUM_LABEL_QUIT_PRESS_TWICE, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_PAUSE_ON_DISCONNECT, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_INPUT_AUTO_MOUSE_GRAB, PARSE_ONLY_BOOL, true },
|
||||
|
||||
+230
-145
File diff suppressed because it is too large
Load Diff
@@ -150,6 +150,7 @@ struct menu_bind_state_port
|
||||
uint16_t hats[MENU_MAX_HATS];
|
||||
bool mouse_buttons[MENU_MAX_MBUTTONS];
|
||||
bool buttons[MENU_MAX_BUTTONS];
|
||||
bool keys[RETROK_LAST];
|
||||
};
|
||||
|
||||
struct menu_bind_axis_state
|
||||
@@ -174,6 +175,7 @@ struct menu_bind_state
|
||||
|
||||
unsigned begin;
|
||||
unsigned last;
|
||||
unsigned order;
|
||||
unsigned user;
|
||||
unsigned port;
|
||||
|
||||
|
||||
+3
-3
@@ -14883,7 +14883,7 @@ static bool setting_append_list(
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
(*list)[list_info->index - 1].offset_by = 1;
|
||||
menu_settings_list_current_add_range(list, list_info, 1, 10, 1, true, true);
|
||||
menu_settings_list_current_add_range(list, list_info, 1, 5, 1, true, true);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
|
||||
|
||||
CONFIG_UINT(
|
||||
@@ -14898,8 +14898,8 @@ static bool setting_append_list(
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
(*list)[list_info->index - 1].offset_by = 1;
|
||||
menu_settings_list_current_add_range(list, list_info, 1, 10, 1, true, true);
|
||||
(*list)[list_info->index - 1].offset_by = 0;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, 5, 1, true, true);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
|
||||
|
||||
CONFIG_ACTION(
|
||||
|
||||
+4
-1
@@ -391,6 +391,10 @@ enum msg_hash_enums
|
||||
MSG_REMAP_FILE_SAVED_SUCCESSFULLY,
|
||||
MSG_REMAP_FILE_REMOVED_SUCCESSFULLY,
|
||||
MSG_REMAP_FILE_RESET,
|
||||
MSG_INPUT_BIND_PRESS,
|
||||
MSG_INPUT_BIND_RELEASE,
|
||||
MSG_INPUT_BIND_TIMEOUT,
|
||||
MSG_INPUT_BIND_HOLD,
|
||||
MSG_OVERRIDE_UNLOAD,
|
||||
MSG_SHADER_PRESET_SAVED_SUCCESSFULLY,
|
||||
MSG_SHADER_PRESET_REMOVED_SUCCESSFULLY,
|
||||
@@ -961,7 +965,6 @@ enum msg_hash_enums
|
||||
|
||||
MENU_LABEL(INPUT_REMAPPING_DIRECTORY),
|
||||
|
||||
MENU_ENUM_LABEL_INPUT_BIND_MODE,
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY,
|
||||
MENU_ENUM_LABEL_INPUT_OSK_OVERLAY,
|
||||
|
||||
|
||||
@@ -2049,13 +2049,6 @@ bool runloop_environment_cb(unsigned cmd, void *data)
|
||||
|
||||
case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS:
|
||||
{
|
||||
static const char *libretro_btn_desc[] = {
|
||||
"B (bottom)", "Y (left)", "Select", "Start",
|
||||
"D-Pad Up", "D-Pad Down", "D-Pad Left", "D-Pad Right",
|
||||
"A (right)", "X (up)",
|
||||
"L", "R", "L2", "R2", "L3", "R3",
|
||||
};
|
||||
|
||||
if (sys_info)
|
||||
{
|
||||
unsigned retro_id;
|
||||
@@ -2156,15 +2149,19 @@ bool runloop_environment_cb(unsigned cmd, void *data)
|
||||
{
|
||||
unsigned mapped_port = settings->uints.input_remap_ports[p];
|
||||
|
||||
RARCH_DBG(" %s %u:\n", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), p + 1);
|
||||
|
||||
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND; retro_id++)
|
||||
{
|
||||
const char *description = sys_info->input_desc_btn[mapped_port][retro_id];
|
||||
unsigned bind_index = input_config_bind_order[retro_id];
|
||||
const char *description = sys_info->input_desc_btn[mapped_port][bind_index];
|
||||
|
||||
if (!description)
|
||||
continue;
|
||||
|
||||
RARCH_DBG(" RetroPad, Port %u, Button \"%s\" => \"%s\"\n",
|
||||
p + 1, libretro_btn_desc[retro_id], description);
|
||||
RARCH_DBG(" \"%s\" => \"%s\"\n",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B + bind_index),
|
||||
description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2802,10 +2799,12 @@ bool runloop_environment_cb(unsigned cmd, void *data)
|
||||
if (log_level != RETRO_LOG_DEBUG)
|
||||
continue;
|
||||
|
||||
RARCH_DBG(" Controller port: %u\n", i + 1);
|
||||
RARCH_DBG(" %s %u:\n", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), i + 1);
|
||||
|
||||
for (j = 0; j < info[i].num_types; j++)
|
||||
RARCH_DBG(" %s (ID: %u)\n", info[i].types[j].desc,
|
||||
if (info[i].types[j].desc)
|
||||
RARCH_DBG(" \"%s\" (%u)\n",
|
||||
info[i].types[j].desc,
|
||||
info[i].types[j].id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user