Atlas - SDL_windows.h
Home / ext / SDL / src / core / windows Lines: 1 | Size: 7314 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21 22// This is an include file for windows.h with the SDL build settings 23 24#ifndef SDL_windows_h_ 25#define SDL_windows_h_ 26 27#ifdef SDL_PLATFORM_WIN32 28 29#ifndef _WIN32_WINNT_NT4 30#define _WIN32_WINNT_NT4 0x0400 31#endif 32#ifndef _WIN32_WINNT_WIN2K 33#define _WIN32_WINNT_WIN2K 0x0500 34#endif 35#ifndef _WIN32_WINNT_WINXP 36#define _WIN32_WINNT_WINXP 0x0501 37#endif 38#ifndef _WIN32_WINNT_WS03 39#define _WIN32_WINNT_WS03 0x0502 40#endif 41#ifndef _WIN32_WINNT_VISTA 42#define _WIN32_WINNT_VISTA 0x0600 43#endif 44#ifndef _WIN32_WINNT_WIN7 45#define _WIN32_WINNT_WIN7 0x0601 46#endif 47#ifndef _WIN32_WINNT_WIN8 48#define _WIN32_WINNT_WIN8 0x0602 49#endif 50#ifndef _WIN32_WINNT_WINBLUE 51#define _WIN32_WINNT_WINBLUE 0x0603 52#endif 53#ifndef _WIN32_WINNT_WIN10 54#define _WIN32_WINNT_WIN10 0x0A00 55#endif 56 57#ifndef WIN32_LEAN_AND_MEAN 58#define WIN32_LEAN_AND_MEAN 1 59#endif 60#ifndef STRICT 61#define STRICT 1 62#endif 63#ifndef UNICODE 64#define UNICODE 1 65#endif 66#undef WINVER 67#undef _WIN32_WINNT 68#if defined(SDL_VIDEO_RENDER_D3D12) || defined(HAVE_DXGI1_6_H) 69#define _WIN32_WINNT _WIN32_WINNT_WIN10 // For D3D12, 0xA00 is required 70#elif defined(HAVE_SHELLSCALINGAPI_H) 71#define _WIN32_WINNT _WIN32_WINNT_WINBLUE // For DPI support 72#elif defined(HAVE_ROAPI_H) 73#define _WIN32_WINNT _WIN32_WINNT_WIN8 74#elif defined(HAVE_SENSORSAPI_H) 75#define _WIN32_WINNT _WIN32_WINNT_WIN7 76#elif defined(HAVE_MMDEVICEAPI_H) 77#define _WIN32_WINNT _WIN32_WINNT_VISTA 78#else 79#define _WIN32_WINNT _WIN32_WINNT_WINXP // Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input 80#endif 81#define WINVER _WIN32_WINNT 82 83#elif defined(SDL_PLATFORM_WINGDK) 84#ifndef WIN32_LEAN_AND_MEAN 85#define WIN32_LEAN_AND_MEAN 1 86#endif 87#ifndef STRICT 88#define STRICT 1 89#endif 90#ifndef UNICODE 91#define UNICODE 1 92#endif 93#undef WINVER 94#undef _WIN32_WINNT 95#define _WIN32_WINNT 0xA00 96#define WINVER _WIN32_WINNT 97 98#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) 99#ifndef WIN32_LEAN_AND_MEAN 100#define WIN32_LEAN_AND_MEAN 1 101#endif 102#ifndef STRICT 103#define STRICT 1 104#endif 105#ifndef UNICODE 106#define UNICODE 1 107#endif 108#undef WINVER 109#undef _WIN32_WINNT 110#define _WIN32_WINNT 0xA00 111#define WINVER _WIN32_WINNT 112#endif 113 114// See https://github.com/libsdl-org/SDL/pull/7607 115// force_align_arg_pointer attribute requires gcc >= 4.2.x. 116#if defined(__clang__) 117#define HAVE_FORCE_ALIGN_ARG_POINTER 118#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) 119#define HAVE_FORCE_ALIGN_ARG_POINTER 120#endif 121#if defined(__GNUC__) && defined(__i386__) && defined(HAVE_FORCE_ALIGN_ARG_POINTER) 122#define MINGW32_FORCEALIGN __attribute__((force_align_arg_pointer)) 123#else 124#define MINGW32_FORCEALIGN 125#endif 126 127#include <windows.h> 128#include <basetyps.h> // for REFIID with broken mingw.org headers 129#include <mmreg.h> 130 131// Routines to convert from UTF8 to native Windows text 132#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S) + 1) * sizeof(WCHAR)) 133#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S) + 1) 134// !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. 135#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S) + 1)) 136#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S) + 1) 137#if UNICODE 138#define WIN_StringToUTF8 WIN_StringToUTF8W 139#define WIN_UTF8ToString WIN_UTF8ToStringW 140#define SDL_tcslen SDL_wcslen 141#define SDL_tcsstr SDL_wcsstr 142#else 143#define WIN_StringToUTF8 WIN_StringToUTF8A 144#define WIN_UTF8ToString WIN_UTF8ToStringA 145#define SDL_tcslen SDL_strlen 146#define SDL_tcsstr SDL_strstr 147#endif 148 149// Set up for C function definitions, even when using C++ 150#ifdef __cplusplus 151extern "C" { 152#endif 153 154// Sets an error message based on a given HRESULT 155extern bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); 156 157// Sets an error message based on GetLastError(). Always returns false. 158extern bool WIN_SetError(const char *prefix); 159 160// Load a function from combase.dll 161FARPROC WIN_LoadComBaseFunction(const char *name); 162 163// Wrap up the oddities of CoInitialize() into a common function. 164extern HRESULT WIN_CoInitialize(void); 165extern void WIN_CoUninitialize(void); 166 167// Wrap up the oddities of RoInitialize() into a common function. 168extern HRESULT WIN_RoInitialize(void); 169extern void WIN_RoUninitialize(void); 170 171// Returns true if we're running on Wine 172extern BOOL WIN_IsWine(void); 173 174// Returns true if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"! 175extern BOOL WIN_IsWindowsXP(void); 176 177// Returns true if we're running on Windows Vista and newer 178extern BOOL WIN_IsWindowsVistaOrGreater(void); 179 180// Returns true if we're running on Windows 7 and newer 181extern BOOL WIN_IsWindows7OrGreater(void); 182 183// Returns true if we're running on Windows 8 and newer 184extern BOOL WIN_IsWindows8OrGreater(void); 185 186// Returns true if we're running on Windows 11 and newer 187extern BOOL WIN_IsWindows11OrGreater(void); 188 189// You need to SDL_free() the result of this call. 190extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); 191 192// Checks to see if two GUID are the same. 193extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b); 194extern BOOL WIN_IsEqualIID(REFIID a, REFIID b); 195 196// Convert between SDL_rect and RECT 197extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect); 198extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect); 199 200// Returns false if a window client rect is not valid 201extern bool WIN_WindowRectValid(const RECT *rect); 202 203extern void WIN_UpdateDarkModeForHWND(HWND hwnd); 204 205extern HICON WIN_CreateIconFromSurface(SDL_Surface *surface); 206 207extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat); 208 209// WideCharToMultiByte, but with some WinXP management. 210extern int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar); 211 212// parse out command lines from OS if argv is NULL, otherwise pass through unchanged. `*pallocated` must be HeapFree'd by caller if not NULL on successful return. Returns NULL on success, error string on problems. 213const char *WIN_CheckDefaultArgcArgv(int *pargc, char ***pargv, void **pallocated); 214 215// Ends C function definitions when using C++ 216#ifdef __cplusplus 217} 218#endif 219 220#endif // SDL_windows_h_ 221[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.