SDL_hidapi_libusb.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* Define standard library functions in terms of SDL */
  19. #define free SDL_free
  20. #define iconv_t SDL_iconv_t
  21. #define ICONV_CONST
  22. #define iconv(a,b,c,d,e) SDL_iconv(a, (const char **)b, c, d, e)
  23. #define iconv_open SDL_iconv_open
  24. #define iconv_close SDL_iconv_close
  25. #define malloc SDL_malloc
  26. #define realloc SDL_realloc
  27. #define setlocale(X, Y) NULL
  28. #define snprintf SDL_snprintf
  29. #define strcmp SDL_strcmp
  30. #define strdup SDL_strdup
  31. #define strncpy SDL_strlcpy
  32. #ifdef tolower
  33. #undef tolower
  34. #endif
  35. #define tolower SDL_tolower
  36. #define wcsdup SDL_wcsdup
  37. #ifndef __FreeBSD__
  38. /* this is awkwardly inlined, so we need to re-implement it here
  39. * so we can override the libusb_control_transfer call */
  40. static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev,
  41. uint8_t descriptor_index, uint16_t lang_id,
  42. unsigned char *data, int length)
  43. {
  44. return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN | 0x0, LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | descriptor_index, lang_id,
  45. data, (uint16_t)length, 1000); /* Endpoint 0 IN */
  46. }
  47. #define libusb_get_string_descriptor SDL_libusb_get_string_descriptor
  48. #endif /* __FreeBSD__ */
  49. #define HIDAPI_THREAD_MODEL_INCLUDE "hidapi_thread_sdl.h"
  50. #undef HIDAPI_H__
  51. #include "libusb/hid.c"