Browse Source

Workaround struct redefinition on some newer MinGW header files.
Fix #1899.

Yao Wei Tjong 姚伟忠 8 years ago
parent
commit
d53928310c

+ 8 - 0
Source/ThirdParty/SDL/CMakeLists.txt

@@ -1111,6 +1111,14 @@ elseif(WINDOWS)
   if(DIRECTX)
   if(DIRECTX)
     # Urho3D - bug fix - use our own FindDirectX.cmake module which does not rely on DXSDK_DIR environment variable directly when DirectX SDK is being used
     # Urho3D - bug fix - use our own FindDirectX.cmake module which does not rely on DXSDK_DIR environment variable directly when DirectX SDK is being used
     # Urho3D - TODO - move the find_package(DirectX) call from Urho3D common module to here later after we have refactored the library dependency handling
     # Urho3D - TODO - move the find_package(DirectX) call from Urho3D common module to here later after we have refactored the library dependency handling
+
+    check_struct_has_member (XINPUT_GAMEPAD_EX wButtons xinput.h HAVE_XINPUT_GAMEPAD_EX)
+    check_struct_has_member (XINPUT_STATE_EX dwPacketNumber xinput.h HAVE_XINPUT_STATE_EX)
+    foreach (VAR HAVE_XINPUT_GAMEPAD_EX HAVE_XINPUT_STATE_EX)
+      if (${VAR})
+        add_definitions (-D${VAR})
+      endif ()
+    endforeach ()
   endif()
   endif()
 
 
   if(SDL_AUDIO)
   if(SDL_AUDIO)

+ 8 - 1
Source/ThirdParty/SDL/src/core/windows/SDL_xinput.h

@@ -18,6 +18,9 @@
      misrepresented as being the original software.
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
   3. This notice may not be removed or altered from any source distribution.
 */
 */
+
+// Modified by Yao Wei Tjong for Urho3D
+
 #include "../../SDL_internal.h"
 #include "../../SDL_internal.h"
 
 
 #ifndef _SDL_xinput_h
 #ifndef _SDL_xinput_h
@@ -100,6 +103,8 @@
 #endif
 #endif
 
 
 /* typedef's for XInput structs we use */
 /* typedef's for XInput structs we use */
+// Urho3D - declara only when built-in xinput.h hasn't declared it
+#ifndef HAVE_XINPUT_GAMEPAD_EX
 typedef struct
 typedef struct
 {
 {
     WORD wButtons;
     WORD wButtons;
@@ -111,12 +116,14 @@ typedef struct
     SHORT sThumbRY;
     SHORT sThumbRY;
     DWORD dwPaddingReserved;
     DWORD dwPaddingReserved;
 } XINPUT_GAMEPAD_EX;
 } XINPUT_GAMEPAD_EX;
-
+#endif
+#ifndef HAVE_XINPUT_STATE_EX
 typedef struct
 typedef struct
 {
 {
     DWORD dwPacketNumber;
     DWORD dwPacketNumber;
     XINPUT_GAMEPAD_EX Gamepad;
     XINPUT_GAMEPAD_EX Gamepad;
 } XINPUT_STATE_EX;
 } XINPUT_STATE_EX;
+#endif
 
 
 typedef struct
 typedef struct
 {
 {