SDL_hidapi_windows.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 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. /* #pragma push_macro/pop_macro works correctly only as of gcc >= 4.4.3
  20. clang-3.0 _seems_ to be OK. */
  21. #pragma push_macro("calloc")
  22. #pragma push_macro("free")
  23. #pragma push_macro("malloc")
  24. #pragma push_macro("memcmp")
  25. #pragma push_macro("swprintf")
  26. #pragma push_macro("towupper")
  27. #pragma push_macro("wcscmp")
  28. #pragma push_macro("_wcsdup")
  29. #pragma push_macro("wcslen")
  30. #pragma push_macro("wcsncpy")
  31. #pragma push_macro("wcsstr")
  32. #pragma push_macro("wcstol")
  33. #undef calloc
  34. #undef free
  35. #undef malloc
  36. #undef memcmp
  37. #undef swprintf
  38. #undef towupper
  39. #undef wcscmp
  40. #undef _wcsdup
  41. #undef wcslen
  42. #undef wcsncpy
  43. #undef wcsstr
  44. #undef wcstol
  45. #define calloc SDL_calloc
  46. #define free SDL_free
  47. #define malloc SDL_malloc
  48. #define memcmp SDL_memcmp
  49. #define swprintf SDL_swprintf
  50. #define towupper (wchar_t)SDL_toupper
  51. #define wcscmp SDL_wcscmp
  52. #define _wcsdup SDL_wcsdup
  53. #define wcslen SDL_wcslen
  54. #define wcsncpy SDL_wcslcpy
  55. #define wcsstr SDL_wcsstr
  56. #define wcstol SDL_wcstol
  57. // These functions conflict when linking both SDL and hidapi statically
  58. #define hid_winapi_descriptor_reconstruct_pp_data SDL_hid_winapi_descriptor_reconstruct_pp_data
  59. #define hid_winapi_get_container_id SDL_hid_winapi_get_container_id
  60. #undef HIDAPI_H__
  61. #include "windows/hid.c"
  62. #define HAVE_PLATFORM_BACKEND 1
  63. #define udev_ctx 1
  64. /* restore libc function macros */
  65. #pragma pop_macro("calloc")
  66. #pragma pop_macro("free")
  67. #pragma pop_macro("malloc")
  68. #pragma pop_macro("memcmp")
  69. #pragma pop_macro("swprintf")
  70. #pragma pop_macro("towupper")
  71. #pragma pop_macro("wcscmp")
  72. #pragma pop_macro("_wcsdup")
  73. #pragma pop_macro("wcslen")
  74. #pragma pop_macro("wcsncpy")
  75. #pragma pop_macro("wcsstr")
  76. #pragma pop_macro("wcstol")