[+] Win32 USB product id reporting

This commit is contained in:
Reece Wilson 2023-11-04 23:58:36 +00:00
parent e4edc29fb3
commit 6b2a2675ee
3 changed files with 24 additions and 1 deletions

View File

@ -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");

View File

@ -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);
}
}

View File

@ -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;