module external.directx.win32;

public import core.sys.windows.windows;
public import core.sys.windows.com;

pure nothrow @safe @nogc HRESULT MAKE_HRESULT(bool s, uint f, uint c)
{
    return (s << 31) | (f << 16) | c;
}

union LARGE_INTEGER
{
    struct
    {
        uint LowPart;
        int HighPart;
    }
    long QuadPart;
}

alias LUID = LARGE_INTEGER;

struct tagSIZE
{
    long cx;
    long cy;
}

alias SIZE = tagSIZE;
enum SIZE_MAX = 0xffffffffffffffff;
alias PSIZE = tagSIZE*;
alias LPSIZE = tagSIZE*;
alias SIZEL = SIZE;
alias PSIZEL = SIZE*;
alias LPSIZEL = SIZE*;

auto GET_X_LPARAM(ARG1)(ARG1 lp)
{
    return (cast(int) cast(short) LOWORD(lp));
}

auto GET_Y_LPARAM(ARG1)(ARG1 lp)
{
    return (cast(int) cast(short) HIWORD(lp));
}

version (HAS_WIN32)
{
}
else
{
    align(1) struct WAVEFORMATEX
    {
    align(1):
        WORD wFormatTag;
        WORD nChannels;
        DWORD nSamplesPerSec;
        DWORD nAvgBytesPerSec;
        WORD nBlockAlign;
        WORD wBitsPerSample;
        WORD cbSize;
    }

    struct WAVEFORMATEXTENSIBLE
    {
        WAVEFORMATEX Format;
        union Samples
        {
            WORD wValidBitsPerSample;
            WORD wSamplesPerBlock;
            WORD wReserved;
        }

        DWORD dwChannelMask;
        GUID SubFormat;
    }
}

uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
{
    return (DeviceType << 16) | (Access << 14) | (Function << 2) | Method;
}

enum CHAR_BIT = 8; // number of bits in a char
enum SCHAR_MIN = (-128); // minimum signed char value
enum SCHAR_MAX = 127; // maximum signed char value
enum UCHAR_MAX = 0xff; // maximum unsigned char value
enum MB_LEN_MAX = 5; // max. # bytes in multibyte char
enum SHRT_MIN = (-32768); // minimum (signed) short value
enum SHRT_MAX = 32767; // maximum (signed) short value
enum USHRT_MAX = 0xffff; // maximum unsigned short value
enum INT_MIN = (-2147483647 - 1); // minimum (signed) int value
enum INT_MAX = 2147483647; // maximum (signed) int value
enum UINT_MAX = 0xffffffff; // maximum unsigned int value
enum LONG_MIN = (-2147483647 - 1); // minimum (signed) long value
enum LONG_MAX = 2147483647; // maximum (signed) long value
enum ULONG_MAX = 0xffffffff; // maximum unsigned long value
enum LLONG_MAX = 9223372036854775807; // maximum signed long long int value
enum LLONG_MIN = (-9223372036854775807 - 1); // minimum signed long long int value
enum ULLONG_MAX = 0xffffffffffffffff; // maximum unsigned long long int value
