Commit 1ee96bb994ca0d92f0157f1b9d904224240ec17a

Sam Lantinga 2014-07-07T10:26:28

Fixed mingw64 build and warnings

diff --git a/configure b/configure
index a598f36..533591a 100755
--- a/configure
+++ b/configure
@@ -23067,7 +23067,7 @@ $as_echo "#define SDL_HAPTIC_XINPUT 1" >>confdefs.h
 $as_echo "#define SDL_HAPTIC_DINPUT 1" >>confdefs.h
 
                 fi
-                SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
+                SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c"
                 have_haptic=yes
             fi
         fi
diff --git a/configure.in b/configure.in
index 42aec1d..80e88e7 100644
--- a/configure.in
+++ b/configure.in
@@ -2982,7 +2982,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
                 if test x$have_dinput = xyes; then
                     AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
                 fi
-                SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
+                SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c"
                 have_haptic=yes
             fi
         fi
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 8316c6f..794b3ac 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -345,7 +345,7 @@ IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
     /* Check to make sure we have enough variables in the state array */
     channels = IMA_ADPCM_state.wavefmt.channels;
     if (channels > SDL_arraysize(IMA_ADPCM_state.state)) {
-        SDL_SetError("IMA ADPCM decoder can only handle %zu channels",
+        SDL_SetError("IMA ADPCM decoder can only handle %u channels",
                      SDL_arraysize(IMA_ADPCM_state.state));
         return (-1);
     }
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index a3ee3a2..f313e7f 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -204,7 +204,6 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
     int posted;
     int xrel;
     int yrel;
-    int x_max = 0, y_max = 0;
 
     if (mouse->relative_mode_warp) {
         int center_x = 0, center_y = 0;
diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h
index b2918be..c808adc 100644
--- a/src/haptic/SDL_syshaptic.h
+++ b/src/haptic/SDL_syshaptic.h
@@ -21,6 +21,9 @@
 
 #include "../SDL_internal.h"
 
+#ifndef _SDL_syshaptic_h
+#define _SDL_syshaptic_h
+
 #include "SDL_haptic.h"
 
 
@@ -206,5 +209,7 @@ extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic);
  */
 extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic);
 
+#endif /* _SDL_syshaptic_h */
+
 /* vi: set ts=4 sw=4 expandtab: */
 
diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c
index e96fe1b..489ca5e 100644
--- a/src/haptic/windows/SDL_dinputhaptic.c
+++ b/src/haptic/windows/SDL_dinputhaptic.c
@@ -105,7 +105,7 @@ SDL_DINPUT_HapticInit(void)
     instance = GetModuleHandle(NULL);
     if (instance == NULL) {
         SDL_SYS_HapticQuit();
-        return SDL_SetError("GetModuleHandle() failed with error code %d.",
+        return SDL_SetError("GetModuleHandle() failed with error code %lu.",
             GetLastError());
     }
     ret = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION);
diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h
index a978c24..e715339 100644
--- a/src/haptic/windows/SDL_windowshaptic_c.h
+++ b/src/haptic/windows/SDL_windowshaptic_c.h
@@ -24,7 +24,7 @@
 #define _SDL_windowshaptic_c_h
 
 #include "SDL_thread.h"
-
+#include "../SDL_syshaptic.h"
 #include "../../core/windows/SDL_directx.h"
 #include "../../core/windows/SDL_xinput.h"
 
diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c
index d53acdf..c60f391 100644
--- a/src/joystick/SDL_gamecontroller.c
+++ b/src/joystick/SDL_gamecontroller.c
@@ -258,10 +258,12 @@ ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *gu
  */
 ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
 {
+#if SDL_JOYSTICK_XINPUT
     if (SDL_SYS_IsXInputGamepad_DeviceIndex(device_index) && s_pXInputMapping) {
         return s_pXInputMapping;
     }
     else
+#endif /* SDL_JOYSTICK_XINPUT */
     {
         SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
         return SDL_PrivateGetControllerMappingForGUID(&jGUID);
diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c
index c5816e9..179f992 100644
--- a/src/joystick/windows/SDL_dinputjoystick.c
+++ b/src/joystick/windows/SDL_dinputjoystick.c
@@ -231,7 +231,7 @@ SetDIerror(const char *function, HRESULT code)
     return SDL_SetError("%s() [%s]: %s", function,
     DXGetErrorString9A(code), DXGetErrorDescription9A(code));
     */
-    return SDL_SetError("%s() DirectX error %d", function, code);
+    return SDL_SetError("%s() DirectX error 0x%8.8lx", function, code);
 }
 
 static SDL_bool
@@ -324,7 +324,7 @@ SDL_DINPUT_JoystickInit(void)
     /* Because we used CoCreateInstance, we need to Initialize it, first. */
     instance = GetModuleHandle(NULL);
     if (instance == NULL) {
-        return SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError());
+        return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError());
     }
     result = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION);
 
diff --git a/src/joystick/windows/SDL_windowsjoystick_c.h b/src/joystick/windows/SDL_windowsjoystick_c.h
index 703b0cc..9b09e65 100644
--- a/src/joystick/windows/SDL_windowsjoystick_c.h
+++ b/src/joystick/windows/SDL_windowsjoystick_c.h
@@ -21,7 +21,6 @@
 #include "../../SDL_internal.h"
 
 #include "SDL_events.h"
-#include "SDL_joystick.h"
 #include "../SDL_sysjoystick.h"
 #include "../../core/windows/SDL_windows.h"
 #include "../../core/windows/SDL_directx.h"
diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
index 4a625a5..2d507e7 100644
--- a/src/joystick/windows/SDL_xinputjoystick.c
+++ b/src/joystick/windows/SDL_xinputjoystick.c
@@ -234,7 +234,6 @@ UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputS
     };
     WORD wButtons = pXInputState->Gamepad.wButtons;
     Uint8 button;
-    Uint8 hat = SDL_HAT_CENTERED;
 
     SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX);
     SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY)));
@@ -379,12 +378,6 @@ SDL_XINPUT_JoystickQuit(void)
 {
 }
 
-SDL_bool
-SDL_SYS_IsXInputGamepad_DeviceIndex(int device_index)
-{
-    return SDL_FALSE;
-}
-
 #endif /* SDL_JOYSTICK_XINPUT */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 7d872ff..6927985 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1113,7 +1113,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
 static void
 D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
+    /*D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;*/
     D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
 
     if (!texturedata) {
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 461d0ac..8a2e2fc 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -69,6 +69,7 @@ if (!_this->egl_data->NAME) \
 }
     
 /* EGL implementation of SDL OpenGL ES support */
+#ifdef EGL_KHR_create_context        
 static int SDL_EGL_HasExtension(_THIS, const char *ext)
 {
     int i;
@@ -100,6 +101,7 @@ static int SDL_EGL_HasExtension(_THIS, const char *ext)
 
     return 0;
 }
+#endif /* EGL_KHR_create_context */
 
 void *
 SDL_EGL_GetProcAddress(_THIS, const char *proc)
@@ -552,21 +554,22 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
 EGLSurface *
 SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) 
 {
-    EGLint format;
-    
     if (SDL_EGL_ChooseConfig(_this) != 0) {
         return EGL_NO_SURFACE;
     }
     
 #if __ANDROID__
-    /* Android docs recommend doing this!
-     * Ref: http://developer.android.com/reference/android/app/NativeActivity.html 
-     */
-    _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
-                                        _this->egl_data->egl_config, 
-                                        EGL_NATIVE_VISUAL_ID, &format);
+    {
+        /* Android docs recommend doing this!
+         * Ref: http://developer.android.com/reference/android/app/NativeActivity.html 
+         */
+        EGLint format;
+        _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
+                                            _this->egl_data->egl_config, 
+                                            EGL_NATIVE_VISUAL_ID, &format);
 
-    ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
+        ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
+    }
 #endif    
     
     return _this->egl_data->eglCreateWindowSurface(
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 7ff47d4..28801d2 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -453,31 +453,30 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             /* Mouse data */
             if (inp.header.dwType == RIM_TYPEMOUSE) {
                 if (isRelative) {
-                    RAWMOUSE* mouse = &inp.data.mouse;
+                    RAWMOUSE* rawmouse = &inp.data.mouse;
 
-                    if ((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
-                        SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY);
+                    if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
+                        SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
                     } else {
                         /* synthesize relative moves from the abs position */
                         static SDL_Point initialMousePoint;
                         if (initialMousePoint.x == 0 && initialMousePoint.y == 0) {
-                            initialMousePoint.x = mouse->lLastX;
-                            initialMousePoint.y = mouse->lLastY;
+                            initialMousePoint.x = rawmouse->lLastX;
+                            initialMousePoint.y = rawmouse->lLastY;
                         }
 
-                        SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
+                        SDL_SendMouseMotion(data->window, 0, 1, (int)(rawmouse->lLastX-initialMousePoint.x), (int)(rawmouse->lLastY-initialMousePoint.y) );
 
-                        initialMousePoint.x = mouse->lLastX;
-                        initialMousePoint.y = mouse->lLastY;
+                        initialMousePoint.x = rawmouse->lLastX;
+                        initialMousePoint.y = rawmouse->lLastY;
                     }
-                    WIN_CheckRawMouseButtons( mouse->usButtonFlags, data );
+                    WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data);
                 } else if (isCapture) {
                     /* we check for where Windows thinks the system cursor lives in this case, so we don't really lose mouse accel, etc. */
                     POINT pt;
-                    HWND hwnd = data->hwnd;
                     GetCursorPos(&pt);
                     if (WindowFromPoint(pt) != hwnd) {  /* if in the window, WM_MOUSEMOVE, etc, will cover it. */
-                        ScreenToClient(data->hwnd, &pt);
+                        ScreenToClient(hwnd, &pt);
                         SDL_SendMouseMotion(data->window, 0, 0, (int) pt.x, (int) pt.y);
                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT);
                         SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT);
@@ -892,7 +891,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             SDL_Window *window = data->window;
             if (window->hit_test) {
                 POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };
-                if (ScreenToClient(data->hwnd, &winpoint)) {
+                if (ScreenToClient(hwnd, &winpoint)) {
                     const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
                     const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
                     switch (rc) {
@@ -905,6 +904,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                         case SDL_HITTEST_RESIZE_BOTTOM: return HTBOTTOM;
                         case SDL_HITTEST_RESIZE_BOTTOMLEFT: return HTBOTTOMLEFT;
                         case SDL_HITTEST_RESIZE_LEFT: return HTLEFT;
+                        case SDL_HITTEST_NORMAL: return HTCLIENT;
                     }
                 }
                 /* If we didn't return, this will call DefWindowProc below. */
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index 828e3ff..0557b6c 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -750,18 +750,16 @@ IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata)
         if (cand_list) {
             size = ImmGetCandidateListW(himc, 0, cand_list, size);
             if (size) {
-                int i = 0;
-                int j = 0;
-                int page_start = 0;
+                UINT i, j;
+                UINT page_start = 0;
                 videodata->ime_candsel = cand_list->dwSelection;
                 videodata->ime_candcount = cand_list->dwCount;
 
                 if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) {
                     const UINT maxcandchar = 18;
-                    UINT i = 0;
                     size_t cchars = 0;
 
-                    for (; i < videodata->ime_candcount; ++i) {
+                    for (i = 0; i < videodata->ime_candcount; ++i) {
                         size_t len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1;
                         if (len + cchars > maxcandchar) {
                             if (i > cand_list->dwSelection)
@@ -775,8 +773,7 @@ IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata)
                         }
                     }
                     videodata->ime_candpgsize = i - page_start;
-                }
-                else {
+                } else {
                     videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
                     page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
                 }
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 1998502..c61076c 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -258,7 +258,6 @@ WIN_CaptureMouse(SDL_Window *window)
     if (!window) {
         SDL_Window *focusWin = SDL_GetKeyboardFocus();
         if (focusWin) {
-            SDL_WindowData *data = (SDL_WindowData *)focusWin->driverdata;
             WIN_OnWindowEnter(SDL_GetVideoDevice(), focusWin);  /* make sure WM_MOUSELEAVE messages are (re)enabled. */
         }
     }