Fixed mingw64 build and warnings
authorSam Lantinga <slouken@libsdl.org>
Mon, 07 Jul 2014 10:26:28 -0700
changeset 8976 1a5d959d7b32
parent 8975 180271d72b1e
child 8977 84ae33058c67
Fixed mingw64 build and warnings
configure
configure.in
src/audio/SDL_wave.c
src/events/SDL_mouse.c
src/haptic/SDL_syshaptic.h
src/haptic/windows/SDL_dinputhaptic.c
src/haptic/windows/SDL_windowshaptic_c.h
src/joystick/SDL_gamecontroller.c
src/joystick/windows/SDL_dinputjoystick.c
src/joystick/windows/SDL_windowsjoystick_c.h
src/joystick/windows/SDL_xinputjoystick.c
src/render/direct3d/SDL_render_d3d.c
src/video/SDL_egl.c
src/video/windows/SDL_windowsevents.c
src/video/windows/SDL_windowskeyboard.c
src/video/windows/SDL_windowsmouse.c
--- a/configure	Sun Jul 06 20:41:39 2014 -0700
+++ b/configure	Mon Jul 07 10:26:28 2014 -0700
@@ -23067,7 +23067,7 @@
 $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
--- a/configure.in	Sun Jul 06 20:41:39 2014 -0700
+++ b/configure.in	Mon Jul 07 10:26:28 2014 -0700
@@ -2982,7 +2982,7 @@
                 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
--- a/src/audio/SDL_wave.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/audio/SDL_wave.c	Mon Jul 07 10:26:28 2014 -0700
@@ -345,7 +345,7 @@
     /* 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);
     }
--- a/src/events/SDL_mouse.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/events/SDL_mouse.c	Mon Jul 07 10:26:28 2014 -0700
@@ -204,7 +204,6 @@
     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;
--- a/src/haptic/SDL_syshaptic.h	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/haptic/SDL_syshaptic.h	Mon Jul 07 10:26:28 2014 -0700
@@ -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_HapticStopAll(SDL_Haptic * haptic);
 
+#endif /* _SDL_syshaptic_h */
+
 /* vi: set ts=4 sw=4 expandtab: */
 
--- a/src/haptic/windows/SDL_dinputhaptic.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/haptic/windows/SDL_dinputhaptic.c	Mon Jul 07 10:26:28 2014 -0700
@@ -105,7 +105,7 @@
     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);
--- a/src/haptic/windows/SDL_windowshaptic_c.h	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/haptic/windows/SDL_windowshaptic_c.h	Mon Jul 07 10:26:28 2014 -0700
@@ -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"
 
--- a/src/joystick/SDL_gamecontroller.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/joystick/SDL_gamecontroller.c	Mon Jul 07 10:26:28 2014 -0700
@@ -258,10 +258,12 @@
  */
 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);
--- a/src/joystick/windows/SDL_dinputjoystick.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/joystick/windows/SDL_dinputjoystick.c	Mon Jul 07 10:26:28 2014 -0700
@@ -231,7 +231,7 @@
     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 @@
     /* 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);
 
--- a/src/joystick/windows/SDL_windowsjoystick_c.h	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/joystick/windows/SDL_windowsjoystick_c.h	Mon Jul 07 10:26:28 2014 -0700
@@ -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"
--- a/src/joystick/windows/SDL_xinputjoystick.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/joystick/windows/SDL_xinputjoystick.c	Mon Jul 07 10:26:28 2014 -0700
@@ -234,7 +234,6 @@
     };
     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_bool
-SDL_SYS_IsXInputGamepad_DeviceIndex(int device_index)
-{
-    return SDL_FALSE;
-}
-
 #endif /* SDL_JOYSTICK_XINPUT */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/render/direct3d/SDL_render_d3d.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/render/direct3d/SDL_render_d3d.c	Mon Jul 07 10:26:28 2014 -0700
@@ -1113,7 +1113,7 @@
 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) {
--- a/src/video/SDL_egl.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/video/SDL_egl.c	Mon Jul 07 10:26:28 2014 -0700
@@ -69,6 +69,7 @@
 }
     
 /* 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 @@
 
     return 0;
 }
+#endif /* EGL_KHR_create_context */
 
 void *
 SDL_EGL_GetProcAddress(_THIS, const char *proc)
@@ -552,21 +554,22 @@
 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(
--- a/src/video/windows/SDL_windowsevents.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/video/windows/SDL_windowsevents.c	Mon Jul 07 10:26:28 2014 -0700
@@ -453,31 +453,30 @@
             /* 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 @@
             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 @@
                         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. */
--- a/src/video/windows/SDL_windowskeyboard.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/video/windows/SDL_windowskeyboard.c	Mon Jul 07 10:26:28 2014 -0700
@@ -750,18 +750,16 @@
         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 @@
                         }
                     }
                     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;
                 }
--- a/src/video/windows/SDL_windowsmouse.c	Sun Jul 06 20:41:39 2014 -0700
+++ b/src/video/windows/SDL_windowsmouse.c	Mon Jul 07 10:26:28 2014 -0700
@@ -258,7 +258,6 @@
     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. */
         }
     }