hidapi build fixes for the upstream build environment

This commit is contained in:
Sam Lantinga 2023-05-26 21:28:01 -07:00
parent 2b386b6c80
commit 1c9aae9a29
2 changed files with 15 additions and 18 deletions

View File

@ -148,7 +148,7 @@ static int pthread_barrier_wait(pthread_barrier_t *barrier)
#define THREAD_STATE_WAIT_TIMED_OUT ETIMEDOUT
typdef struct
typedef struct
{
pthread_t thread;
pthread_mutex_t mutex; /* Protects input_reports */
@ -171,15 +171,8 @@ static void thread_state_free(hid_device_thread_state *state)
pthread_mutex_destroy(&state->mutex);
}
static void thread_state_push_cleanup(void (*routine)(void *), void *arg)
{
pthread_cleanup_push(&cleanup_mutex, dev);
}
static void thread_state_pop_cleanup(int execute)
{
pthread_cleanup_pop(execute);
}
#define thread_state_push_cleanup pthread_cleanup_push
#define thread_state_pop_cleanup pthread_cleanup_pop
static void thread_state_lock(hid_device_thread_state *state)
{
@ -218,7 +211,7 @@ static void thread_state_wait_barrier(hid_device_thread_state *state)
static void thread_state_create_thread(hid_device_thread_state *state, void *(*func)(void*), void *func_arg)
{
pthread_create(&dev->thread, NULL, func, param);
pthread_create(&state->thread, NULL, func, func_arg);
}
static void thread_state_join_thread(hid_device_thread_state *state)
@ -983,14 +976,14 @@ static int is_xbox360(unsigned short vendor_id, const struct libusb_interface_de
0x24c6, /* PowerA */
0x2c22, /* Qanba */
0x2dc8, /* 8BitDo */
0x9886, /* ASTRO Gaming */
0x9886, /* ASTRO Gaming */
};
if (intf_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC &&
intf_desc->bInterfaceSubClass == XB360_IFACE_SUBCLASS &&
(intf_desc->bInterfaceProtocol == XB360_IFACE_PROTOCOL ||
intf_desc->bInterfaceProtocol == XB360W_IFACE_PROTOCOL)) {
int i;
size_t i;
for (i = 0; i < sizeof(SUPPORTED_VENDORS)/sizeof(SUPPORTED_VENDORS[0]); ++i) {
if (vendor_id == SUPPORTED_VENDORS[i]) {
return 1;
@ -1010,20 +1003,20 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de
0x0738, /* Mad Catz */
0x0e6f, /* PDP */
0x0f0d, /* Hori */
0x10f5, /* Turtle Beach */
0x10f5, /* Turtle Beach */
0x1532, /* Razer Wildcat */
0x20d6, /* PowerA */
0x24c6, /* PowerA */
0x2dc8, /* 8BitDo */
0x2e24, /* Hyperkin */
0x3537, /* GameSir */
0x3537, /* GameSir */
};
if (intf_desc->bInterfaceNumber == 0 &&
intf_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC &&
intf_desc->bInterfaceSubClass == XB1_IFACE_SUBCLASS &&
intf_desc->bInterfaceProtocol == XB1_IFACE_PROTOCOL) {
int i;
size_t i;
for (i = 0; i < sizeof(SUPPORTED_VENDORS)/sizeof(SUPPORTED_VENDORS[0]); ++i) {
if (vendor_id == SUPPORTED_VENDORS[i]) {
return 1;
@ -1367,6 +1360,8 @@ static void *read_thread(void *param)
static void init_xbox360(libusb_device_handle *device_handle, unsigned short idVendor, unsigned short idProduct, const struct libusb_config_descriptor *conf_desc)
{
(void)conf_desc;
if ((idVendor == 0x05ac && idProduct == 0x055b) /* Gamesir-G3w */ ||
idVendor == 0x0f0d /* Hori Xbox controllers */) {
unsigned char data[20];
@ -1386,6 +1381,8 @@ static void init_xboxone(libusb_device_handle *device_handle, unsigned short idV
static const int XB1_IFACE_PROTOCOL = 208;
int j, k, res;
(void)idProduct;
for (j = 0; j < conf_desc->bNumInterfaces; j++) {
const struct libusb_interface *intf = &conf_desc->interface[j];
for (k = 0; k < intf->num_altsetting; k++) {

View File

@ -1207,7 +1207,7 @@ int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char
if (overlapped) {
/* See if there is any data yet. */
res = WaitForSingleObject(ev, milliseconds >= 0 ? milliseconds : INFINITE);
res = WaitForSingleObject(ev, milliseconds >= 0 ? (DWORD)milliseconds : INFINITE);
if (res != WAIT_OBJECT_0) {
/* There was no data this time. Return zero bytes available,
but leave the Overlapped I/O running. */
@ -1365,7 +1365,7 @@ int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned c
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev)
{
typedef BOOL (WINAPI *CancelIoEx_t)(HANDLE hFile, LPOVERLAPPED lpOverlapped);
CancelIoEx_t CancelIoExFunc = (CancelIoEx_t)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "CancelIoEx");
CancelIoEx_t CancelIoExFunc = (CancelIoEx_t)(void *)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "CancelIoEx");
if (!dev)
return;