1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
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 #if defined(__WIN32__)
28 #define WIN32_LEAN_AND_MEAN
29 #define STRICT
30 #ifndef UNICODE
31 #define UNICODE 1
32 #endif
33 #undef _WIN32_WINNT
34 #define _WIN32_WINNT  0x501   /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
35 #endif
36 
37 #include <windows.h>
38 #include <basetyps.h>   /* for REFIID with broken mingw.org headers */
39 
40 #include "SDL_rect.h"
41 
42 /* Routines to convert from UTF8 to native Windows text */
43 #define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
44 #define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S)+1)
45 /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */
46 #define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S)+1))
47 #define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S)+1)
48 #if UNICODE
49 #define WIN_StringToUTF8 WIN_StringToUTF8W
50 #define WIN_UTF8ToString WIN_UTF8ToStringW
51 #define SDL_tcslen SDL_wcslen
52 #define SDL_tcsstr SDL_wcsstr
53 #else
54 #define WIN_StringToUTF8 WIN_StringToUTF8A
55 #define WIN_UTF8ToString WIN_UTF8ToStringA
56 #define SDL_tcslen SDL_strlen
57 #define SDL_tcsstr SDL_strstr
58 #endif
59 
60 /* Sets an error message based on a given HRESULT */
61 extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
62 
63 /* Sets an error message based on GetLastError(). Always return -1. */
64 extern int WIN_SetError(const char *prefix);
65 
66 /* Wrap up the oddities of CoInitialize() into a common function. */
67 extern HRESULT WIN_CoInitialize(void);
68 extern void WIN_CoUninitialize(void);
69 
70 /* Returns SDL_TRUE if we're running on Windows Vista and newer */
71 extern BOOL WIN_IsWindowsVistaOrGreater(void);
72 
73 /* Returns SDL_TRUE if we're running on Windows 7 and newer */
74 extern BOOL WIN_IsWindows7OrGreater(void);
75 
76 /* Returns SDL_TRUE if we're running on Windows 8 and newer */
77 extern BOOL WIN_IsWindows8OrGreater(void);
78 
79 /* You need to SDL_free() the result of this call. */
80 extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
81 
82 /* Checks to see if two GUID are the same. */
83 extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b);
84 extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
85 
86 /* Convert between SDL_rect and RECT */
87 extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
88 extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
89 
90 #endif /* _INCLUDED_WINDOWS_H */
91 
92 /* vi: set ts=4 sw=4 expandtab: */
93