mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
hidapi/windows: fix build using older toolchains.
This commit is contained in:
@@ -154,6 +154,10 @@ static void free_library_handles()
|
||||
cfgmgr32_lib_handle = NULL;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
static int lookup_functions()
|
||||
{
|
||||
hid_lib_handle = LoadLibraryW(L"hid.dll");
|
||||
@@ -166,10 +170,6 @@ static int lookup_functions()
|
||||
goto err;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
#define RESOLVE(lib_handle, x) x = (x##_)GetProcAddress(lib_handle, #x); if (!x) goto err;
|
||||
|
||||
RESOLVE(hid_lib_handle, HidD_GetHidGuid);
|
||||
@@ -195,9 +195,6 @@ static int lookup_functions()
|
||||
RESOLVE(cfgmgr32_lib_handle, CM_Get_Device_Interface_ListW);
|
||||
|
||||
#undef RESOLVE
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -205,6 +202,9 @@ err:
|
||||
free_library_handles();
|
||||
return -1;
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* HIDAPI_USE_DDK */
|
||||
|
||||
@@ -570,6 +570,7 @@ static wchar_t *hid_internal_UTF8toUTF16(const char *src)
|
||||
static int hid_get_bluetooth_info(const char *path, struct hid_device_info* dev)
|
||||
{
|
||||
wchar_t *interface_path = NULL, *device_id = NULL, *compatible_ids = NULL;
|
||||
wchar_t *compatible_id;
|
||||
CONFIGRET cr;
|
||||
DEVINST dev_node;
|
||||
int is_bluetooth = 0;
|
||||
@@ -596,9 +597,10 @@ static int hid_get_bluetooth_info(const char *path, struct hid_device_info* dev)
|
||||
goto end;
|
||||
|
||||
/* Now we can parse parent's compatible IDs to find out the device bus type */
|
||||
for (wchar_t* compatible_id = compatible_ids; *compatible_id; compatible_id += wcslen(compatible_id) + 1) {
|
||||
for (compatible_id = compatible_ids; *compatible_id; compatible_id += wcslen(compatible_id) + 1) {
|
||||
/* Normalize to upper case */
|
||||
for (wchar_t* p = compatible_id; *p; ++p) *p = towupper(*p);
|
||||
wchar_t* p = compatible_id;
|
||||
for (; *p; ++p) *p = towupper(*p);
|
||||
|
||||
/* USB devices
|
||||
https://docs.microsoft.com/windows-hardware/drivers/hid/plug-and-play-support
|
||||
|
@@ -59,7 +59,7 @@ typedef CONFIGRET(__stdcall* CM_Get_Parent_)(PDEVINST pdnDevInst, DEVINST dnDevI
|
||||
typedef CONFIGRET(__stdcall* CM_Get_DevNode_PropertyW_)(DEVINST dnDevInst, CONST DEVPROPKEY* PropertyKey, DEVPROPTYPE* PropertyType, PBYTE PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags);
|
||||
typedef CONFIGRET(__stdcall* CM_Get_Device_Interface_PropertyW_)(LPCWSTR pszDeviceInterface, CONST DEVPROPKEY* PropertyKey, DEVPROPTYPE* PropertyType, PBYTE PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags);
|
||||
typedef CONFIGRET(__stdcall* CM_Get_Device_Interface_List_SizeW_)(PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags);
|
||||
typedef CONFIGRET(__stdcall* CM_Get_Device_Interface_ListW_)(LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR Buffer, ULONG BufferLen, ULONG ulFlags);
|
||||
typedef CONFIGRET(__stdcall* CM_Get_Device_Interface_ListW_)(LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, WCHAR* Buffer, ULONG BufferLen, ULONG ulFlags);
|
||||
|
||||
// from devpkey.h
|
||||
static DEVPROPKEY DEVPKEY_NAME = { { 0xb725f130, 0x47ef, 0x101a, {0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac} }, 10 }; // DEVPROP_TYPE_STRING
|
||||
|
@@ -40,8 +40,6 @@ typedef struct _HIDD_ATTRIBUTES{
|
||||
USHORT VersionNumber;
|
||||
} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
|
||||
|
||||
typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;
|
||||
|
||||
typedef void (__stdcall *HidD_GetHidGuid_)(LPGUID hid_guid);
|
||||
typedef BOOLEAN (__stdcall *HidD_GetAttributes_)(HANDLE device, PHIDD_ATTRIBUTES attrib);
|
||||
typedef BOOLEAN (__stdcall *HidD_GetSerialNumberString_)(HANDLE device, PVOID buffer, ULONG buffer_len);
|
||||
@@ -56,7 +54,6 @@ typedef BOOLEAN (__stdcall *HidD_FreePreparsedData_)(PHIDP_PREPARSED_DATA prepar
|
||||
typedef BOOLEAN (__stdcall *HidD_SetNumInputBuffers_)(HANDLE handle, ULONG number_buffers);
|
||||
typedef BOOLEAN (__stdcall *HidD_SetOutputReport_)(HANDLE handle, PVOID buffer, ULONG buffer_len);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* HIDAPI_HIDSDI_H */
|
||||
|
Reference in New Issue
Block a user