mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 16:39:43 +00:00
Merge pull request #1934 from fr500/master
Add VID/PID to the joypad struct
This commit is contained in:
commit
b91f310b60
@ -35,6 +35,9 @@ struct dinput_joypad
|
||||
LPDIRECTINPUTDEVICE8 joypad;
|
||||
DIJOYSTATE2 joy_state;
|
||||
char* joy_name;
|
||||
char* joy_friendly_name;
|
||||
int32_t vid;
|
||||
int32_t pid;
|
||||
};
|
||||
|
||||
static struct dinput_joypad g_pads[MAX_USERS];
|
||||
@ -70,6 +73,8 @@ static void dinput_joypad_destroy(void)
|
||||
|
||||
free(g_pads[i].joy_name);
|
||||
g_pads[i].joy_name = NULL;
|
||||
free(g_pads[i].joy_friendly_name);
|
||||
g_pads[i].joy_friendly_name = NULL;
|
||||
*settings->input.device_names[i] = '\0';
|
||||
}
|
||||
|
||||
@ -158,7 +163,7 @@ static bool guid_is_xinput_device(const GUID* product_guid)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(raw_devs);
|
||||
raw_devs = NULL;
|
||||
return false;
|
||||
@ -172,6 +177,14 @@ static const char *dinput_joypad_name(unsigned pad)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *dinput_joypad_friendly_name(unsigned pad)
|
||||
{
|
||||
if (pad < MAX_USERS)
|
||||
return g_pads[pad].joy_friendly_name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
{
|
||||
bool is_xinput_pad;
|
||||
@ -194,17 +207,31 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
g_dinput_ctx, &inst->guidInstance, pad, NULL)))
|
||||
#endif
|
||||
return DIENUM_CONTINUE;
|
||||
|
||||
|
||||
g_pads[g_joypad_cnt].joy_name = strdup(inst->tszProductName);
|
||||
|
||||
g_pads[g_joypad_cnt].joy_friendly_name = strdup(inst->tszInstanceName);
|
||||
|
||||
/* there may be more useful info in the GUID so leave this here for a while
|
||||
|
||||
printf("Guid = {%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}\n",
|
||||
inst->guidProduct.Data1, inst->guidProduct.Data2, inst->guidProduct.Data3,
|
||||
inst->guidProduct.Data4[0], inst->guidProduct.Data4[1], inst->guidProduct.Data4[2], inst->guidProduct.Data4[3],
|
||||
inst->guidProduct.Data4[4], inst->guidProduct.Data4[5], inst->guidProduct.Data4[6], inst->guidProduct.Data4[7]);
|
||||
*/
|
||||
|
||||
g_pads[g_joypad_cnt].vid = inst->guidProduct.Data1/0x10000;
|
||||
g_pads[g_joypad_cnt].pid = inst->guidProduct.Data1%0x10000;
|
||||
RARCH_LOG("PID: {%04lX} VID:{%04lX}\n", g_pads[g_joypad_cnt].pid, g_pads[g_joypad_cnt].vid);
|
||||
|
||||
|
||||
#ifdef HAVE_XINPUT
|
||||
#if 0
|
||||
is_xinput_pad = g_xinput_block_pads
|
||||
is_xinput_pad = g_xinput_block_pads
|
||||
&& name_is_xinput_pad(inst->tszProductName);
|
||||
#endif
|
||||
is_xinput_pad = g_xinput_block_pads
|
||||
is_xinput_pad = g_xinput_block_pads
|
||||
&& guid_is_xinput_device(&inst->guidProduct);
|
||||
|
||||
|
||||
if (is_xinput_pad)
|
||||
{
|
||||
if (g_last_xinput_pad_idx < 4)
|
||||
@ -217,9 +244,9 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
IDirectInputDevice8_SetCooperativeLevel(*pad, (HWND)driver->video_window,
|
||||
DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
|
||||
|
||||
IDirectInputDevice8_EnumObjects(*pad, enum_axes_cb,
|
||||
IDirectInputDevice8_EnumObjects(*pad, enum_axes_cb,
|
||||
*pad, DIDFT_ABSAXIS);
|
||||
|
||||
|
||||
#ifdef HAVE_XINPUT
|
||||
if (!is_xinput_pad)
|
||||
#endif
|
||||
@ -233,13 +260,15 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = g_joypad_cnt;
|
||||
strlcpy(params.name, dinput_joypad_name(g_joypad_cnt), sizeof(params.name));
|
||||
strlcpy(params.display_name, dinput_joypad_friendly_name(g_joypad_cnt), sizeof(params.driver));
|
||||
strlcpy(params.driver, dinput_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
RARCH_LOG("DINPUT %s %s %s\n",params.name, params.driver, params.display_name);
|
||||
}
|
||||
|
||||
enum_iteration_done:
|
||||
g_joypad_cnt++;
|
||||
return DIENUM_CONTINUE;
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
static bool dinput_joypad_init(void *data)
|
||||
@ -250,13 +279,14 @@ static bool dinput_joypad_init(void *data)
|
||||
|
||||
if (!dinput_init_context())
|
||||
return false;
|
||||
|
||||
|
||||
g_last_xinput_pad_idx = 0;
|
||||
|
||||
|
||||
for (i = 0; i < MAX_USERS; ++i)
|
||||
{
|
||||
g_xinput_pad_indexes[i] = -1;
|
||||
g_pads[i].joy_name = NULL;
|
||||
g_pads[i].joy_friendly_name = NULL;
|
||||
}
|
||||
|
||||
RARCH_LOG("Enumerating DInput joypads ...\n");
|
||||
@ -282,7 +312,7 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
unsigned pov;
|
||||
unsigned hat = GET_HAT(joykey);
|
||||
unsigned elems = sizeof(pad->joy_state.rgdwPOV) /
|
||||
unsigned elems = sizeof(pad->joy_state.rgdwPOV) /
|
||||
sizeof(pad->joy_state.rgdwPOV[0]);
|
||||
|
||||
if (hat >= elems)
|
||||
@ -310,7 +340,7 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned elems = sizeof(pad->joy_state.rgbButtons) /
|
||||
unsigned elems = sizeof(pad->joy_state.rgbButtons) /
|
||||
sizeof(pad->joy_state.rgbButtons[0]);
|
||||
|
||||
if (joykey < elems)
|
||||
|
@ -24,6 +24,7 @@ typedef struct autoconfig_params
|
||||
{
|
||||
char name[PATH_MAX_LENGTH];
|
||||
char driver[PATH_MAX_LENGTH];
|
||||
char display_name[PATH_MAX_LENGTH];
|
||||
unsigned idx;
|
||||
int32_t vid;
|
||||
int32_t pid;
|
||||
|
Loading…
Reference in New Issue
Block a user