src/video/wincommon/SDL_sysevents.c
author Sam Lantinga
Thu, 29 Dec 2011 04:29:53 -0500
branchSDL-1.2
changeset 6110 676a54593bc4
parent 5988 bf927e528813
child 6125 760a3162e180
permissions -rw-r--r--
Fixed bugs 1034 and 1035

zicodxx@gmx.de 2010-07-28 12:59:27 PDT
Again another bug I encountered on Windows 7:

Assuming I hide my mouse cusor with SDL_ShowCursor(SDL_DISABLE).
Now if my app runs on Fullscreen, I tend to "get out" of it using ALT+TAB. This
will minimize the app. However SDL_GetAppState will STILL report SDL_APPACTIVE,
SDL_APPINPUTFOCUS and SDL_APPMOUSEFOCUS.

Also if I check event.active.gain, this *seems* (as much as I could find out)
to be set twice (first 0 then 1 again) while going out of the app with ALT+TAB.
I am not perfectly sure here but even if the app is minimized because of
ALT+TAB (or also CTRL+ESC), event.active.gain is 1.

Alex Volkov 2011-04-28 17:19:26 PDT
This happens with the windib driver. Windows posts the WM_ACTIVATE WA_INACTIVE
event with minimized==false when you Alt+Tab out of a fullscreen app.
Responding to this event, wincommon/SDL_sysevents.c:WinMessage() calls
ShowWindow(,SW_MINIMIZE) via SDL_RestoreDesktopMode, but another WM_ACTIVATE
event is not posted in response to that.
Whatever the case may be, WinMessage() should just treat a fullscreen app
receiving WA_INACTIVE the same as a minimized app. Additionally, it's probably
a good idea to clear SDL_APPMOUSEFOCUS at the same time, and that should take
care of bug #1035.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@4159
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@1433
    24
#define WIN32_LEAN_AND_MEAN
slouken@1433
    25
#include <windows.h>
slouken@0
    26
icculus@3970
    27
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
icculus@3970
    28
#ifndef WM_XBUTTONDOWN
icculus@3970
    29
#define WM_XBUTTONDOWN 0x020B
icculus@3970
    30
#endif
icculus@3970
    31
#ifndef WM_XBUTTONUP
icculus@3970
    32
#define WM_XBUTTONUP 0x020C
icculus@3970
    33
#endif
icculus@3970
    34
#ifndef GET_XBUTTON_WPARAM
icculus@3970
    35
#define GET_XBUTTON_WPARAM(w) (HIWORD(w))
icculus@3970
    36
#endif
icculus@3970
    37
slouken@0
    38
#include "SDL_events.h"
slouken@0
    39
#include "SDL_video.h"
slouken@0
    40
#include "SDL_syswm.h"
slouken@1361
    41
#include "../SDL_sysvideo.h"
slouken@1361
    42
#include "../../events/SDL_sysevents.h"
slouken@1361
    43
#include "../../events/SDL_events_c.h"
slouken@0
    44
#include "SDL_lowvideo.h"
slouken@0
    45
#include "SDL_syswm_c.h"
slouken@0
    46
#include "SDL_main.h"
icculus@1152
    47
#include "SDL_loadso.h"
slouken@0
    48
slouken@0
    49
#ifdef WMMSG_DEBUG
slouken@0
    50
#include "wmmsg.h"
slouken@0
    51
#endif
slouken@0
    52
slouken@4162
    53
#include "../windib/SDL_gapidibvideo.h"
slouken@4162
    54
slouken@4162
    55
#ifdef SDL_VIDEO_DRIVER_GAPI
slouken@1465
    56
#include "../gapi/SDL_gapivideo.h"
slouken@4162
    57
#endif
slouken@1465
    58
slouken@4162
    59
#ifdef _WIN32_WCE
slouken@1465
    60
#define IsZoomed(HWND) 1
slouken@0
    61
#define NO_GETKEYBOARDSTATE
slouken@1465
    62
#if _WIN32_WCE < 420
slouken@453
    63
#define NO_CHANGEDISPLAYSETTINGS
slouken@0
    64
#endif
slouken@1465
    65
#endif
slouken@0
    66
slouken@0
    67
/* The window we use for everything... */
slouken@453
    68
#ifdef _WIN32_WCE
slouken@453
    69
LPWSTR SDL_Appname = NULL;
slouken@453
    70
#else
slouken@453
    71
LPSTR SDL_Appname = NULL;
slouken@453
    72
#endif
slouken@1288
    73
Uint32 SDL_Appstyle = 0;
slouken@0
    74
HINSTANCE SDL_Instance = NULL;
slouken@0
    75
HWND SDL_Window = NULL;
slouken@0
    76
RECT SDL_bounds = {0, 0, 0, 0};
slouken@833
    77
int SDL_windowX = 0;
slouken@833
    78
int SDL_windowY = 0;
slouken@0
    79
int SDL_resizing = 0;
slouken@0
    80
int mouse_relative = 0;
slouken@0
    81
int posted = 0;
slouken@304
    82
#ifndef NO_CHANGEDISPLAYSETTINGS
slouken@1295
    83
DEVMODE SDL_desktop_mode;
slouken@304
    84
DEVMODE SDL_fullscreen_mode;
slouken@304
    85
#endif
slouken@338
    86
WORD *gamma_saved = NULL;
slouken@0
    87
slouken@0
    88
slouken@0
    89
/* Functions called by the message processing function */
icculus@1152
    90
LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL;
slouken@3992
    91
void (*WIN_Activate)(_THIS, BOOL active, BOOL iconic);
slouken@0
    92
void (*WIN_RealizePalette)(_THIS);
slouken@0
    93
void (*WIN_PaletteChanged)(_THIS, HWND window);
slouken@0
    94
void (*WIN_WinPAINT)(_THIS, HDC hdc);
slouken@338
    95
extern void DIB_SwapGamma(_THIS);
slouken@0
    96
slouken@1272
    97
#ifndef NO_GETKEYBOARDSTATE
icculus@5983
    98
#ifndef _WIN64
slouken@1253
    99
/* Variables and support functions for SDL_ToUnicode() */
slouken@1253
   100
static int codepage;
slouken@1253
   101
static int Is9xME();
slouken@1253
   102
static int GetCodePage();
icculus@5890
   103
static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, const BYTE *keystate, LPWSTR wchars, int wsize, UINT flags);
slouken@1253
   104
slouken@1253
   105
ToUnicodeFN SDL_ToUnicode = ToUnicode9xME;
icculus@5983
   106
#endif
slouken@1272
   107
#endif /* !NO_GETKEYBOARDSTATE */
slouken@1253
   108
slouken@1253
   109
icculus@1152
   110
#if defined(_WIN32_WCE)
icculus@1152
   111
slouken@4162
   112
//AdjustWindowRect is not available under WinCE 2003
slouken@4162
   113
#define AdjustWindowRect(a,b,c) (AdjustWindowRectEx((a),(b),(c),0))
slouken@4162
   114
icculus@1152
   115
// dynamically load aygshell dll because we want SDL to work on HPC and be300
icculus@1152
   116
HINSTANCE aygshell = NULL;
icculus@1152
   117
BOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0;
icculus@1152
   118
icculus@1152
   119
#define SHFS_SHOWTASKBAR            0x0001
icculus@1152
   120
#define SHFS_HIDETASKBAR            0x0002
icculus@1152
   121
#define SHFS_SHOWSIPBUTTON          0x0004
icculus@1152
   122
#define SHFS_HIDESIPBUTTON          0x0008
icculus@1152
   123
#define SHFS_SHOWSTARTICON          0x0010
icculus@1152
   124
#define SHFS_HIDESTARTICON          0x0020
icculus@1152
   125
icculus@1152
   126
static void LoadAygshell(void)
icculus@1152
   127
{
icculus@1152
   128
	if( !aygshell )
icculus@1152
   129
		 aygshell = SDL_LoadObject("aygshell.dll");
slouken@1497
   130
	if( (aygshell != 0) && (SHFullScreen == 0) )
icculus@1152
   131
	{
icculus@1152
   132
		SHFullScreen = (int (WINAPI *)(struct HWND__ *,unsigned long)) SDL_LoadFunction(aygshell, "SHFullScreen");
icculus@1152
   133
	}
icculus@1152
   134
}
icculus@1152
   135
icculus@1152
   136
#endif
icculus@1152
   137
slouken@1523
   138
/* JC 14 Mar 2006
slouken@1523
   139
   This is used all over the place, in the windib driver and in the dx5 driver
slouken@1523
   140
   So we may as well stick it here instead of having multiple copies scattered
slouken@1523
   141
   about
slouken@1523
   142
*/
slouken@1523
   143
void WIN_FlushMessageQueue()
slouken@1523
   144
{
slouken@1523
   145
	MSG  msg;
slouken@1523
   146
	while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) {
slouken@1523
   147
		if ( msg.message == WM_QUIT ) break;
slouken@1523
   148
		TranslateMessage( &msg );
slouken@1523
   149
		DispatchMessage( &msg );
slouken@1523
   150
	}
slouken@1523
   151
}
slouken@1523
   152
slouken@304
   153
static void SDL_RestoreGameMode(void)
slouken@304
   154
{
slouken@4162
   155
#ifdef _WIN32_WCE //Under ce we don't minimize, therefore no restore
slouken@4162
   156
	
slouken@4162
   157
#ifdef SDL_VIDEO_DRIVER_GAPI
slouken@1497
   158
	SDL_VideoDevice *this = current_video;
slouken@1497
   159
	if(SDL_strcmp(this->name, "gapi") == 0)
slouken@1497
   160
	{
slouken@4162
   161
		if( this->hidden->gapiInfo->suspended )
slouken@1497
   162
		{
slouken@4162
   163
			this->hidden->gapiInfo->suspended = 0;
slouken@1497
   164
		}
slouken@1497
   165
	}
slouken@4162
   166
#endif
slouken@4162
   167
	
slouken@1497
   168
#else
slouken@1465
   169
	ShowWindow(SDL_Window, SW_RESTORE);
slouken@1497
   170
#endif
slouken@1497
   171
slouken@304
   172
#ifndef NO_CHANGEDISPLAYSETTINGS
slouken@1465
   173
#ifndef _WIN32_WCE
slouken@304
   174
	ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN);
slouken@304
   175
#endif
slouken@1465
   176
#endif /* NO_CHANGEDISPLAYSETTINGS */
slouken@304
   177
}
slouken@304
   178
static void SDL_RestoreDesktopMode(void)
slouken@304
   179
{
slouken@1497
   180
slouken@1497
   181
#ifdef _WIN32_WCE
slouken@4162
   182
	
slouken@4162
   183
#ifdef SDL_VIDEO_DRIVER_GAPI
slouken@1497
   184
	SDL_VideoDevice *this = current_video;
slouken@1497
   185
	if(SDL_strcmp(this->name, "gapi") == 0)
slouken@1497
   186
	{
slouken@4162
   187
		if( !this->hidden->gapiInfo->suspended )
slouken@1497
   188
		{
slouken@4162
   189
			this->hidden->gapiInfo->suspended = 1;
slouken@1497
   190
		}
slouken@1497
   191
	}
slouken@4162
   192
#endif
slouken@4162
   193
	
slouken@1497
   194
#else
slouken@1497
   195
	/* WinCE does not have a taskbar, so minimizing is not convenient */
slouken@1465
   196
	ShowWindow(SDL_Window, SW_MINIMIZE);
slouken@1497
   197
#endif
slouken@1497
   198
slouken@304
   199
#ifndef NO_CHANGEDISPLAYSETTINGS
slouken@1465
   200
#ifndef _WIN32_WCE
slouken@304
   201
	ChangeDisplaySettings(NULL, 0);
slouken@304
   202
#endif
slouken@1465
   203
#endif /* NO_CHANGEDISPLAYSETTINGS */
slouken@304
   204
}
slouken@304
   205
slouken@0
   206
#ifdef WM_MOUSELEAVE
slouken@0
   207
/* 
slouken@0
   208
   Special code to handle mouse leave events - this sucks...
slouken@0
   209
   http://support.microsoft.com/support/kb/articles/q183/1/07.asp
slouken@0
   210
slouken@0
   211
   TrackMouseEvent() is only available on Win98 and WinNT.
slouken@0
   212
   _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32
slouken@0
   213
   development environment, and only works on systems that have had IE 3.0
slouken@0
   214
   or newer installed on them (which is not the case with the base Win95).
slouken@0
   215
   Therefore, we implement our own version of _TrackMouseEvent() which
slouken@0
   216
   uses our own implementation if TrackMouseEvent() is not available.
slouken@0
   217
*/
slouken@0
   218
static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL;
slouken@0
   219
slouken@0
   220
static VOID CALLBACK
slouken@0
   221
TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
slouken@0
   222
{
icculus@5988
   223
	union { RECT rect; POINT pt; } rectpt;  /* prevent type-punning issue. */
slouken@0
   224
	POINT pt;
slouken@0
   225
icculus@5988
   226
	GetClientRect(hWnd, &rectpt.rect);
icculus@5988
   227
	MapWindowPoints(hWnd, NULL, &rectpt.pt, 2);
slouken@0
   228
	GetCursorPos(&pt);
icculus@5988
   229
	if ( !PtInRect(&rectpt.rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
slouken@0
   230
		if ( !KillTimer(hWnd, idEvent) ) {
slouken@0
   231
			/* Error killing the timer! */
slouken@0
   232
		}
slouken@0
   233
		PostMessage(hWnd, WM_MOUSELEAVE, 0, 0);
slouken@0
   234
	}
slouken@0
   235
}
slouken@0
   236
static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme)
slouken@0
   237
{
slouken@0
   238
	if ( ptme->dwFlags == TME_LEAVE ) {
slouken@0
   239
		return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100,
slouken@1456
   240
		                (TIMERPROC)TrackMouseTimerProc) != 0;
slouken@0
   241
	}
slouken@0
   242
	return FALSE;
slouken@0
   243
}
slouken@0
   244
#endif /* WM_MOUSELEAVE */
slouken@0
   245
slouken@145
   246
/* The main Win32 event handler
slouken@145
   247
DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it
slouken@145
   248
*/
slouken@1456
   249
LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
slouken@0
   250
{
slouken@0
   251
	SDL_VideoDevice *this = current_video;
slouken@0
   252
	static int mouse_pressed = 0;
slouken@0
   253
#ifdef WMMSG_DEBUG
slouken@0
   254
	fprintf(stderr, "Received windows message:  ");
slouken@0
   255
	if ( msg > MAX_WMMSG ) {
slouken@0
   256
		fprintf(stderr, "%d", msg);
slouken@0
   257
	} else {
slouken@0
   258
		fprintf(stderr, "%s", wmtab[msg]);
slouken@0
   259
	}
slouken@0
   260
	fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam);
slouken@0
   261
#endif
slouken@0
   262
	switch (msg) {
slouken@0
   263
slouken@0
   264
		case WM_ACTIVATE: {
slouken@0
   265
			SDL_VideoDevice *this = current_video;
slouken@3992
   266
			BOOL active, minimized;
slouken@0
   267
			Uint8 appstate;
slouken@0
   268
slouken@0
   269
			minimized = HIWORD(wParam);
slouken@3992
   270
			active = (LOWORD(wParam) != WA_INACTIVE) && !minimized;
slouken@3992
   271
			if ( active ) {
slouken@0
   272
				/* Gain the following states */
slouken@0
   273
				appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
slouken@4391
   274
				if ( !(SDL_GetAppState() & SDL_APPINPUTFOCUS) ) {
slouken@4391
   275
					if ( this->input_grab != SDL_GRAB_OFF ) {
slouken@4391
   276
						WIN_GrabInput(this, SDL_GRAB_ON);
slouken@4391
   277
					}
slouken@338
   278
					if ( ! DDRAW_FULLSCREEN() ) {
slouken@338
   279
						DIB_SwapGamma(this);
slouken@338
   280
					}
slouken@304
   281
					if ( WINDIB_FULLSCREEN() ) {
slouken@304
   282
						SDL_RestoreGameMode();
slouken@304
   283
					}
slouken@0
   284
				}
icculus@1152
   285
#if defined(_WIN32_WCE)
slouken@3992
   286
				if ( WINDIB_FULLSCREEN() ) {
slouken@3992
   287
					LoadAygshell();
slouken@3992
   288
					if( SHFullScreen )
slouken@3992
   289
						SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON);
slouken@3992
   290
					else
slouken@3992
   291
						ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE);
slouken@3992
   292
				}
icculus@1152
   293
#endif
slouken@0
   294
				posted = SDL_PrivateAppActive(1, appstate);
slouken@0
   295
			} else {
slouken@0
   296
				/* Lose the following states */
slouken@0
   297
				appstate = SDL_APPINPUTFOCUS;
slouken@0
   298
				if ( minimized ) {
slouken@0
   299
					appstate |= SDL_APPACTIVE;
slouken@0
   300
				}
slouken@4391
   301
slouken@0
   302
				if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
slouken@4391
   303
					if ( this->input_grab != SDL_GRAB_OFF ) {
slouken@4391
   304
						WIN_GrabInput(this, SDL_GRAB_OFF);
slouken@4391
   305
					}
slouken@338
   306
					if ( ! DDRAW_FULLSCREEN() ) {
slouken@338
   307
						DIB_SwapGamma(this);
slouken@338
   308
					}
slouken@304
   309
					if ( WINDIB_FULLSCREEN() ) {
slouken@4391
   310
						appstate |= SDL_APPMOUSEFOCUS;
slouken@304
   311
						SDL_RestoreDesktopMode();
slouken@6110
   312
						/* A fullscreen app gets hidden but will not get a minimize event */
slouken@6110
   313
						appstate |= (SDL_APPACTIVE | SDL_APPMOUSEFOCUS);
icculus@1152
   314
#if defined(_WIN32_WCE)
icculus@1152
   315
						LoadAygshell();
slouken@1497
   316
						if( SHFullScreen ) 
icculus@1152
   317
							SHFullScreen(SDL_Window, SHFS_SHOWSTARTICON|SHFS_SHOWTASKBAR|SHFS_SHOWSIPBUTTON);
icculus@1152
   318
						else
icculus@1152
   319
							ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOW);
icculus@1152
   320
#endif
slouken@304
   321
					}
slouken@0
   322
				}
slouken@0
   323
				posted = SDL_PrivateAppActive(0, appstate);
slouken@0
   324
			}
slouken@3992
   325
			WIN_Activate(this, active, minimized);
slouken@0
   326
			return(0);
slouken@0
   327
		}
slouken@0
   328
		break;
slouken@0
   329
slouken@0
   330
		case WM_MOUSEMOVE: {
slouken@0
   331
slouken@4169
   332
#ifdef WM_MOUSELEAVE
slouken@4391
   333
			if ( SDL_VideoSurface ) {
slouken@0
   334
				/* mouse has entered the window */
slouken@4169
   335
slouken@4169
   336
				if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
slouken@0
   337
					TRACKMOUSEEVENT tme;
slouken@0
   338
slouken@0
   339
					tme.cbSize = sizeof(tme);
slouken@0
   340
					tme.dwFlags = TME_LEAVE;
slouken@0
   341
					tme.hwndTrack = SDL_Window;
slouken@0
   342
					_TrackMouseEvent(&tme);
slouken@0
   343
				}
slouken@0
   344
			}
slouken@4169
   345
#endif /* WM_MOUSELEAVE */
slouken@4169
   346
slouken@4169
   347
			/* Mouse motion is handled in DIB_PumpEvents or
slouken@4169
   348
			 * DX5_PumpEvents, depending on the video driver
slouken@4169
   349
			 * in use */
slouken@4169
   350
slouken@4169
   351
			posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
slouken@0
   352
		}
slouken@0
   353
		return(0);
slouken@0
   354
slouken@0
   355
#ifdef WM_MOUSELEAVE
slouken@0
   356
		case WM_MOUSELEAVE: {
slouken@0
   357
slouken@4391
   358
			if ( SDL_VideoSurface ) {
slouken@0
   359
				/* mouse has left the window */
slouken@0
   360
				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
slouken@0
   361
			}
slouken@0
   362
		}
slouken@0
   363
		return(0);
slouken@0
   364
#endif /* WM_MOUSELEAVE */
slouken@0
   365
slouken@0
   366
		case WM_LBUTTONDOWN:
slouken@0
   367
		case WM_LBUTTONUP:
slouken@0
   368
		case WM_MBUTTONDOWN:
slouken@0
   369
		case WM_MBUTTONUP:
slouken@0
   370
		case WM_RBUTTONDOWN:
icculus@3970
   371
		case WM_RBUTTONUP:
icculus@3970
   372
		case WM_XBUTTONDOWN:
icculus@3970
   373
		case WM_XBUTTONUP: {
slouken@0
   374
			/* Mouse is handled by DirectInput when fullscreen */
slouken@4167
   375
			if ( SDL_VideoSurface && ! DINPUT() ) {
icculus@3970
   376
				WORD xbuttonval = 0;
slouken@0
   377
				Uint8 button, state;
slouken@5170
   378
                int x, y;
slouken@0
   379
slouken@145
   380
				/* DJM:
slouken@145
   381
				   We want the SDL window to take focus so that
slouken@145
   382
				   it acts like a normal windows "component"
slouken@145
   383
				   (e.g. gains keyboard focus on a mouse click).
slouken@145
   384
				 */
slouken@145
   385
				SetFocus(SDL_Window);
slouken@145
   386
slouken@0
   387
				/* Figure out which button to use */
slouken@0
   388
				switch (msg) {
slouken@0
   389
					case WM_LBUTTONDOWN:
slouken@457
   390
						button = SDL_BUTTON_LEFT;
slouken@0
   391
						state = SDL_PRESSED;
slouken@0
   392
						break;
slouken@0
   393
					case WM_LBUTTONUP:
slouken@457
   394
						button = SDL_BUTTON_LEFT;
slouken@0
   395
						state = SDL_RELEASED;
slouken@0
   396
						break;
slouken@0
   397
					case WM_MBUTTONDOWN:
slouken@457
   398
						button = SDL_BUTTON_MIDDLE;
slouken@0
   399
						state = SDL_PRESSED;
slouken@0
   400
						break;
slouken@0
   401
					case WM_MBUTTONUP:
slouken@457
   402
						button = SDL_BUTTON_MIDDLE;
slouken@0
   403
						state = SDL_RELEASED;
slouken@0
   404
						break;
slouken@0
   405
					case WM_RBUTTONDOWN:
slouken@457
   406
						button = SDL_BUTTON_RIGHT;
slouken@0
   407
						state = SDL_PRESSED;
slouken@0
   408
						break;
slouken@0
   409
					case WM_RBUTTONUP:
slouken@457
   410
						button = SDL_BUTTON_RIGHT;
slouken@0
   411
						state = SDL_RELEASED;
slouken@0
   412
						break;
icculus@3970
   413
					case WM_XBUTTONDOWN:
icculus@3970
   414
						xbuttonval = GET_XBUTTON_WPARAM(wParam);
slouken@4113
   415
						button = SDL_BUTTON_X1 + xbuttonval - 1;
icculus@3970
   416
						state = SDL_PRESSED;
icculus@3970
   417
						break;
icculus@3970
   418
					case WM_XBUTTONUP:
icculus@3970
   419
						xbuttonval = GET_XBUTTON_WPARAM(wParam);
slouken@4113
   420
						button = SDL_BUTTON_X1 + xbuttonval - 1;
icculus@3970
   421
						state = SDL_RELEASED;
icculus@3970
   422
						break;
slouken@0
   423
					default:
slouken@0
   424
						/* Eh? Unknown button? */
slouken@0
   425
						return(0);
slouken@0
   426
				}
slouken@0
   427
				if ( state == SDL_PRESSED ) {
slouken@0
   428
					/* Grab mouse so we get up events */
slouken@0
   429
					if ( ++mouse_pressed > 0 ) {
slouken@0
   430
						SetCapture(hwnd);
slouken@0
   431
					}
slouken@0
   432
				} else {
slouken@0
   433
					/* Release mouse after all up events */
slouken@0
   434
					if ( --mouse_pressed <= 0 ) {
slouken@0
   435
						ReleaseCapture();
slouken@0
   436
						mouse_pressed = 0;
slouken@0
   437
					}
slouken@0
   438
				}
slouken@5077
   439
				if ( mouse_relative ) {
slouken@5077
   440
				/*	RJR: March 28, 2000
slouken@5077
   441
					report internal mouse position if in relative mode */
slouken@5077
   442
					x = 0; y = 0;
slouken@5077
   443
				} else {
slouken@5077
   444
					x = (Sint16)LOWORD(lParam);
slouken@5077
   445
					y = (Sint16)HIWORD(lParam);
slouken@5077
   446
#ifdef _WIN32_WCE
slouken@5077
   447
					if (SDL_VideoSurface)
slouken@5077
   448
						GapiTransform(this->hidden->userOrientation,
slouken@5077
   449
this->hidden->hiresFix, &x, &y);
slouken@5077
   450
#endif
slouken@5077
   451
				}
slouken@0
   452
				posted = SDL_PrivateMouseButton(
slouken@5077
   453
							state, button, x, y);
icculus@3970
   454
icculus@3970
   455
				/*
icculus@3970
   456
				 * MSDN says:
icculus@3970
   457
				 *  "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP
icculus@3970
   458
				 *   messages, an application should return TRUE from [an 
icculus@3970
   459
				 *   XBUTTON message] if it processes it. Doing so will allow
icculus@3970
   460
				 *   software that simulates this message on Microsoft Windows
icculus@3970
   461
				 *   systems earlier than Windows 2000 to determine whether
icculus@3970
   462
				 *   the window procedure processed the message or called
icculus@3970
   463
				 *   DefWindowProc to process it.
icculus@3970
   464
				 */
icculus@3970
   465
				if (xbuttonval > 0)
icculus@3970
   466
					return(TRUE);
slouken@0
   467
			}
slouken@0
   468
		}
slouken@0
   469
		return(0);
slouken@0
   470
slouken@61
   471
slouken@61
   472
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
slouken@61
   473
		case WM_MOUSEWHEEL: 
slouken@4167
   474
			if ( SDL_VideoSurface && ! DINPUT() ) {
slouken@61
   475
				int move = (short)HIWORD(wParam);
slouken@162
   476
				if ( move ) {
slouken@162
   477
					Uint8 button;
slouken@162
   478
					if ( move > 0 )
slouken@451
   479
						button = SDL_BUTTON_WHEELUP;
slouken@162
   480
					else
slouken@451
   481
						button = SDL_BUTTON_WHEELDOWN;
slouken@61
   482
					posted = SDL_PrivateMouseButton(
slouken@162
   483
						SDL_PRESSED, button, 0, 0);
slouken@332
   484
					posted |= SDL_PrivateMouseButton(
slouken@332
   485
						SDL_RELEASED, button, 0, 0);
slouken@61
   486
				}
slouken@61
   487
			}
slouken@61
   488
			return(0);
slouken@61
   489
#endif
slouken@61
   490
slouken@0
   491
#ifdef WM_GETMINMAXINFO
slouken@0
   492
		/* This message is sent as a way for us to "check" the values
slouken@0
   493
		 * of a position change.  If we don't like it, we can adjust
slouken@0
   494
		 * the values before they are changed.
slouken@0
   495
		 */
slouken@0
   496
		case WM_GETMINMAXINFO: {
slouken@0
   497
			MINMAXINFO *info;
slouken@0
   498
			RECT        size;
slouken@0
   499
			int x, y;
slouken@565
   500
			int style;
slouken@0
   501
			int width;
slouken@0
   502
			int height;
slouken@0
   503
slouken@0
   504
			/* We don't want to clobber an internal resize */
slouken@0
   505
			if ( SDL_resizing )
slouken@0
   506
				return(0);
slouken@0
   507
slouken@0
   508
			/* We allow resizing with the SDL_RESIZABLE flag */
slouken@0
   509
			if ( SDL_PublicSurface &&
slouken@0
   510
				(SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
slouken@0
   511
				return(0);
slouken@0
   512
			}
slouken@0
   513
slouken@0
   514
			/* Get the current position of our window */
slouken@0
   515
			GetWindowRect(SDL_Window, &size);
slouken@0
   516
			x = size.left;
slouken@0
   517
			y = size.top;
slouken@0
   518
slouken@0
   519
			/* Calculate current width and height of our window */
slouken@0
   520
			size.top = 0;
slouken@0
   521
			size.left = 0;
slouken@0
   522
			if ( SDL_PublicSurface != NULL ) {
slouken@0
   523
				size.bottom = SDL_PublicSurface->h;
slouken@0
   524
				size.right = SDL_PublicSurface->w;
slouken@0
   525
			} else {
slouken@0
   526
				size.bottom = 0;
slouken@0
   527
				size.right = 0;
slouken@0
   528
			}
slouken@565
   529
slouken@565
   530
			/* DJM - according to the docs for GetMenu(), the
slouken@565
   531
			   return value is undefined if hwnd is a child window.
slouken@565
   532
			   Aparently it's too difficult for MS to check
slouken@565
   533
			   inside their function, so I have to do it here.
slouken@565
   534
          		 */
slouken@1480
   535
         		style = GetWindowLong(hwnd, GWL_STYLE);
slouken@565
   536
         		AdjustWindowRect(
slouken@565
   537
				&size,
slouken@565
   538
				style,
slouken@565
   539
            			style & WS_CHILDWINDOW ? FALSE
slouken@565
   540
						       : GetMenu(hwnd) != NULL);
slouken@565
   541
slouken@0
   542
			width = size.right - size.left;
slouken@0
   543
			height = size.bottom - size.top;
slouken@0
   544
slouken@0
   545
			/* Fix our size to the current size */
slouken@0
   546
			info = (MINMAXINFO *)lParam;
slouken@0
   547
			info->ptMaxSize.x = width;
slouken@0
   548
			info->ptMaxSize.y = height;
slouken@0
   549
			info->ptMaxPosition.x = x;
slouken@0
   550
			info->ptMaxPosition.y = y;
slouken@0
   551
			info->ptMinTrackSize.x = width;
slouken@0
   552
			info->ptMinTrackSize.y = height;
slouken@0
   553
			info->ptMaxTrackSize.x = width;
slouken@0
   554
			info->ptMaxTrackSize.y = height;
slouken@0
   555
		}
slouken@0
   556
		return(0);
slouken@0
   557
#endif /* WM_GETMINMAXINFO */
slouken@0
   558
slouken@4250
   559
		case WM_WINDOWPOSCHANGING: {
slouken@4250
   560
			WINDOWPOS *windowpos = (WINDOWPOS*)lParam;
slouken@4250
   561
slouken@4250
   562
			/* When menu is at the side or top, Windows likes
slouken@4250
   563
			   to try to reposition the fullscreen window when
slouken@4250
   564
			   changing video modes.
slouken@4250
   565
			 */
slouken@4250
   566
			if ( !SDL_resizing &&
slouken@4250
   567
			     SDL_PublicSurface &&
slouken@4250
   568
			     (SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
slouken@4250
   569
				windowpos->x = 0;
slouken@4250
   570
				windowpos->y = 0;
slouken@4250
   571
			}
slouken@4250
   572
		}
slouken@4250
   573
		return(0);
slouken@4250
   574
slouken@447
   575
		case WM_WINDOWPOSCHANGED: {
slouken@0
   576
			SDL_VideoDevice *this = current_video;
icculus@5988
   577
			POINT pt;
slouken@447
   578
			int w, h;
slouken@0
   579
slouken@0
   580
			GetClientRect(SDL_Window, &SDL_bounds);
icculus@5988
   581
icculus@5988
   582
			/* avoiding type-punning here... */
icculus@5988
   583
			pt.x = SDL_bounds.left;
icculus@5988
   584
			pt.y = SDL_bounds.top;
icculus@5988
   585
			ClientToScreen(SDL_Window, &pt);
icculus@5988
   586
			SDL_bounds.left = pt.x;
icculus@5988
   587
			SDL_bounds.top = pt.y;
icculus@5988
   588
icculus@5988
   589
			pt.x = SDL_bounds.right;
icculus@5988
   590
			pt.y = SDL_bounds.bottom;
icculus@5988
   591
			ClientToScreen(SDL_Window, &pt);
icculus@5988
   592
			SDL_bounds.right = pt.x;
icculus@5988
   593
			SDL_bounds.bottom = pt.y;
icculus@5988
   594
slouken@1291
   595
			if ( !SDL_resizing && !IsZoomed(SDL_Window) &&
slouken@1291
   596
			     SDL_PublicSurface &&
slouken@1291
   597
				!(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
slouken@1291
   598
				SDL_windowX = SDL_bounds.left;
slouken@1291
   599
				SDL_windowY = SDL_bounds.top;
slouken@1291
   600
			}
slouken@447
   601
			w = SDL_bounds.right-SDL_bounds.left;
slouken@447
   602
			h = SDL_bounds.bottom-SDL_bounds.top;
slouken@0
   603
			if ( this->input_grab != SDL_GRAB_OFF ) {
slouken@0
   604
				ClipCursor(&SDL_bounds);
slouken@0
   605
			}
slouken@447
   606
			if ( SDL_PublicSurface && 
slouken@0
   607
				(SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
slouken@447
   608
				SDL_PrivateResize(w, h);
slouken@0
   609
			}
slouken@0
   610
		}
slouken@0
   611
		break;
slouken@0
   612
slouken@0
   613
		/* We need to set the cursor */
slouken@0
   614
		case WM_SETCURSOR: {
slouken@0
   615
			Uint16 hittest;
slouken@0
   616
slouken@0
   617
			hittest = LOWORD(lParam);
slouken@0
   618
			if ( hittest == HTCLIENT ) {
slouken@0
   619
				SetCursor(SDL_hcursor);
slouken@0
   620
				return(TRUE);
slouken@0
   621
			}
slouken@0
   622
		}
slouken@0
   623
		break;
slouken@0
   624
slouken@0
   625
		/* We are about to get palette focus! */
slouken@0
   626
		case WM_QUERYNEWPALETTE: {
slouken@0
   627
			WIN_RealizePalette(current_video);
slouken@0
   628
			return(TRUE);
slouken@0
   629
		}
slouken@0
   630
		break;
slouken@0
   631
slouken@0
   632
		/* Another application changed the palette */
slouken@0
   633
		case WM_PALETTECHANGED: {
slouken@0
   634
			WIN_PaletteChanged(current_video, (HWND)wParam);
slouken@0
   635
		}
slouken@0
   636
		break;
slouken@0
   637
slouken@0
   638
		/* We were occluded, refresh our display */
slouken@0
   639
		case WM_PAINT: {
slouken@0
   640
			HDC hdc;
slouken@0
   641
			PAINTSTRUCT ps;
slouken@0
   642
slouken@0
   643
			hdc = BeginPaint(SDL_Window, &ps);
slouken@0
   644
			if ( current_video->screen &&
slouken@0
   645
			     !(current_video->screen->flags & SDL_OPENGL) ) {
slouken@0
   646
				WIN_WinPAINT(current_video, hdc);
slouken@0
   647
			}
slouken@0
   648
			EndPaint(SDL_Window, &ps);
slouken@0
   649
		}
slouken@0
   650
		return(0);
slouken@0
   651
slouken@145
   652
		/* DJM: Send an expose event in this case */
slouken@0
   653
		case WM_ERASEBKGND: {
slouken@145
   654
			posted = SDL_PrivateExpose();
slouken@0
   655
		}
slouken@145
   656
		return(0);
slouken@0
   657
slouken@0
   658
		case WM_CLOSE: {
slouken@0
   659
			if ( (posted = SDL_PrivateQuit()) )
slouken@0
   660
				PostQuitMessage(0);
slouken@0
   661
		}
slouken@0
   662
		return(0);
slouken@0
   663
slouken@0
   664
		case WM_DESTROY: {
slouken@0
   665
			PostQuitMessage(0);
slouken@0
   666
		}
slouken@0
   667
		return(0);
slouken@0
   668
slouken@1272
   669
#ifndef NO_GETKEYBOARDSTATE
icculus@5983
   670
		case WM_INPUTLANGCHANGE:
icculus@5983
   671
#ifndef _WIN64
slouken@1253
   672
			codepage = GetCodePage();
icculus@5983
   673
#endif
slouken@1253
   674
		return(TRUE);
slouken@1272
   675
#endif
slouken@1253
   676
slouken@0
   677
		default: {
slouken@0
   678
			/* Special handling by the video driver */
slouken@0
   679
			if (HandleMessage) {
slouken@0
   680
				return(HandleMessage(current_video,
slouken@0
   681
			                     hwnd, msg, wParam, lParam));
slouken@0
   682
			}
slouken@0
   683
		}
slouken@0
   684
		break;
slouken@0
   685
	}
slouken@0
   686
	return(DefWindowProc(hwnd, msg, wParam, lParam));
slouken@0
   687
}
slouken@0
   688
slouken@145
   689
/* Allow the application handle to be stored and retrieved later */
slouken@149
   690
static void *SDL_handle = NULL;
slouken@145
   691
slouken@149
   692
void SDL_SetModuleHandle(void *handle)
slouken@145
   693
{
slouken@145
   694
	SDL_handle = handle;
slouken@145
   695
}
slouken@149
   696
void *SDL_GetModuleHandle(void)
slouken@145
   697
{
slouken@145
   698
	void *handle;
slouken@145
   699
slouken@145
   700
	if ( SDL_handle ) {
slouken@145
   701
		handle = SDL_handle;
slouken@145
   702
	} else {
slouken@145
   703
		handle = GetModuleHandle(NULL);
slouken@145
   704
	}
slouken@145
   705
	return(handle);
slouken@145
   706
}
slouken@145
   707
slouken@0
   708
/* This allows the SDL_WINDOWID hack */
slouken@1280
   709
BOOL SDL_windowid = FALSE;
slouken@0
   710
icculus@1145
   711
static int app_registered = 0;
icculus@1145
   712
slouken@0
   713
/* Register the class for this application -- exported for winmain.c */
slouken@149
   714
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
slouken@0
   715
{
slouken@0
   716
	WNDCLASS class;
slouken@0
   717
#ifdef WM_MOUSELEAVE
slouken@0
   718
	HMODULE handle;
slouken@0
   719
#endif
slouken@0
   720
slouken@0
   721
	/* Only do this once... */
icculus@1145
   722
	if ( app_registered ) {
slouken@1498
   723
		++app_registered;
slouken@0
   724
		return(0);
slouken@0
   725
	}
slouken@0
   726
slouken@1288
   727
#ifndef CS_BYTEALIGNCLIENT
slouken@1288
   728
#define CS_BYTEALIGNCLIENT	0
slouken@1288
   729
#endif
slouken@1288
   730
	if ( ! name && ! SDL_Appname ) {
slouken@1288
   731
		name = "SDL_app";
slouken@1288
   732
		SDL_Appstyle = CS_BYTEALIGNCLIENT;
slouken@1288
   733
		SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
slouken@0
   734
	}
slouken@0
   735
slouken@1288
   736
	if ( name ) {
slouken@0
   737
#ifdef _WIN32_WCE
slouken@453
   738
		/* WinCE uses the UNICODE version */
slouken@1505
   739
		SDL_Appname = SDL_iconv_utf8_ucs2(name);
slouken@453
   740
#else
slouken@4007
   741
		SDL_Appname = SDL_iconv_utf8_locale(name);
slouken@1288
   742
#endif /* _WIN32_WCE */
slouken@1288
   743
		SDL_Appstyle = style;
slouken@1288
   744
		SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
slouken@453
   745
	}
slouken@1288
   746
slouken@1288
   747
	/* Register the application class */
slouken@1288
   748
	class.hCursor		= NULL;
slouken@1288
   749
	class.hIcon		= LoadImage(SDL_Instance, SDL_Appname,
slouken@1288
   750
				            IMAGE_ICON,
slouken@0
   751
	                                    0, 0, LR_DEFAULTCOLOR);
slouken@36
   752
	class.lpszMenuName	= NULL;
slouken@453
   753
	class.lpszClassName	= SDL_Appname;
slouken@0
   754
	class.hbrBackground	= NULL;
slouken@1288
   755
	class.hInstance		= SDL_Instance;
slouken@1288
   756
	class.style		= SDL_Appstyle;
slouken@1361
   757
#if SDL_VIDEO_OPENGL
slouken@0
   758
	class.style		|= CS_OWNDC;
slouken@0
   759
#endif
slouken@0
   760
	class.lpfnWndProc	= WinMessage;
slouken@0
   761
	class.cbWndExtra	= 0;
slouken@0
   762
	class.cbClsExtra	= 0;
slouken@0
   763
	if ( ! RegisterClass(&class) ) {
slouken@0
   764
		SDL_SetError("Couldn't register application class");
slouken@0
   765
		return(-1);
slouken@0
   766
	}
slouken@0
   767
slouken@0
   768
#ifdef WM_MOUSELEAVE
slouken@0
   769
	/* Get the version of TrackMouseEvent() we use */
slouken@0
   770
	_TrackMouseEvent = NULL;
slouken@0
   771
	handle = GetModuleHandle("USER32.DLL");
slouken@0
   772
	if ( handle ) {
slouken@0
   773
		_TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent");
slouken@0
   774
	}
slouken@0
   775
	if ( _TrackMouseEvent == NULL ) {
slouken@0
   776
		_TrackMouseEvent = WIN_TrackMouseEvent;
slouken@0
   777
	}
slouken@0
   778
#endif /* WM_MOUSELEAVE */
slouken@0
   779
slouken@1272
   780
#ifndef NO_GETKEYBOARDSTATE
icculus@5983
   781
#ifndef _WIN64
slouken@1253
   782
	/* Initialise variables for SDL_ToUnicode() */
slouken@1253
   783
	codepage = GetCodePage();
icculus@5897
   784
icculus@5897
   785
	/* Cygwin headers don't match windows.h, so we have to cast around a
icculus@5897
   786
	   const issue here... */
icculus@5898
   787
	SDL_ToUnicode = Is9xME() ? ToUnicode9xME : (ToUnicodeFN) ToUnicode;
slouken@1272
   788
#endif
icculus@5983
   789
#endif /* NO_GETKEYBOARDSTATE */
slouken@1253
   790
icculus@1145
   791
	app_registered = 1;
slouken@0
   792
	return(0);
slouken@0
   793
}
slouken@0
   794
slouken@1288
   795
/* Unregisters the windowclass registered in SDL_RegisterApp above. */
icculus@1150
   796
void SDL_UnregisterApp()
icculus@1145
   797
{
icculus@1145
   798
	WNDCLASS class;
icculus@1145
   799
icculus@1145
   800
	/* SDL_RegisterApp might not have been called before */
slouken@1498
   801
	if ( !app_registered ) {
slouken@1498
   802
		return;
slouken@1498
   803
	}
slouken@1498
   804
	--app_registered;
slouken@1498
   805
	if ( app_registered == 0 ) {
slouken@1288
   806
		/* Check for any registered window classes. */
slouken@1288
   807
		if ( GetClassInfo(SDL_Instance, SDL_Appname, &class) ) {
icculus@1145
   808
			UnregisterClass(SDL_Appname, SDL_Instance);
icculus@1145
   809
		}
slouken@1498
   810
		SDL_free(SDL_Appname);
slouken@1498
   811
		SDL_Appname = NULL;
icculus@1145
   812
	}
icculus@1145
   813
}
icculus@1145
   814
slouken@1272
   815
#ifndef NO_GETKEYBOARDSTATE
icculus@5983
   816
#ifndef _WIN64
slouken@1253
   817
/* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */
slouken@1253
   818
slouken@1253
   819
static int Is9xME()
slouken@1253
   820
{
slouken@1253
   821
	OSVERSIONINFO   info;
slouken@1253
   822
slouken@1336
   823
	SDL_memset(&info, 0, sizeof(info));
slouken@1253
   824
	info.dwOSVersionInfoSize = sizeof(info);
slouken@1253
   825
	if (!GetVersionEx(&info)) {
slouken@1253
   826
		return 0;
slouken@1253
   827
	}
slouken@1253
   828
	return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
slouken@1253
   829
}
slouken@1253
   830
slouken@1253
   831
static int GetCodePage()
slouken@1253
   832
{
slouken@1253
   833
	char	buff[8];
slouken@1253
   834
	int	lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT);
slouken@1253
   835
	int	cp = GetACP();
slouken@1253
   836
slouken@1253
   837
	if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) {
slouken@1341
   838
		cp = SDL_atoi(buff);
slouken@1253
   839
	}
slouken@1253
   840
	return cp;
slouken@1253
   841
}
slouken@1253
   842
icculus@5891
   843
static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, const BYTE *keystate, LPWSTR wchars, int wsize, UINT flags)
slouken@1253
   844
{
slouken@1253
   845
	BYTE	chars[2];
slouken@1253
   846
icculus@5892
   847
	/* arg #3 should be const BYTE *, but cygwin lists it as PBYTE. */
icculus@5892
   848
	if (ToAsciiEx(vkey, scancode, (PBYTE) keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) {
icculus@5988
   849
		return MultiByteToWideChar(codepage, 0, (LPCSTR) chars, 1, wchars, wsize);
slouken@1253
   850
	}
slouken@1253
   851
	return 0;
slouken@1253
   852
}
icculus@5983
   853
#endif
slouken@1272
   854
#endif /* !NO_GETKEYBOARDSTATE */