mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Move input_config_get_bind_string to input_driver.c
This commit is contained in:
parent
ad39b1d115
commit
b5138b6122
@ -1827,6 +1827,114 @@ unsigned input_config_translate_str_to_bind_id(const char *str)
|
||||
return RARCH_BIND_LIST_END;
|
||||
}
|
||||
|
||||
void input_config_get_bind_string(
|
||||
void *settings_data,
|
||||
char *buf,
|
||||
const struct retro_keybind *bind,
|
||||
const struct retro_keybind *auto_bind,
|
||||
size_t size)
|
||||
{
|
||||
settings_t *settings = (settings_t*)settings_data;
|
||||
int delim = 0;
|
||||
bool input_descriptor_label_show =
|
||||
settings->bools.input_descriptor_label_show;
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
if (bind && bind->joykey != NO_BTN)
|
||||
input_config_get_bind_string_joykey(
|
||||
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);
|
||||
else if (auto_bind && auto_bind->joyaxis != AXIS_NONE)
|
||||
input_config_get_bind_string_joyaxis(
|
||||
input_descriptor_label_show,
|
||||
buf, "Auto: ", auto_bind, size);
|
||||
|
||||
if (*buf)
|
||||
delim = 1;
|
||||
|
||||
#ifndef RARCH_CONSOLE
|
||||
{
|
||||
char key[64];
|
||||
key[0] = '\0';
|
||||
|
||||
input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key));
|
||||
if ( key[0] == 'n'
|
||||
&& key[1] == 'u'
|
||||
&& key[2] == 'l'
|
||||
&& key[3] == '\0'
|
||||
)
|
||||
*key = '\0';
|
||||
/*empty?*/
|
||||
if (*key != '\0')
|
||||
{
|
||||
char keybuf[64];
|
||||
|
||||
keybuf[0] = '\0';
|
||||
|
||||
if (delim)
|
||||
strlcat(buf, ", ", size);
|
||||
snprintf(keybuf, sizeof(keybuf),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key);
|
||||
strlcat(buf, keybuf, size);
|
||||
delim = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bind->mbutton != NO_BTN)
|
||||
{
|
||||
int tag = 0;
|
||||
switch (bind->mbutton)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tag != 0)
|
||||
{
|
||||
if (delim)
|
||||
strlcat(buf, ", ", size);
|
||||
strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size);
|
||||
}
|
||||
}
|
||||
|
||||
/*completely empty?*/
|
||||
if (*buf == '\0')
|
||||
strlcat(buf, "---", size);
|
||||
}
|
||||
|
||||
void input_config_get_bind_string_joykey(
|
||||
bool input_descriptor_label_show,
|
||||
char *buf, const char *prefix,
|
||||
|
@ -144,7 +144,8 @@ uint8_t input_config_bind_map_get_retro_key(unsigned index);
|
||||
* @param auto_bind A default binding which will be used after `bind`. Can be NULL.
|
||||
* @param size The maximum length that will be written to `buf`
|
||||
*/
|
||||
void input_config_get_bind_string(char *buf, const struct retro_keybind *bind,
|
||||
void input_config_get_bind_string(void *settings_data,
|
||||
char *buf, const struct retro_keybind *bind,
|
||||
const struct retro_keybind *auto_bind, size_t size);
|
||||
|
||||
/**
|
||||
|
@ -9969,7 +9969,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
(const struct retro_keybind*)
|
||||
input_config_get_bind_auto(port, retro_id);
|
||||
|
||||
input_config_get_bind_string(descriptor,
|
||||
input_config_get_bind_string(settings, descriptor,
|
||||
keybind, auto_bind, sizeof(descriptor));
|
||||
|
||||
if (!strstr(descriptor, "Auto"))
|
||||
@ -10020,7 +10020,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
(const struct retro_keybind*)
|
||||
input_config_get_bind_auto(port, retro_id);
|
||||
|
||||
input_config_get_bind_string(descriptor,
|
||||
input_config_get_bind_string(settings, descriptor,
|
||||
keybind, auto_bind, sizeof(descriptor));
|
||||
|
||||
if (!strstr(descriptor, "Auto"))
|
||||
|
@ -1951,7 +1951,7 @@ int menu_dialog_iterate(
|
||||
(const struct retro_keybind*)
|
||||
input_config_get_bind_auto(0, binds[i]);
|
||||
|
||||
input_config_get_bind_string(desc[i],
|
||||
input_config_get_bind_string(settings, desc[i],
|
||||
keybind, auto_bind, sizeof(desc[i]));
|
||||
}
|
||||
|
||||
|
@ -1303,6 +1303,7 @@ static void setting_get_string_representation_st_bind(rarch_setting_t *setting,
|
||||
unsigned index_offset = 0;
|
||||
const struct retro_keybind* keybind = NULL;
|
||||
const struct retro_keybind* auto_bind = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!setting)
|
||||
return;
|
||||
@ -1312,7 +1313,7 @@ static void setting_get_string_representation_st_bind(rarch_setting_t *setting,
|
||||
auto_bind = (const struct retro_keybind*)
|
||||
input_config_get_bind_auto(index_offset, keybind->id);
|
||||
|
||||
input_config_get_bind_string(s, keybind, auto_bind, len);
|
||||
input_config_get_bind_string(settings, s, keybind, auto_bind, len);
|
||||
}
|
||||
|
||||
static int setting_action_action_ok(
|
||||
|
107
retroarch.c
107
retroarch.c
@ -20975,113 +20975,6 @@ void input_keyboard_event(bool down, unsigned code,
|
||||
}
|
||||
}
|
||||
|
||||
void input_config_get_bind_string(char *buf,
|
||||
const struct retro_keybind *bind,
|
||||
const struct retro_keybind *auto_bind,
|
||||
size_t size)
|
||||
{
|
||||
int delim = 0;
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
bool input_descriptor_label_show =
|
||||
settings->bools.input_descriptor_label_show;
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
if (bind && bind->joykey != NO_BTN)
|
||||
input_config_get_bind_string_joykey(
|
||||
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);
|
||||
else if (auto_bind && auto_bind->joyaxis != AXIS_NONE)
|
||||
input_config_get_bind_string_joyaxis(
|
||||
input_descriptor_label_show,
|
||||
buf, "Auto: ", auto_bind, size);
|
||||
|
||||
if (*buf)
|
||||
delim = 1;
|
||||
|
||||
#ifndef RARCH_CONSOLE
|
||||
{
|
||||
char key[64];
|
||||
key[0] = '\0';
|
||||
|
||||
input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key));
|
||||
if ( key[0] == 'n'
|
||||
&& key[1] == 'u'
|
||||
&& key[2] == 'l'
|
||||
&& key[3] == '\0'
|
||||
)
|
||||
*key = '\0';
|
||||
/*empty?*/
|
||||
if (*key != '\0')
|
||||
{
|
||||
char keybuf[64];
|
||||
|
||||
keybuf[0] = '\0';
|
||||
|
||||
if (delim)
|
||||
strlcat(buf, ", ", size);
|
||||
snprintf(keybuf, sizeof(keybuf),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key);
|
||||
strlcat(buf, keybuf, size);
|
||||
delim = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bind->mbutton != NO_BTN)
|
||||
{
|
||||
int tag = 0;
|
||||
switch (bind->mbutton)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||
tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tag != 0)
|
||||
{
|
||||
if (delim)
|
||||
strlcat(buf, ", ", size);
|
||||
strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size);
|
||||
}
|
||||
}
|
||||
|
||||
/*completely empty?*/
|
||||
if (*buf == '\0')
|
||||
strlcat(buf, "---", size);
|
||||
}
|
||||
|
||||
/* input_device_info wrappers START */
|
||||
|
||||
unsigned input_config_get_device_count(void)
|
||||
|
@ -287,7 +287,7 @@ QWidget *UserBindsPage::widget()
|
||||
(const struct retro_keybind*)
|
||||
input_config_get_bind_auto(p, retro_id);
|
||||
|
||||
input_config_get_bind_string(descriptor,
|
||||
input_config_get_bind_string(settings, descriptor,
|
||||
keybind, auto_bind, sizeof(descriptor));
|
||||
|
||||
const struct retro_keybind *keyptr =
|
||||
|
Loading…
x
Reference in New Issue
Block a user