src/core/windows/SDL_windows.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 02 Jan 2016 10:10:34 -0800
changeset 9998 f67cf37e9cd4
parent 9619 b94b6d0bff0f
child 10278 1e7b4cfe8451
permissions -rw-r--r--
Updated copyright to 2016
slouken@5090
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9998
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
slouken@5090
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@5090
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@5090
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@5090
    20
*/
slouken@5090
    21
slouken@5090
    22
/* This is an include file for windows.h with the SDL build settings */
slouken@5090
    23
slouken@5090
    24
#ifndef _INCLUDED_WINDOWS_H
slouken@5090
    25
#define _INCLUDED_WINDOWS_H
slouken@5090
    26
dludwig@8353
    27
#if defined(__WIN32__)
slouken@5090
    28
#define WIN32_LEAN_AND_MEAN
slouken@5090
    29
#define STRICT
slouken@5090
    30
#ifndef UNICODE
slouken@5090
    31
#define UNICODE 1
slouken@5090
    32
#endif
slouken@5336
    33
#undef _WIN32_WINNT
slouken@6350
    34
#define _WIN32_WINNT  0x501   /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
dludwig@8353
    35
#endif
slouken@5090
    36
slouken@5090
    37
#include <windows.h>
slouken@5090
    38
slouken@5090
    39
/* Routines to convert from UTF8 to native Windows text */
slouken@5090
    40
#if UNICODE
slouken@7833
    41
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
slouken@7833
    42
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1)
slouken@5090
    43
#else
icculus@7660
    44
/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */
slouken@5090
    45
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
slouken@5090
    46
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
slouken@5090
    47
#endif
slouken@5090
    48
dludwig@8401
    49
/* Sets an error message based on a given HRESULT */
dludwig@8460
    50
extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
dludwig@8401
    51
icculus@7037
    52
/* Sets an error message based on GetLastError(). Always return -1. */
icculus@7037
    53
extern int WIN_SetError(const char *prefix);
slouken@5090
    54
icculus@5591
    55
/* Wrap up the oddities of CoInitialize() into a common function. */
icculus@5591
    56
extern HRESULT WIN_CoInitialize(void);
icculus@5591
    57
extern void WIN_CoUninitialize(void);
icculus@5591
    58
slouken@8733
    59
/* Returns SDL_TRUE if we're running on Windows Vista and newer */
slouken@8733
    60
extern BOOL WIN_IsWindowsVistaOrGreater();
slouken@8733
    61
slouken@5090
    62
#endif /* _INCLUDED_WINDOWS_H */
slouken@5090
    63
slouken@5090
    64
/* vi: set ts=4 sw=4 expandtab: */