Fixed building with mingw32
authorSam Lantinga <slouken@libsdl.org>
Wed, 18 Jan 2017 11:57:27 -0800
changeset 108187e06b0e4dbe0
parent 10817 efc103e60c5b
child 10819 bab110e44dcb
Fixed building with mingw32
src/audio/winmm/SDL_winmm.c
src/joystick/windows/SDL_mmjoystick.c
src/stdlib/SDL_string.c
     1.1 --- a/src/audio/winmm/SDL_winmm.c	Wed Jan 18 02:11:56 2017 -0500
     1.2 +++ b/src/audio/winmm/SDL_winmm.c	Wed Jan 18 11:57:27 2017 -0800
     1.3 @@ -33,6 +33,41 @@
     1.4  #include "../SDL_audio_c.h"
     1.5  #include "SDL_winmm.h"
     1.6  
     1.7 +/*====== WORKAROUND for MinGW's WinAPI header where those structures are being missed ======*/
     1.8 +#if defined(__MINGW32__) && !defined(__MINGW64__)
     1.9 +
    1.10 +typedef struct tagWAVEINCAPS2W 
    1.11 +{
    1.12 +    WORD wMid;
    1.13 +    WORD wPid;
    1.14 +    MMVERSION vDriverVersion;
    1.15 +    WCHAR szPname[MAXPNAMELEN];
    1.16 +    DWORD dwFormats;
    1.17 +    WORD wChannels;
    1.18 +    WORD wReserved1;
    1.19 +    GUID ManufacturerGuid;
    1.20 +    GUID ProductGuid;
    1.21 +    GUID NameGuid;
    1.22 +} WAVEINCAPS2W,*PWAVEINCAPS2W,*NPWAVEINCAPS2W,*LPWAVEINCAPS2W;
    1.23 +
    1.24 +typedef struct tagWAVEOUTCAPS2W
    1.25 +{
    1.26 +    WORD wMid;
    1.27 +    WORD wPid;
    1.28 +    MMVERSION vDriverVersion;
    1.29 +    WCHAR szPname[MAXPNAMELEN];
    1.30 +    DWORD dwFormats;
    1.31 +    WORD wChannels;
    1.32 +    WORD wReserved1;
    1.33 +    DWORD dwSupport;
    1.34 +    GUID ManufacturerGuid;
    1.35 +    GUID ProductGuid;
    1.36 +    GUID NameGuid;
    1.37 +} WAVEOUTCAPS2W,*PWAVEOUTCAPS2W,*NPWAVEOUTCAPS2W,*LPWAVEOUTCAPS2W;
    1.38 +
    1.39 +#endif /* defined(__MINGW32__) && !defined(__MINGW64__) */
    1.40 +/*==========================================================================================*/
    1.41 +
    1.42  #ifndef WAVE_FORMAT_IEEE_FLOAT
    1.43  #define WAVE_FORMAT_IEEE_FLOAT 0x0003
    1.44  #endif
     2.1 --- a/src/joystick/windows/SDL_mmjoystick.c	Wed Jan 18 02:11:56 2017 -0500
     2.2 +++ b/src/joystick/windows/SDL_mmjoystick.c	Wed Jan 18 11:57:27 2017 -0800
     2.3 @@ -85,7 +85,12 @@
     2.4      char regvalue[256];
     2.5      char regname[256];
     2.6  
     2.7 -    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
     2.8 +    SDL_snprintf(regkey, SDL_arraysize(regkey),
     2.9 +#ifdef UNICODE
    2.10 +                 "%S\\%s\\%S",
    2.11 +#else
    2.12 +                 "%s\\%s\\%s",
    2.13 +#endif
    2.14                   REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR);
    2.15      hTopKey = HKEY_LOCAL_MACHINE;
    2.16      regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
    2.17 @@ -110,8 +115,13 @@
    2.18      }
    2.19  
    2.20      /* open that registry key */
    2.21 -    SDL_snprintf(regkey, SDL_arraysize(regkey), "%s\\%s", REGSTR_PATH_JOYOEM,
    2.22 -                 regname);
    2.23 +    SDL_snprintf(regkey, SDL_arraysize(regkey),
    2.24 +#ifdef UNICODE
    2.25 +                 "%S\\%s",
    2.26 +#else
    2.27 +                 "%s\\%s",
    2.28 +#endif
    2.29 +                 REGSTR_PATH_JOYOEM, regname);
    2.30      regresult = RegOpenKeyExA(hTopKey, regkey, 0, KEY_READ, &hKey);
    2.31      if (regresult != ERROR_SUCCESS) {
    2.32          return NULL;
    2.33 @@ -313,7 +323,7 @@
    2.34      };
    2.35      DWORD pos[MAX_AXES];
    2.36      struct _transaxis *transaxis;
    2.37 -    int value, change;
    2.38 +    int value;
    2.39      JOYINFOEX joyinfo;
    2.40  
    2.41      joyinfo.dwSize = sizeof(joyinfo);
     3.1 --- a/src/stdlib/SDL_string.c	Wed Jan 18 02:11:56 2017 -0500
     3.2 +++ b/src/stdlib/SDL_string.c	Wed Jan 18 11:57:27 2017 -0800
     3.3 @@ -1628,6 +1628,16 @@
     3.4                      len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
     3.5                      done = SDL_TRUE;
     3.6                      break;
     3.7 +                case 'S':
     3.8 +                    {
     3.9 +                        /* In practice this is used on Windows for WCHAR strings */
    3.10 +                        wchar_t *wide_arg = va_arg(ap, wchar_t *);
    3.11 +                        char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
    3.12 +                        len = SDL_PrintString(text, left, &info, arg);
    3.13 +                        SDL_free(arg);
    3.14 +                        done = SDL_TRUE;
    3.15 +                    }
    3.16 +                    break;
    3.17                  case 's':
    3.18                      len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
    3.19                      done = SDL_TRUE;