SDL_windows.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* This is an include file for windows.h with the SDL build settings */
  19. #ifndef _INCLUDED_WINDOWS_H
  20. #define _INCLUDED_WINDOWS_H
  21. #ifdef __WIN32__
  22. #ifndef WIN32_LEAN_AND_MEAN
  23. #define WIN32_LEAN_AND_MEAN 1
  24. #endif
  25. #ifndef STRICT
  26. #define STRICT 1
  27. #endif
  28. #ifndef UNICODE
  29. #define UNICODE 1
  30. #endif
  31. #undef WINVER
  32. #undef _WIN32_WINNT
  33. #ifdef SDL_VIDEO_RENDER_D3D12
  34. #define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */
  35. #elif defined(HAVE_SHELLSCALINGAPI_H)
  36. #define _WIN32_WINNT 0x603 /* For DPI support */
  37. #else
  38. #define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
  39. #endif
  40. #define WINVER _WIN32_WINNT
  41. #elif defined(__WINGDK__)
  42. #ifndef WIN32_LEAN_AND_MEAN
  43. #define WIN32_LEAN_AND_MEAN 1
  44. #endif
  45. #ifndef STRICT
  46. #define STRICT 1
  47. #endif
  48. #ifndef UNICODE
  49. #define UNICODE 1
  50. #endif
  51. #undef WINVER
  52. #undef _WIN32_WINNT
  53. #define _WIN32_WINNT 0xA00
  54. #define WINVER _WIN32_WINNT
  55. #elif defined(__XBOXONE__) || defined(__XBOXSERIES__)
  56. #ifndef WIN32_LEAN_AND_MEAN
  57. #define WIN32_LEAN_AND_MEAN 1
  58. #endif
  59. #ifndef STRICT
  60. #define STRICT 1
  61. #endif
  62. #ifndef UNICODE
  63. #define UNICODE 1
  64. #endif
  65. #undef WINVER
  66. #undef _WIN32_WINNT
  67. #define _WIN32_WINNT 0xA00
  68. #define WINVER _WIN32_WINNT
  69. #endif
  70. #include <windows.h>
  71. #include <basetyps.h> /* for REFIID with broken mingw.org headers */
  72. #include <mmreg.h>
  73. /* Older Visual C++ headers don't have the Win64-compatible typedefs... */
  74. #if defined(_MSC_VER) && (_MSC_VER <= 1200)
  75. #ifndef DWORD_PTR
  76. #define DWORD_PTR DWORD
  77. #endif
  78. #ifndef LONG_PTR
  79. #define LONG_PTR LONG
  80. #endif
  81. #endif
  82. /* Routines to convert from UTF8 to native Windows text */
  83. #define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S) + 1) * sizeof(WCHAR))
  84. #define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S) + 1)
  85. /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */
  86. #define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S) + 1))
  87. #define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S) + 1)
  88. #if UNICODE
  89. #define WIN_StringToUTF8 WIN_StringToUTF8W
  90. #define WIN_UTF8ToString WIN_UTF8ToStringW
  91. #define SDL_tcslen SDL_wcslen
  92. #define SDL_tcsstr SDL_wcsstr
  93. #else
  94. #define WIN_StringToUTF8 WIN_StringToUTF8A
  95. #define WIN_UTF8ToString WIN_UTF8ToStringA
  96. #define SDL_tcslen SDL_strlen
  97. #define SDL_tcsstr SDL_strstr
  98. #endif
  99. /* Set up for C function definitions, even when using C++ */
  100. #ifdef __cplusplus
  101. extern "C" {
  102. #endif
  103. /* Sets an error message based on a given HRESULT */
  104. extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
  105. /* Sets an error message based on GetLastError(). Always return -1. */
  106. extern int WIN_SetError(const char *prefix);
  107. #ifndef __WINRT__
  108. /* Load a function from combase.dll */
  109. void *WIN_LoadComBaseFunction(const char *name);
  110. #endif
  111. /* Wrap up the oddities of CoInitialize() into a common function. */
  112. extern HRESULT WIN_CoInitialize(void);
  113. extern void WIN_CoUninitialize(void);
  114. /* Wrap up the oddities of RoInitialize() into a common function. */
  115. extern HRESULT WIN_RoInitialize(void);
  116. extern void WIN_RoUninitialize(void);
  117. /* Returns SDL_TRUE if we're running on Windows Vista and newer */
  118. extern BOOL WIN_IsWindowsVistaOrGreater(void);
  119. /* Returns SDL_TRUE if we're running on Windows 7 and newer */
  120. extern BOOL WIN_IsWindows7OrGreater(void);
  121. /* Returns SDL_TRUE if we're running on Windows 8 and newer */
  122. extern BOOL WIN_IsWindows8OrGreater(void);
  123. /* You need to SDL_free() the result of this call. */
  124. extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
  125. /* Checks to see if two GUID are the same. */
  126. extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b);
  127. extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
  128. /* Convert between SDL_rect and RECT */
  129. extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
  130. extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
  131. /* Returns SDL_TRUE if the rect is empty */
  132. extern BOOL WIN_IsRectEmpty(const RECT *rect);
  133. extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
  134. /* Ends C function definitions when using C++ */
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif /* _INCLUDED_WINDOWS_H */