mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-22 09:15:02 +00:00
Add RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS.
This commit is contained in:
parent
4402fcb323
commit
8981dd6c6b
43
dynamic.c
43
dynamic.c
@ -352,6 +352,49 @@ static bool environment_cb(unsigned cmd, void *data)
|
||||
break;
|
||||
}
|
||||
|
||||
case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS:
|
||||
{
|
||||
memset(g_extern.system.input_desc_btn, 0, sizeof(g_extern.system.input_desc_btn));
|
||||
|
||||
const struct retro_input_descriptor *desc = (const struct retro_input_descriptor*)data;
|
||||
for (; desc->description; desc++)
|
||||
{
|
||||
if (desc->port >= MAX_PLAYERS)
|
||||
continue;
|
||||
|
||||
if (desc->device != RETRO_DEVICE_JOYPAD) // Ignore all others for now.
|
||||
continue;
|
||||
|
||||
if (desc->id >= RARCH_FIRST_ANALOG_BIND)
|
||||
continue;
|
||||
|
||||
g_extern.system.input_desc_btn[desc->port][desc->id] = desc->description;
|
||||
}
|
||||
|
||||
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",
|
||||
};
|
||||
|
||||
RARCH_LOG("Environ SET_INPUT_DESCRIPTORS:\n");
|
||||
for (unsigned p = 0; p < MAX_PLAYERS; p++)
|
||||
{
|
||||
for (unsigned id = 0; id < RARCH_FIRST_ANALOG_BIND; id++)
|
||||
{
|
||||
const char *desc = g_extern.system.input_desc_btn[p][id];
|
||||
if (desc)
|
||||
{
|
||||
RARCH_LOG("\tRetroPad, Player %u, Button \"%s\" => \"%s\"\n",
|
||||
p + 1, libretro_btn_desc[id], desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);
|
||||
return false;
|
||||
|
@ -344,6 +344,8 @@ struct global
|
||||
bool rgb32;
|
||||
|
||||
bool force_nonblock;
|
||||
|
||||
const char *input_desc_btn[MAX_PLAYERS][RARCH_FIRST_ANALOG_BIND];
|
||||
} system;
|
||||
|
||||
struct
|
||||
|
@ -170,6 +170,16 @@ void retro_run(void)
|
||||
|
||||
bool retro_load_game(const struct retro_game_info *info)
|
||||
{
|
||||
struct retro_input_descriptor desc[] = {
|
||||
{ .port = 0, .device = RETRO_DEVICE_JOYPAD, .index = 0, .id = RETRO_DEVICE_ID_JOYPAD_LEFT, .description = "Left" },
|
||||
{ .port = 0, .device = RETRO_DEVICE_JOYPAD, .index = 0, .id = RETRO_DEVICE_ID_JOYPAD_UP, .description = "Up" },
|
||||
{ .port = 0, .device = RETRO_DEVICE_JOYPAD, .index = 0, .id = RETRO_DEVICE_ID_JOYPAD_DOWN, .description = "Down" },
|
||||
{ .port = 0, .device = RETRO_DEVICE_JOYPAD, .index = 0, .id = RETRO_DEVICE_ID_JOYPAD_RIGHT, .description = "Right" },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
|
||||
|
||||
(void)info;
|
||||
return true;
|
||||
}
|
||||
|
25
libretro.h
25
libretro.h
@ -357,6 +357,14 @@ enum retro_key
|
||||
// The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.
|
||||
// If the call returns false, the frontend does not support this pixel format.
|
||||
// This function should be called inside retro_load_game() or retro_get_system_av_info().
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11
|
||||
// const struct retro_input_descriptor * --
|
||||
// Sets an array of retro_input_descriptors.
|
||||
// It is up to the frontend to present this in a usable way.
|
||||
// The array is terminated by retro_input_descriptor::description being set to NULL.
|
||||
// This function can be called at any time, but it is recommended to call it as early as possible.
|
||||
|
||||
|
||||
enum retro_pixel_format
|
||||
{
|
||||
@ -370,8 +378,25 @@ struct retro_message
|
||||
unsigned frames; // Duration in frames of message.
|
||||
};
|
||||
|
||||
// Describes how the libretro implementation maps a libretro input bind
|
||||
// to its internal input system through a human readable string.
|
||||
// This string can be used to better let a user configure input.
|
||||
struct retro_input_descriptor
|
||||
{
|
||||
// Associates given parameters with a description.
|
||||
unsigned port;
|
||||
unsigned device;
|
||||
unsigned index;
|
||||
unsigned id;
|
||||
|
||||
const char *description; // Human readable description for parameters.
|
||||
// The pointer must remain valid until retro_unload_game() is called.
|
||||
};
|
||||
|
||||
struct retro_system_info
|
||||
{
|
||||
// All pointers are owned by libretro implementation, and pointers must remain valid until retro_deinit() is called.
|
||||
|
||||
const char *library_name; // Descriptive name of library. Should not contain any version numbers, etc.
|
||||
const char *library_version; // Descriptive version of core.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user