diff --git a/src/win32_init.c b/src/win32_init.c index 5acae4c2..59e6245c 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -186,6 +186,8 @@ static GLFWbool loadLibraries(void) { _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities) _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities"); + _glfw.win32.xinput.GetCapabilitiesEx = (PFN_XInputGetCapabilitiesEx) + _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, (char *)108); _glfw.win32.xinput.GetState = (PFN_XInputGetState) _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState"); diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 4e83577a..09908f1a 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -534,6 +534,14 @@ void _glfwDetectJoystickConnectionWin32(void) js->win32.index = index; + XINPUT_CAPABILITIES_EX ex; + if (XInputGetCapabilitiesEx(1, index, 0, &ex) == ERROR_SUCCESS) + { + js->usbInfo.product = ex.productId; + js->usbInfo.vendor = ex.vendorId; + js->usbInfo.version = ex.revisionId; + } + _glfwInputJoystick(js, GLFW_CONNECTED); } } diff --git a/src/win32_platform.h b/src/win32_platform.h index c3822c3a..2493250e 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -524,10 +524,22 @@ typedef enum #define ERROR_INVALID_PROFILE_ARB 0x2096 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +typedef struct XINPUT_CAPABILITIES_EX_S +{ + XINPUT_CAPABILITIES Capabilities; + WORD vendorId; + WORD productId; + WORD revisionId; + DWORD a4; //unknown +} XINPUT_CAPABILITIES_EX, *XINPUT_CAPABILITIES_EX_p; + // xinput.dll function pointer typedefs -typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*); +typedef DWORD(WINAPI *PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES *); +typedef DWORD(WINAPI *PFN_XInputGetCapabilitiesEx)(DWORD, DWORD, DWORD, XINPUT_CAPABILITIES_EX_p); + typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*); #define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities +#define XInputGetCapabilitiesEx _glfw.win32.xinput.GetCapabilitiesEx #define XInputGetState _glfw.win32.xinput.GetState // dinput8.dll function pointer typedefs @@ -750,6 +762,7 @@ typedef struct _GLFWlibraryWin32 struct { HINSTANCE instance; PFN_XInputGetCapabilities GetCapabilities; + PFN_XInputGetCapabilitiesEx GetCapabilitiesEx; PFN_XInputGetState GetState; } xinput;