Fixed building with libusb on FreeBSD

This commit is contained in:
Sam Lantinga
2025-10-24 10:29:39 -07:00
parent 5c56cf110b
commit 404ec13fbb
2 changed files with 18 additions and 3 deletions

View File

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

View File

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