diff --git a/src/hidapi/SDL_hidapi_libusb.h b/src/hidapi/SDL_hidapi_libusb.h index ed8b4a35d7..ec0e5b265d 100644 --- a/src/hidapi/SDL_hidapi_libusb.h +++ b/src/hidapi/SDL_hidapi_libusb.h @@ -82,7 +82,6 @@ #define wcsncpy SDL_wcslcpy -#ifndef SDL_PLATFORM_FREEBSD /* this is awkwardly inlined, so we need to re-implement it here * so we can override the libusb_control_transfer call */ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, @@ -93,7 +92,23 @@ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, data, (uint16_t)length, 1000); /* Endpoint 0 IN */ } #define libusb_get_string_descriptor SDL_libusb_get_string_descriptor -#endif /* SDL_PLATFORM_FREEBSD */ + +/* this is inlined, except on FreeBSD, so we need to re-implement it here */ +static void SDL_libusb_fill_interrupt_transfer( + struct libusb_transfer *transfer, libusb_device_handle *dev_handle, + unsigned char endpoint, unsigned char *buffer, int length, + libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) +{ + transfer->dev_handle = dev_handle; + transfer->endpoint = endpoint; + transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT; + transfer->timeout = timeout; + transfer->buffer = buffer; + transfer->length = length; + transfer->user_data = user_data; + transfer->callback = callback; +} +#define libusb_fill_interrupt_transfer SDL_libusb_fill_interrupt_transfer #define HIDAPI_THREAD_MODEL_INCLUDE "hidapi_thread_sdl.h" #ifndef LIBUSB_API_VERSION diff --git a/src/hidapi/libusb/hid.c b/src/hidapi/libusb/hid.c index 71731a45ef..16bec68f18 100644 --- a/src/hidapi/libusb/hid.c +++ b/src/hidapi/libusb/hid.c @@ -288,7 +288,7 @@ static int get_usage(uint8_t *report_descriptor, size_t size, return -1; /* failure */ } -#if defined(__FreeBSD__) && __FreeBSD__ < 10 +#if defined(__FreeBSD__) && __FreeBSD__ < 10 && !defined(libusb_get_string_descriptor) /* The libusb version included in FreeBSD < 10 doesn't have this function. In mainline libusb, it's inlined in libusb.h. This function will bear a striking resemblance to that one, because there's about one way to code it.