1 /* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2016 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 39 /* Routines to convert from UTF8 to native Windows text */ 40 #if UNICODE 41 #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) 42 #define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) 43 #else 44 /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ 45 #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) 46 #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) 47 #endif 48 49 /* Sets an error message based on a given HRESULT */ 50 extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); 51 52 /* Sets an error message based on GetLastError(). Always return -1. */ 53 extern int WIN_SetError(const char *prefix); 54 55 /* Wrap up the oddities of CoInitialize() into a common function. */ 56 extern HRESULT WIN_CoInitialize(void); 57 extern void WIN_CoUninitialize(void); 58 59 /* Returns SDL_TRUE if we're running on Windows Vista and newer */ 60 extern BOOL WIN_IsWindowsVistaOrGreater(); 61 62 /* You need to SDL_free() the result of this call. */ 63 extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); 64 65 #endif /* _INCLUDED_WINDOWS_H */ 66 67 /* vi: set ts=4 sw=4 expandtab: */ 68