(dinput_joypad) Grab window pointer once
This commit is contained in:
parent
784904071a
commit
d85eb927c1
|
@ -55,6 +55,7 @@ struct dinput_joypad_data
|
|||
#define NUM_HATS 4
|
||||
#endif
|
||||
|
||||
static uintptr_t g_window_ptr;
|
||||
static struct dinput_joypad_data g_pads[MAX_USERS];
|
||||
static unsigned g_joypad_cnt;
|
||||
static unsigned g_last_xinput_pad_idx;
|
||||
|
@ -336,9 +337,6 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
|||
bool is_xinput_pad;
|
||||
#endif
|
||||
LPDIRECTINPUTDEVICE8 *pad = NULL;
|
||||
|
||||
(void)p;
|
||||
|
||||
if (g_joypad_cnt == MAX_USERS)
|
||||
return DIENUM_STOP;
|
||||
|
||||
|
@ -356,20 +354,21 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
|||
g_pads[g_joypad_cnt].joy_name = strdup((const char*)inst->tszProductName);
|
||||
g_pads[g_joypad_cnt].joy_friendly_name = strdup((const char*)inst->tszInstanceName);
|
||||
|
||||
/* there may be more useful info in the GUID so leave this here for a while */
|
||||
#if 0
|
||||
/* 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]);
|
||||
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]);
|
||||
#endif
|
||||
|
||||
g_pads[g_joypad_cnt].vid = inst->guidProduct.Data1 % 0x10000;
|
||||
|
@ -390,7 +389,7 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
|||
/* Set data format to simple joystick */
|
||||
IDirectInputDevice8_SetDataFormat(*pad, &c_dfDIJoystick2);
|
||||
IDirectInputDevice8_SetCooperativeLevel(*pad,
|
||||
(HWND)video_driver_window_get(),
|
||||
(HWND)g_window_ptr,
|
||||
DISCL_EXCLUSIVE | DISCL_BACKGROUND);
|
||||
|
||||
IDirectInputDevice8_EnumObjects(*pad, enum_axes_cb,
|
||||
|
@ -436,6 +435,7 @@ static bool dinput_joypad_init(void *data)
|
|||
g_pads[i].joy_friendly_name = NULL;
|
||||
}
|
||||
|
||||
g_window_ptr = video_driver_window_get();
|
||||
IDirectInput8_EnumDevices(g_dinput_ctx, DI8DEVCLASS_GAMECTRL,
|
||||
enum_joypad_cb, NULL, DIEDFL_ATTACHEDONLY);
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue