src/video/win32/SDL_win32video.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 30 Nov 2010 17:58:51 -0800
changeset 4919 716b2cbf4c9e
parent 4912 37576cdf6751
child 5038 40ef2ad3757c
permissions -rw-r--r--
First pass at Windows multi-touch gesture support
dewyatt@4759
     1
/*
dewyatt@4759
     2
    SDL - Simple DirectMedia Layer
dewyatt@4759
     3
    Copyright (C) 1997-2010 Sam Lantinga
dewyatt@4759
     4
dewyatt@4759
     5
    This library is free software; you can redistribute it and/or
dewyatt@4759
     6
    modify it under the terms of the GNU Lesser General Public
dewyatt@4759
     7
    License as published by the Free Software Foundation; either
dewyatt@4759
     8
    version 2.1 of the License, or (at your option) any later version.
dewyatt@4759
     9
dewyatt@4759
    10
    This library is distributed in the hope that it will be useful,
dewyatt@4759
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
dewyatt@4759
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dewyatt@4759
    13
    Lesser General Public License for more details.
dewyatt@4759
    14
dewyatt@4759
    15
    You should have received a copy of the GNU Lesser General Public
dewyatt@4759
    16
    License along with this library; if not, write to the Free Software
dewyatt@4759
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
dewyatt@4759
    18
dewyatt@4759
    19
    Sam Lantinga
dewyatt@4759
    20
    slouken@libsdl.org
dewyatt@4759
    21
*/
dewyatt@4759
    22
#include "SDL_config.h"
dewyatt@4759
    23
dewyatt@4759
    24
#ifndef _SDL_win32video_h
dewyatt@4759
    25
#define _SDL_win32video_h
dewyatt@4759
    26
dewyatt@4759
    27
#include "../SDL_sysvideo.h"
dewyatt@4759
    28
dewyatt@4759
    29
#define WIN32_LEAN_AND_MEAN
dewyatt@4759
    30
#define STRICT
slouken@4569
    31
#ifndef UNICODE
dewyatt@4759
    32
#define UNICODE
slouken@4569
    33
#endif
dewyatt@4759
    34
#undef WINVER
slouken@4868
    35
#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
jimtla@4650
    36
dewyatt@4759
    37
#include <windows.h>
dewyatt@4759
    38
Daniel@4893
    39
#ifndef __GNUC__
dewyatt@4759
    40
#include <msctf.h>
Daniel@4893
    41
#else
Daniel@4893
    42
#include "SDL_msctf.h"
Daniel@4893
    43
#endif
Daniel@4893
    44
Daniel@4892
    45
#include <imm.h>
dewyatt@4759
    46
Daniel@4912
    47
#define MAX_CANDLIST    10
Daniel@4912
    48
#define MAX_CANDLENGTH  256
Daniel@4912
    49
dewyatt@4759
    50
#if SDL_VIDEO_RENDER_D3D
dewyatt@4759
    51
//#include <d3d9.h>
dewyatt@4759
    52
#define D3D_DEBUG_INFO
dewyatt@4759
    53
#include "d3d9.h"
dewyatt@4759
    54
#endif
dewyatt@4759
    55
dewyatt@4759
    56
#if SDL_VIDEO_RENDER_DDRAW
dewyatt@4759
    57
/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */
dewyatt@4759
    58
#include <objbase.h>
dewyatt@4759
    59
#include "ddraw.h"
dewyatt@4759
    60
#endif
dewyatt@4759
    61
dewyatt@4759
    62
#include "SDL_win32clipboard.h"
dewyatt@4759
    63
#include "SDL_win32events.h"
dewyatt@4759
    64
#include "SDL_win32gamma.h"
dewyatt@4759
    65
#include "SDL_win32keyboard.h"
dewyatt@4759
    66
#include "SDL_win32modes.h"
dewyatt@4759
    67
#include "SDL_win32mouse.h"
dewyatt@4759
    68
#include "SDL_win32opengl.h"
dewyatt@4759
    69
#include "SDL_win32window.h"
dewyatt@4759
    70
#include "SDL_events.h"
dewyatt@4759
    71
dewyatt@4759
    72
#ifdef UNICODE
dewyatt@4759
    73
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
dewyatt@4759
    74
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
dewyatt@4759
    75
#else
dewyatt@4759
    76
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
dewyatt@4759
    77
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
dewyatt@4759
    78
#endif
dewyatt@4759
    79
extern void WIN_SetError(const char *prefix);
dewyatt@4759
    80
slouken@4569
    81
enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
slouken@4569
    82
slouken@4919
    83
#if WINVER < 0x0601
slouken@4919
    84
/* Touch input definitions */
slouken@4919
    85
#define TWF_FINETOUCH	1
slouken@4919
    86
#define TWF_WANTPALM	2
slouken@4919
    87
slouken@4919
    88
#define TOUCHEVENTF_MOVE 0x0001
slouken@4919
    89
#define TOUCHEVENTF_DOWN 0x0002
slouken@4919
    90
#define TOUCHEVENTF_UP   0x0004
slouken@4919
    91
slouken@4919
    92
DECLARE_HANDLE(HTOUCHINPUT);
slouken@4919
    93
slouken@4919
    94
typedef struct _TOUCHINPUT {
slouken@4919
    95
	LONG      x;
slouken@4919
    96
	LONG      y;
slouken@4919
    97
	HANDLE    hSource;
slouken@4919
    98
	DWORD     dwID;
slouken@4919
    99
	DWORD     dwFlags;
slouken@4919
   100
	DWORD     dwMask;
slouken@4919
   101
	DWORD     dwTime;
slouken@4919
   102
	ULONG_PTR dwExtraInfo;
slouken@4919
   103
	DWORD     cxContact;
slouken@4919
   104
	DWORD     cyContact;
slouken@4919
   105
} TOUCHINPUT, *PTOUCHINPUT;
slouken@4919
   106
slouken@4919
   107
#endif /* WINVER < 0x0601 */
slouken@4919
   108
slouken@4569
   109
typedef BOOL  (*PFNSHFullScreen)(HWND, DWORD);
slouken@4569
   110
typedef void  (*PFCoordTransform)(SDL_Window*, POINT*);
slouken@4569
   111
dewyatt@4759
   112
typedef struct  
dewyatt@4759
   113
{
dewyatt@4759
   114
    void **lpVtbl;
dewyatt@4759
   115
    int refcount;
dewyatt@4759
   116
    void *data;
dewyatt@4759
   117
} TSFSink;
dewyatt@4759
   118
Daniel@4892
   119
/* Definition from Win98DDK version of IMM.H */
dewyatt@4759
   120
typedef struct tagINPUTCONTEXT2 {
Daniel@4912
   121
    HWND hWnd;
Daniel@4912
   122
    BOOL fOpen;
Daniel@4912
   123
    POINT ptStatusWndPos;
Daniel@4912
   124
    POINT ptSoftKbdPos;
Daniel@4912
   125
    DWORD fdwConversion;
Daniel@4912
   126
    DWORD fdwSentence;
Daniel@4912
   127
    union {
Daniel@4912
   128
        LOGFONTA A;
Daniel@4912
   129
        LOGFONTW W;
Daniel@4892
   130
    } lfFont;
Daniel@4912
   131
    COMPOSITIONFORM cfCompForm;
Daniel@4912
   132
    CANDIDATEFORM cfCandForm[4];
Daniel@4912
   133
    HIMCC hCompStr;
Daniel@4912
   134
    HIMCC hCandInfo;
Daniel@4912
   135
    HIMCC hGuideLine;
Daniel@4912
   136
    HIMCC hPrivate;
Daniel@4912
   137
    DWORD dwNumMsgBuf;
Daniel@4912
   138
    HIMCC hMsgBuf;
Daniel@4912
   139
    DWORD fdwInit;
Daniel@4912
   140
    DWORD dwReserve[3];
Daniel@4892
   141
} INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2;
dewyatt@4759
   142
dewyatt@4759
   143
/* Private display data */
dewyatt@4759
   144
dewyatt@4759
   145
typedef struct SDL_VideoData
dewyatt@4759
   146
{
slouken@4569
   147
    int render;
slouken@4569
   148
dewyatt@4759
   149
#if SDL_VIDEO_RENDER_D3D
dewyatt@4759
   150
    HANDLE d3dDLL;
dewyatt@4759
   151
    IDirect3D9 *d3d;
dewyatt@4759
   152
#endif
dewyatt@4759
   153
#if SDL_VIDEO_RENDER_DDRAW
dewyatt@4759
   154
    HANDLE ddrawDLL;
dewyatt@4759
   155
    IDirectDraw *ddraw;
dewyatt@4759
   156
#endif
slouken@4569
   157
#ifdef _WIN32_WCE
slouken@4569
   158
    HMODULE hAygShell;
slouken@4569
   159
    PFNSHFullScreen SHFullScreen;
slouken@4569
   160
    PFCoordTransform CoordTransform;
slouken@4569
   161
#endif
dewyatt@4759
   162
dewyatt@4759
   163
    const SDL_scancode *key_layout;
slouken@4919
   164
	DWORD clipboard_count;
slouken@4919
   165
slouken@4919
   166
	/* Touch input functions */
slouken@4919
   167
	HANDLE userDLL;
slouken@4919
   168
	BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
slouken@4919
   169
	BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
slouken@4919
   170
	BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
dewyatt@4759
   171
dewyatt@4759
   172
    SDL_bool ime_com_initialized;
dewyatt@4759
   173
    struct ITfThreadMgr *ime_threadmgr;
dewyatt@4759
   174
    SDL_bool ime_initialized;
dewyatt@4759
   175
    SDL_bool ime_enabled;
dewyatt@4759
   176
    SDL_bool ime_available;
dewyatt@4759
   177
    HWND ime_hwnd_main;
dewyatt@4759
   178
    HWND ime_hwnd_current;
dewyatt@4759
   179
    HIMC ime_himc;
dewyatt@4759
   180
dewyatt@4759
   181
    WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
dewyatt@4759
   182
    WCHAR ime_readingstring[16];
dewyatt@4759
   183
    int ime_cursor;
dewyatt@4759
   184
Daniel@4912
   185
    SDL_bool ime_candlist;
Daniel@4912
   186
    WCHAR ime_candidates[MAX_CANDLIST][MAX_CANDLENGTH];
Daniel@4912
   187
    DWORD ime_candcount;
Daniel@4912
   188
    DWORD ime_candref;
Daniel@4912
   189
    DWORD ime_candsel;
Daniel@4912
   190
    UINT ime_candpgsize;
Daniel@4912
   191
    int ime_candlistindexbase;
Daniel@4912
   192
    SDL_bool ime_candvertical;
Daniel@4912
   193
Daniel@4912
   194
    SDL_Texture *ime_candtex;
Daniel@4912
   195
    SDL_bool ime_dirty;
Daniel@4912
   196
    SDL_Rect ime_rect;
Daniel@4912
   197
    SDL_Rect ime_candlistrect;
Daniel@4912
   198
    int ime_winwidth;
Daniel@4912
   199
    int ime_winheight;
Daniel@4912
   200
dewyatt@4759
   201
    HKL ime_hkl;
dewyatt@4759
   202
    HMODULE ime_himm32;
dewyatt@4759
   203
    UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
dewyatt@4759
   204
    BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
dewyatt@4759
   205
    LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
dewyatt@4759
   206
    BOOL (WINAPI *ImmUnlockIMC)(HIMC himc);
dewyatt@4759
   207
    LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc);
dewyatt@4759
   208
    BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
dewyatt@4759
   209
dewyatt@4759
   210
    SDL_bool ime_uiless;
dewyatt@4759
   211
    struct ITfThreadMgrEx *ime_threadmgrex;
dewyatt@4759
   212
    DWORD ime_uielemsinkcookie;
dewyatt@4759
   213
    DWORD ime_alpnsinkcookie;
dewyatt@4759
   214
    DWORD ime_openmodesinkcookie;
dewyatt@4759
   215
    DWORD ime_convmodesinkcookie;
dewyatt@4759
   216
    TSFSink *ime_uielemsink;
dewyatt@4759
   217
    TSFSink *ime_ippasink;
dewyatt@4759
   218
} SDL_VideoData;
dewyatt@4759
   219
dewyatt@4759
   220
#endif /* _SDL_win32video_h */
dewyatt@4759
   221
dewyatt@4759
   222
/* vi: set ts=4 sw=4 expandtab: */