Can set RETRO_DEVICE_ANALOG with input descriptors now too

This commit is contained in:
twinaphex 2014-12-04 14:53:29 +01:00
parent 1e1457c45c
commit 6615f26749
3 changed files with 43 additions and 5 deletions

View File

@ -665,18 +665,55 @@ bool rarch_environment_cb(unsigned cmd, void *data)
for (; desc->description; desc++)
{
unsigned port = desc->port;
unsigned id = desc->id;
if (desc->port >= MAX_PLAYERS)
continue;
/* Ignore all others for now. */
if (desc->device != RETRO_DEVICE_JOYPAD)
if (desc->device != RETRO_DEVICE_JOYPAD &&
desc->device != RETRO_DEVICE_ANALOG)
continue;
if (desc->id >= RARCH_FIRST_CUSTOM_BIND)
continue;
g_extern.system.input_desc_btn[desc->port][desc->id] =
desc->description;
if (desc->device == RETRO_DEVICE_ANALOG)
{
switch (id)
{
case RETRO_DEVICE_ID_ANALOG_X:
switch (desc->index)
{
case RETRO_DEVICE_INDEX_ANALOG_LEFT:
g_extern.system.input_desc_btn[port][RARCH_ANALOG_LEFT_X_PLUS] = desc->description;
g_extern.system.input_desc_btn[port][RARCH_ANALOG_LEFT_X_MINUS] = desc->description;
break;
case RETRO_DEVICE_INDEX_ANALOG_RIGHT:
g_extern.system.input_desc_btn[port][RARCH_ANALOG_RIGHT_X_PLUS] = desc->description;
g_extern.system.input_desc_btn[port][RARCH_ANALOG_RIGHT_X_MINUS] = desc->description;
break;
}
break;
case RETRO_DEVICE_ID_ANALOG_Y:
switch (desc->index)
{
case RETRO_DEVICE_INDEX_ANALOG_LEFT:
g_extern.system.input_desc_btn[port][RARCH_ANALOG_LEFT_Y_PLUS] = desc->description;
g_extern.system.input_desc_btn[port][RARCH_ANALOG_LEFT_Y_MINUS] = desc->description;
break;
case RETRO_DEVICE_INDEX_ANALOG_RIGHT:
g_extern.system.input_desc_btn[port][RARCH_ANALOG_RIGHT_Y_PLUS] = desc->description;
g_extern.system.input_desc_btn[port][RARCH_ANALOG_RIGHT_Y_MINUS] = desc->description;
break;
}
break;
}
}
else
{
g_extern.system.input_desc_btn[port][id] = desc->description;
}
}
static const char *libretro_btn_desc[] = {

View File

@ -562,7 +562,7 @@ struct global
bool force_nonblock;
bool no_content;
const char *input_desc_btn[MAX_PLAYERS][RARCH_FIRST_CUSTOM_BIND];
const char *input_desc_btn[MAX_PLAYERS][RARCH_FIRST_META_KEY];
char valid_extensions[PATH_MAX];
retro_keyboard_event_t key_event;

View File

@ -4539,8 +4539,9 @@ static bool setting_data_append_list_input_options(
if (
g_settings.input.input_descriptor_label_show
&& (i < RARCH_FIRST_CUSTOM_BIND)
&& (i < RARCH_FIRST_META_KEY)
&& (g_extern.has_set_input_descriptors)
&& (i != RARCH_TURBO_ENABLE)
)
snprintf(label, sizeof(label), "%s %s", buffer[player],
g_extern.system.input_desc_btn[player][i] ? g_extern.system.input_desc_btn[player][i] : "N/A");