Implement KEYBINDS_ACTION_GET_BIND_LABEL - will be used through

set_keybinds
This commit is contained in:
twinaphex 2013-03-14 18:02:19 +01:00
parent fd05b5a25c
commit 44ccbe0122
4 changed files with 65 additions and 16 deletions

View File

@ -135,7 +135,7 @@ struct retro_keybind
struct platform_bind
{
uint64_t joykey;
const char *desc;
char *desc;
};
enum rarch_shader_type
@ -223,6 +223,7 @@ enum keybind_set_id
KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE,
KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK,
KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK,
KEYBINDS_ACTION_GET_BIND_LABEL,
KEYBINDS_ACTION_LAST
};

View File

@ -168,14 +168,12 @@ static void gx_input_set_keybinds(void *data, unsigned device, unsigned port,
{
uint64_t *key = &g_settings.input.binds[port][id].joykey;
uint64_t joykey = *key;
size_t arr_size;
size_t arr_size = platform_keys_size / sizeof(platform_keys[0]);
(void)device;
if (keybind_action & (1ULL << KEYBINDS_ACTION_DECREMENT_BIND))
{
arr_size = platform_keys_size / sizeof(platform_keys[0]);
if (joykey == NO_BTN)
*key = platform_keys[arr_size - 1].joykey;
else if (platform_keys[0].joykey == joykey)
@ -196,8 +194,6 @@ static void gx_input_set_keybinds(void *data, unsigned device, unsigned port,
if (keybind_action & (1ULL << KEYBINDS_ACTION_INCREMENT_BIND))
{
arr_size = platform_keys_size / sizeof(platform_keys[0]);
if (joykey == NO_BTN)
*key = platform_keys[0].joykey;
else if (platform_keys[arr_size - 1].joykey == joykey)
@ -412,6 +408,26 @@ static void gx_input_set_keybinds(void *data, unsigned device, unsigned port,
break;
}
}
if (keybind_action & (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL))
{
struct platform_bind *ret = (struct platform_bind*)data;
if (ret->joykey == NO_BTN)
strlcpy(ret->desc, "No button", sizeof(ret->desc));
else
{
for (size_t i = 0; i < arr_size; i++)
{
if (platform_keys[i].joykey == joykey)
{
strlcpy(ret->desc, platform_keys[i].desc, sizeof(ret->desc));
return;
}
}
strlcpy(ret->desc, "Unknown", sizeof(ret->desc));
}
}
}
static void *gx_input_init(void)

View File

@ -402,14 +402,12 @@ static void ps3_input_set_keybinds(void *data, unsigned device,
{
uint64_t *key = &g_settings.input.binds[port][id].joykey;
uint64_t joykey = *key;
size_t arr_size;
size_t arr_size = platform_keys_size / sizeof(platform_keys[0]);
(void)device;
if (keybind_action & (1ULL << KEYBINDS_ACTION_DECREMENT_BIND))
{
arr_size = platform_keys_size / sizeof(platform_keys[0]);
if (joykey == NO_BTN)
*key = platform_keys[arr_size - 1].joykey;
else if (platform_keys[0].joykey == joykey)
@ -430,8 +428,6 @@ static void ps3_input_set_keybinds(void *data, unsigned device,
if (keybind_action & (1ULL << KEYBINDS_ACTION_INCREMENT_BIND))
{
arr_size = platform_keys_size / sizeof(platform_keys[0]);
if (joykey == NO_BTN)
*key = platform_keys[0].joykey;
else if (platform_keys[arr_size - 1].joykey == joykey)
@ -490,6 +486,26 @@ static void ps3_input_set_keybinds(void *data, unsigned device,
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[RARCH_ANALOG_RIGHT_X_DPAD_LEFT].joykey;
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[RARCH_ANALOG_RIGHT_X_DPAD_RIGHT].joykey;
}
if (keybind_action & (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL))
{
struct platform_bind *ret = (struct platform_bind*)data;
if (ret->joykey == NO_BTN)
strlcpy(ret->desc, "No button", sizeof(ret->desc));
else
{
for (size_t i = 0; i < arr_size; i++)
{
if (platform_keys[i].joykey == joykey)
{
strlcpy(ret->desc, platform_keys[i].desc, sizeof(ret->desc));
return;
}
}
strlcpy(ret->desc, "Unknown", sizeof(ret->desc));
}
}
}
static void* ps3_input_init(void)

View File

@ -274,14 +274,12 @@ static void xdk_input_set_keybinds(void *data, unsigned device,
{
uint64_t *key = &g_settings.input.binds[port][id].joykey;
uint64_t joykey = *key;
size_t arr_size;
size_t arr_size = platform_keys_size / sizeof(platform_keys[0]);
(void)device;
if (keybind_action & (1ULL << KEYBINDS_ACTION_DECREMENT_BIND))
{
arr_size = platform_keys_size / sizeof(platform_keys[0]);
if (joykey == NO_BTN)
*key = platform_keys[arr_size - 1].joykey;
else if (platform_keys[0].joykey == joykey)
@ -302,8 +300,6 @@ static void xdk_input_set_keybinds(void *data, unsigned device,
if (keybind_action & (1ULL << KEYBINDS_ACTION_INCREMENT_BIND))
{
arr_size = platform_keys_size / sizeof(platform_keys[0]);
if (joykey == NO_BTN)
*key = platform_keys[0].joykey;
else if (platform_keys[arr_size - 1].joykey == joykey)
@ -363,6 +359,26 @@ static void xdk_input_set_keybinds(void *data, unsigned device,
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[RARCH_ANALOG_RIGHT_X_DPAD_LEFT].joykey;
g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[RARCH_ANALOG_RIGHT_X_DPAD_RIGHT].joykey;
}
if (keybind_action & (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL))
{
struct platform_bind *ret = (struct platform_bind*)data;
if (ret->joykey == NO_BTN)
strlcpy(ret->desc, "No button", sizeof(ret->desc));
else
{
for (size_t i = 0; i < arr_size; i++)
{
if (platform_keys[i].joykey == joykey)
{
strlcpy(ret->desc, platform_keys[i].desc, sizeof(ret->desc));
return;
}
}
strlcpy(ret->desc, "Unknown", sizeof(ret->desc));
}
}
}
static void *xdk_input_init(void)