Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/sdl/core/windows/SDL_windows.h
9905 views
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 _INCLUDED_WINDOWS_H
25
#define _INCLUDED_WINDOWS_H
26
27
#ifdef SDL_PLATFORM_WIN32
28
#ifndef WIN32_LEAN_AND_MEAN
29
#define WIN32_LEAN_AND_MEAN 1
30
#endif
31
#ifndef STRICT
32
#define STRICT 1
33
#endif
34
#ifndef UNICODE
35
#define UNICODE 1
36
#endif
37
#undef WINVER
38
#undef _WIN32_WINNT
39
#if defined(SDL_VIDEO_RENDER_D3D12) || defined(HAVE_DXGI1_6_H)
40
#define _WIN32_WINNT 0xA00 // For D3D12, 0xA00 is required
41
#elif defined(HAVE_SHELLSCALINGAPI_H)
42
#define _WIN32_WINNT 0x603 // For DPI support
43
#else
44
#define _WIN32_WINNT 0x501 // Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input
45
#endif
46
#define WINVER _WIN32_WINNT
47
48
#elif defined(SDL_PLATFORM_WINGDK)
49
#ifndef WIN32_LEAN_AND_MEAN
50
#define WIN32_LEAN_AND_MEAN 1
51
#endif
52
#ifndef STRICT
53
#define STRICT 1
54
#endif
55
#ifndef UNICODE
56
#define UNICODE 1
57
#endif
58
#undef WINVER
59
#undef _WIN32_WINNT
60
#define _WIN32_WINNT 0xA00
61
#define WINVER _WIN32_WINNT
62
63
#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
64
#ifndef WIN32_LEAN_AND_MEAN
65
#define WIN32_LEAN_AND_MEAN 1
66
#endif
67
#ifndef STRICT
68
#define STRICT 1
69
#endif
70
#ifndef UNICODE
71
#define UNICODE 1
72
#endif
73
#undef WINVER
74
#undef _WIN32_WINNT
75
#define _WIN32_WINNT 0xA00
76
#define WINVER _WIN32_WINNT
77
#endif
78
79
// See https://github.com/libsdl-org/SDL/pull/7607
80
// force_align_arg_pointer attribute requires gcc >= 4.2.x.
81
#if defined(__clang__)
82
#define HAVE_FORCE_ALIGN_ARG_POINTER
83
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
84
#define HAVE_FORCE_ALIGN_ARG_POINTER
85
#endif
86
#if defined(__GNUC__) && defined(__i386__) && defined(HAVE_FORCE_ALIGN_ARG_POINTER)
87
#define MINGW32_FORCEALIGN __attribute__((force_align_arg_pointer))
88
#else
89
#define MINGW32_FORCEALIGN
90
#endif
91
92
#include <windows.h>
93
#include <basetyps.h> // for REFIID with broken mingw.org headers
94
#include <mmreg.h>
95
96
// Routines to convert from UTF8 to native Windows text
97
#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S) + 1) * sizeof(WCHAR))
98
#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S) + 1)
99
// !!! FIXME: UTF8ToString() can just be a SDL_strdup() here.
100
#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S) + 1))
101
#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S) + 1)
102
#if UNICODE
103
#define WIN_StringToUTF8 WIN_StringToUTF8W
104
#define WIN_UTF8ToString WIN_UTF8ToStringW
105
#define SDL_tcslen SDL_wcslen
106
#define SDL_tcsstr SDL_wcsstr
107
#else
108
#define WIN_StringToUTF8 WIN_StringToUTF8A
109
#define WIN_UTF8ToString WIN_UTF8ToStringA
110
#define SDL_tcslen SDL_strlen
111
#define SDL_tcsstr SDL_strstr
112
#endif
113
114
// Set up for C function definitions, even when using C++
115
#ifdef __cplusplus
116
extern "C" {
117
#endif
118
119
// Sets an error message based on a given HRESULT
120
extern bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
121
122
// Sets an error message based on GetLastError(). Always returns false.
123
extern bool WIN_SetError(const char *prefix);
124
125
// Load a function from combase.dll
126
FARPROC WIN_LoadComBaseFunction(const char *name);
127
128
// Wrap up the oddities of CoInitialize() into a common function.
129
extern HRESULT WIN_CoInitialize(void);
130
extern void WIN_CoUninitialize(void);
131
132
// Wrap up the oddities of RoInitialize() into a common function.
133
extern HRESULT WIN_RoInitialize(void);
134
extern void WIN_RoUninitialize(void);
135
136
// Returns true if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
137
extern BOOL WIN_IsWindowsXP(void);
138
139
// Returns true if we're running on Windows Vista and newer
140
extern BOOL WIN_IsWindowsVistaOrGreater(void);
141
142
// Returns true if we're running on Windows 7 and newer
143
extern BOOL WIN_IsWindows7OrGreater(void);
144
145
// Returns true if we're running on Windows 8 and newer
146
extern BOOL WIN_IsWindows8OrGreater(void);
147
148
// You need to SDL_free() the result of this call.
149
extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
150
151
// Checks to see if two GUID are the same.
152
extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b);
153
extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
154
155
// Convert between SDL_rect and RECT
156
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
157
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
158
159
// Returns false if a window client rect is not valid
160
bool WIN_WindowRectValid(const RECT *rect);
161
162
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
163
164
// WideCharToMultiByte, but with some WinXP management.
165
extern int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
166
167
// Ends C function definitions when using C++
168
#ifdef __cplusplus
169
}
170
#endif
171
172
#endif // _INCLUDED_WINDOWS_H
173
174