fix_mingw.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From 6a83588fdda0f70465ecd8b0231e753f434abeb1 Mon Sep 17 00:00:00 2001
  2. From: Sam Lantinga <[email protected]>
  3. Date: Fri, 9 Feb 2024 01:26:45 -0800
  4. Subject: [PATCH] Redefine XINPUT_CAPABILITIES_EX as an SDL typedef
  5. mingw-w64 has added this from Proton (which added this from SDL), so we need to re-define it as a local symbol to avoid conflicting with mingw-w64 headers.
  6. Fixes https://github.com/libsdl-org/SDL/issues/9031
  7. (cherry picked from commit b7c61569f899982338bff0d5b9d35bd6d83485d3)
  8. (cherry picked from commit 93d7b6e50c3f625a86c2443deffc334cf0eda832)
  9. ---
  10. src/core/windows/SDL_xinput.h | 6 +++---
  11. src/joystick/windows/SDL_xinputjoystick.c | 4 ++--
  12. 2 files changed, 5 insertions(+), 5 deletions(-)
  13. diff --git a/src/core/windows/SDL_xinput.h b/src/core/windows/SDL_xinput.h
  14. index 396afcde7dd01..efdb86282e10c 100644
  15. --- a/src/core/windows/SDL_xinput.h
  16. +++ b/src/core/windows/SDL_xinput.h
  17. @@ -212,7 +212,7 @@ typedef struct
  18. #endif /* HAVE_XINPUT_H */
  19. /* This struct is not defined in XInput headers. */
  20. -typedef struct _XINPUT_CAPABILITIES_EX
  21. +typedef struct
  22. {
  23. XINPUT_CAPABILITIES Capabilities;
  24. WORD VendorId;
  25. @@ -220,7 +220,7 @@ typedef struct _XINPUT_CAPABILITIES_EX
  26. WORD ProductVersion;
  27. WORD unk1;
  28. DWORD unk2;
  29. -} XINPUT_CAPABILITIES_EX, *PXINPUT_CAPABILITIES_EX;
  30. +} SDL_XINPUT_CAPABILITIES_EX;
  31. /* Forward decl's for XInput API's we load dynamically and use if available */
  32. typedef DWORD(WINAPI *XInputGetState_t)(
  33. @@ -244,7 +244,7 @@ typedef DWORD(WINAPI *XInputGetCapabilitiesEx_t)(
  34. DWORD dwReserved, /* [in] Must be 1 */
  35. DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
  36. DWORD dwFlags, /* [in] Input flags that identify the device type */
  37. - XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */
  38. + SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */
  39. );
  40. typedef DWORD(WINAPI *XInputGetBatteryInformation_t)(
  41. diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
  42. index 3a2e912ca381b..1ae7fb489957e 100644
  43. --- a/src/joystick/windows/SDL_xinputjoystick.c
  44. +++ b/src/joystick/windows/SDL_xinputjoystick.c
  45. @@ -117,7 +117,7 @@ static const char *GetXInputName(const Uint8 userid, BYTE SubType)
  46. static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
  47. {
  48. - XINPUT_CAPABILITIES_EX capabilities;
  49. + SDL_XINPUT_CAPABILITIES_EX capabilities;
  50. if (!XINPUTGETCAPABILITIESEX || XINPUTGETCAPABILITIESEX(1, userid, 0, &capabilities) != ERROR_SUCCESS) {
  51. return SDL_FALSE;
  52. @@ -143,7 +143,7 @@ static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Ui
  53. int SDL_XINPUT_GetSteamVirtualGamepadSlot(Uint8 userid)
  54. {
  55. - XINPUT_CAPABILITIES_EX capabilities;
  56. + SDL_XINPUT_CAPABILITIES_EX capabilities;
  57. if (XINPUTGETCAPABILITIESEX &&
  58. XINPUTGETCAPABILITIESEX(1, userid, 0, &capabilities) == ERROR_SUCCESS &&