mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 11:18:25 +00:00
Add correct joypad name reporting to RGUI (for xi and di), also cleanup dinput name variables
This commit is contained in:
parent
bcb48caa16
commit
37ebdcdec7
@ -49,6 +49,7 @@ struct dinput_joypad
|
||||
{
|
||||
LPDIRECTINPUTDEVICE8 joypad;
|
||||
DIJOYSTATE2 joy_state;
|
||||
char* joy_name;
|
||||
};
|
||||
|
||||
static unsigned g_joypad_cnt;
|
||||
@ -350,9 +351,6 @@ const input_driver_t input_dinput = {
|
||||
// -1 = not xbox pad, otherwise 0..3
|
||||
int g_xbox_pad_indexes[MAX_PLAYERS];
|
||||
|
||||
// TODO: Move the name string to struct dinput_joypad
|
||||
static char *g_pad_names[MAX_PLAYERS];
|
||||
|
||||
static void dinput_joypad_destroy(void)
|
||||
{
|
||||
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||
@ -362,16 +360,17 @@ static void dinput_joypad_destroy(void)
|
||||
IDirectInputDevice8_Unacquire(g_pads[i].joypad);
|
||||
IDirectInputDevice8_Release(g_pads[i].joypad);
|
||||
}
|
||||
|
||||
if (g_pads[i].joy_name)
|
||||
{
|
||||
free(g_pads[i].joy_name);
|
||||
g_pads[i].joy_name = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
g_joypad_cnt = 0;
|
||||
memset(g_pads, 0, sizeof(g_pads));
|
||||
|
||||
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
free (g_pad_names[i]);
|
||||
g_pad_names[i] = NULL;
|
||||
}
|
||||
|
||||
// Can be blocked by global Dinput context.
|
||||
dinput_destroy_context();
|
||||
@ -443,8 +442,8 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
return DIENUM_CONTINUE;
|
||||
|
||||
size_t name_len = strlen(inst->tszProductName) + 1;
|
||||
g_pad_names[g_joypad_cnt] = (char*)malloc(name_len);
|
||||
strncpy(g_pad_names[g_joypad_cnt], inst->tszProductName, name_len);
|
||||
g_pads[g_joypad_cnt].joy_name = (char*)malloc(name_len);
|
||||
strncpy(g_pads[g_joypad_cnt].joy_name, inst->tszProductName, name_len);
|
||||
|
||||
#ifdef HAVE_WINXINPUT
|
||||
int last_xbox_pad_index = 0;
|
||||
@ -473,7 +472,7 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
if (1)
|
||||
#endif
|
||||
{
|
||||
|
||||
strlcpy(g_settings.input.device_names[g_joypad_cnt], dinput_joypad_name(g_joypad_cnt), sizeof(g_settings.input.device_names[g_joypad_cnt]));
|
||||
input_config_autoconfigure_joypad(g_joypad_cnt, dinput_joypad_name(g_joypad_cnt), dinput_joypad.ident);
|
||||
}
|
||||
|
||||
@ -488,9 +487,10 @@ static bool dinput_joypad_init(void)
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < MAX_PLAYERS; ++i)
|
||||
{
|
||||
g_xbox_pad_indexes[i] = -1;
|
||||
|
||||
memset(&g_pad_names, 0, sizeof(g_pad_names));
|
||||
g_pads[i].joy_name = NULL;
|
||||
}
|
||||
|
||||
RARCH_LOG("Enumerating DInput joypads ...\n");
|
||||
IDirectInput8_EnumDevices(g_ctx, DI8DEVCLASS_GAMECTRL,
|
||||
@ -633,8 +633,8 @@ static bool dinput_joypad_query_pad(unsigned pad)
|
||||
|
||||
static const char *dinput_joypad_name(unsigned pad)
|
||||
{
|
||||
if ((pad < MAX_PLAYERS) && (g_pad_names[pad]))
|
||||
return g_pad_names[pad];
|
||||
if (pad < MAX_PLAYERS)
|
||||
return g_pads[pad].joy_name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -208,8 +208,13 @@ static bool winxinput_joypad_init(void)
|
||||
return false;
|
||||
|
||||
for (unsigned autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||
{
|
||||
if (pad_index_to_xplayer_index(autoconf_pad) > -1)
|
||||
{
|
||||
strlcpy(g_settings.input.device_names[autoconf_pad], winxinput_joypad_name(autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||
input_config_autoconfigure_joypad(autoconf_pad, winxinput_joypad_name(autoconf_pad), winxinput_joypad.ident);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user