2017-07-29 00:32:22 +00:00
|
|
|
/*
|
|
|
|
Simple DirectMedia Layer
|
2022-04-09 11:33:02 +00:00
|
|
|
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
2017-07-29 00:32:22 +00:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is an include file for windows.h with the SDL build settings */
|
|
|
|
|
|
|
|
#ifndef _INCLUDED_WINDOWS_H
|
|
|
|
#define _INCLUDED_WINDOWS_H
|
|
|
|
|
|
|
|
#if defined(__WIN32__)
|
2022-09-20 17:15:20 +00:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN 1
|
|
|
|
#endif
|
|
|
|
#ifndef STRICT
|
|
|
|
#define STRICT 1
|
|
|
|
#endif
|
2017-07-29 00:32:22 +00:00
|
|
|
#ifndef UNICODE
|
|
|
|
#define UNICODE 1
|
|
|
|
#endif
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <windows.h>
|
2017-08-11 12:05:21 +00:00
|
|
|
#include <basetyps.h> /* for REFIID with broken mingw.org headers */
|
2017-07-29 00:32:22 +00:00
|
|
|
|
2021-11-28 14:00:02 +00:00
|
|
|
#include "SDL_rect.h"
|
|
|
|
|
2017-07-29 00:32:22 +00:00
|
|
|
/* Routines to convert from UTF8 to native Windows text */
|
2021-11-28 14:00:02 +00:00
|
|
|
#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
|
|
|
#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S)+1)
|
|
|
|
/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */
|
|
|
|
#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S)+1))
|
|
|
|
#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S)+1)
|
2017-07-29 00:32:22 +00:00
|
|
|
#if UNICODE
|
2021-11-28 14:00:02 +00:00
|
|
|
#define WIN_StringToUTF8 WIN_StringToUTF8W
|
|
|
|
#define WIN_UTF8ToString WIN_UTF8ToStringW
|
|
|
|
#define SDL_tcslen SDL_wcslen
|
|
|
|
#define SDL_tcsstr SDL_wcsstr
|
2017-07-29 00:32:22 +00:00
|
|
|
#else
|
2021-11-28 14:00:02 +00:00
|
|
|
#define WIN_StringToUTF8 WIN_StringToUTF8A
|
|
|
|
#define WIN_UTF8ToString WIN_UTF8ToStringA
|
|
|
|
#define SDL_tcslen SDL_strlen
|
|
|
|
#define SDL_tcsstr SDL_strstr
|
2017-07-29 00:32:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Sets an error message based on a given HRESULT */
|
|
|
|
extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
|
|
|
|
|
|
|
|
/* Sets an error message based on GetLastError(). Always return -1. */
|
|
|
|
extern int WIN_SetError(const char *prefix);
|
|
|
|
|
2022-04-09 11:33:02 +00:00
|
|
|
#if !defined(__WINRT__)
|
|
|
|
/* Load a function from combase.dll */
|
|
|
|
void *WIN_LoadComBaseFunction(const char *name);
|
|
|
|
#endif
|
|
|
|
|
2017-07-29 00:32:22 +00:00
|
|
|
/* Wrap up the oddities of CoInitialize() into a common function. */
|
|
|
|
extern HRESULT WIN_CoInitialize(void);
|
|
|
|
extern void WIN_CoUninitialize(void);
|
|
|
|
|
2022-04-09 11:33:02 +00:00
|
|
|
/* Wrap up the oddities of RoInitialize() into a common function. */
|
|
|
|
extern HRESULT WIN_RoInitialize(void);
|
|
|
|
extern void WIN_RoUninitialize(void);
|
|
|
|
|
2017-07-29 00:32:22 +00:00
|
|
|
/* Returns SDL_TRUE if we're running on Windows Vista and newer */
|
|
|
|
extern BOOL WIN_IsWindowsVistaOrGreater(void);
|
|
|
|
|
2018-11-01 14:10:29 +00:00
|
|
|
/* Returns SDL_TRUE if we're running on Windows 7 and newer */
|
|
|
|
extern BOOL WIN_IsWindows7OrGreater(void);
|
|
|
|
|
2021-11-28 14:00:02 +00:00
|
|
|
/* Returns SDL_TRUE if we're running on Windows 8 and newer */
|
|
|
|
extern BOOL WIN_IsWindows8OrGreater(void);
|
|
|
|
|
2017-07-29 00:32:22 +00:00
|
|
|
/* You need to SDL_free() the result of this call. */
|
|
|
|
extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
|
|
|
|
|
2017-08-11 12:05:21 +00:00
|
|
|
/* Checks to see if two GUID are the same. */
|
|
|
|
extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b);
|
|
|
|
extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
|
|
|
|
|
2021-11-28 14:00:02 +00:00
|
|
|
/* Convert between SDL_rect and RECT */
|
|
|
|
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
|
|
|
|
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
|
|
|
|
|
2017-07-29 00:32:22 +00:00
|
|
|
#endif /* _INCLUDED_WINDOWS_H */
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|