Add some testing of new controller info API to libretro-test.
This commit is contained in:
parent
a14f0a2760
commit
aafe28bb14
|
@ -971,7 +971,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
|||
{
|
||||
RARCH_LOG("Controller port: %u\n", i);
|
||||
for (j = 0; j < info[i].num_types; j++)
|
||||
RARCH_LOG(" %s (ident: %s, ID: %u)\n", info[i].types[j].desc, info[i].types[j].ident, info[i].types[j].id);
|
||||
RARCH_LOG(" %s (ID: %u)\n", info[i].types[j].desc, info[i].types[j].id);
|
||||
}
|
||||
|
||||
free(g_extern.system.ports);
|
||||
|
|
|
@ -2201,7 +2201,16 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
|
|||
}
|
||||
case RGUI_SETTINGS_BIND_DEVICE_TYPE:
|
||||
{
|
||||
const char *name;
|
||||
const struct retro_controller_description *desc = NULL;
|
||||
if (rgui->current_pad < g_extern.system.num_ports)
|
||||
{
|
||||
desc = libretro_find_controller_description(&g_extern.system.ports[rgui->current_pad],
|
||||
g_settings.input.libretro_device[rgui->current_pad]);
|
||||
}
|
||||
|
||||
const char *name = desc ? desc->desc : NULL;
|
||||
if (!name) // Find generic name.
|
||||
{
|
||||
switch (g_settings.input.libretro_device[rgui->current_pad])
|
||||
{
|
||||
case RETRO_DEVICE_NONE: name = "None"; break;
|
||||
|
@ -2210,6 +2219,7 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
|
|||
case RETRO_DEVICE_MOUSE: name = "Mouse"; break;
|
||||
default: name = "Unknown"; break;
|
||||
}
|
||||
}
|
||||
|
||||
strlcpy(type_str, name, type_str_size);
|
||||
break;
|
||||
|
|
|
@ -39,8 +39,7 @@ unsigned retro_api_version(void)
|
|||
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
(void)port;
|
||||
(void)device;
|
||||
logging.log(RETRO_LOG_INFO, "Plugging device %u into port %u.\n", device, port);
|
||||
}
|
||||
|
||||
void retro_get_system_info(struct retro_system_info *info)
|
||||
|
@ -130,6 +129,18 @@ void retro_set_environment(retro_environment_t cb)
|
|||
};
|
||||
|
||||
cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)types);
|
||||
|
||||
static const struct retro_controller_description controllers[] = {
|
||||
{ "Dummy Controller #1", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0) },
|
||||
{ "Dummy Controller #2", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1) },
|
||||
};
|
||||
|
||||
static const struct retro_controller_info ports[] = {
|
||||
{ controllers, 2 },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
||||
}
|
||||
|
||||
void retro_set_audio_sample(retro_audio_sample_t cb)
|
||||
|
|
|
@ -644,9 +644,6 @@ struct retro_controller_description
|
|||
// set to the particular device type the core uses.
|
||||
const char *desc;
|
||||
|
||||
// A computer-friendly short string identifier ([a-z]).
|
||||
const char *ident;
|
||||
|
||||
// Device type passed to retro_set_controller_port_device(). If the device type is a sub-class of a generic input device type,
|
||||
// use the RETRO_DEVICE_SUBCLASS macro to create an ID. E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1).
|
||||
unsigned id;
|
||||
|
|
Loading…
Reference in New Issue