src/video/windib/SDL_dibevents.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Sep 2009 09:58:43 +0000
branchSDL-1.2
changeset 4220 cf958451fd8d
parent 4219 0a7481888fd1
child 4232 29605c881b29
permissions -rw-r--r--
Fixed bug #795 Andrey 2009-09-14 21:16:53 PDT WinCE GetCursorPos fixed I'm using iPAQ HP rx5919, with Windows Mobile 5. And I also use mingw32ce 0.59.1 toolchain. I fixed this, see attachment patch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 4139
diff changeset
     3
    Copyright (C) 1997-2009 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1303
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1303
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1303
diff changeset
    13
    Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1303
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1303
diff changeset
    16
    License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1303
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    19
    Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 145
diff changeset
    20
    slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    21
*/
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1379
diff changeset
    22
#include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    23
1433
bb6839704ed6 SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    24
#define WIN32_LEAN_AND_MEAN
bb6839704ed6 SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    25
#include <windows.h>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
    27
#include "SDL_main.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    28
#include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    29
#include "SDL_syswm.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    30
#include "../../events/SDL_sysevents.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    31
#include "../../events/SDL_events_c.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    32
#include "../wincommon/SDL_lowvideo.h"
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    33
#include "SDL_gapidibvideo.h"
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    34
#include "SDL_vkeys.h"
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    35
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    36
#ifdef SDL_VIDEO_DRIVER_GAPI
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    37
#include "../gapi/SDL_gapivideo.h"
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    38
#endif
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    39
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    40
#ifdef SDL_VIDEO_DRIVER_WINDIB
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    41
#include "SDL_dibvideo.h"
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    42
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    43
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    44
#ifndef WM_APP
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    45
#define WM_APP	0x8000
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    46
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    47
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    48
#ifdef _WIN32_WCE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    49
#define NO_GETKEYBOARDSTATE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    50
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    51
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    52
/* The translation table from a Microsoft VK keysym to a SDL keysym */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    53
static SDLKey VK_keymap[SDLK_LAST];
1472
4aac8563c296 Fixed more Win64 portability issues
Sam Lantinga <slouken@libsdl.org>
parents: 1456
diff changeset
    54
static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed);
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    55
static SDLKey Arrows_keymap[4];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    56
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    57
/* Masks for processing the windows KEYDOWN and KEYUP messages */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    58
#define REPEATED_KEYMASK	(1<<30)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    59
#define EXTENDED_KEYMASK	(1<<24)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    60
145
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
    61
/* DJM: If the user setup the window for us, we want to save his window proc,
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
    62
   and give him a chance to handle some messages. */
1303
52b5afd7ecee Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents: 1288
diff changeset
    63
#ifdef STRICT
52b5afd7ecee Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents: 1288
diff changeset
    64
#define WNDPROCTYPE	WNDPROC
52b5afd7ecee Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents: 1288
diff changeset
    65
#else
52b5afd7ecee Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents: 1288
diff changeset
    66
#define WNDPROCTYPE	FARPROC
52b5afd7ecee Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents: 1288
diff changeset
    67
#endif
52b5afd7ecee Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents: 1288
diff changeset
    68
static WNDPROCTYPE userWindowProc = NULL;
145
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
    69
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    70
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    71
#ifdef SDL_VIDEO_DRIVER_GAPI
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    72
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    73
WPARAM rotateKey(WPARAM key,int direction) 
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    74
{
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    75
	if(direction ==0 ) return key;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    76
	
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    77
	switch (key) {
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    78
		case 0x26: /* up */
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    79
			return Arrows_keymap[(2 + direction) % 4];
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    80
		case 0x27: /* right */
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    81
			return Arrows_keymap[(1 + direction) % 4];
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    82
		case 0x28: /* down */
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    83
			return Arrows_keymap[direction % 4];
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    84
		case 0x25: /* left */
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
    85
			return Arrows_keymap[(3 + direction) % 4];
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    86
	}
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    87
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    88
	return key;
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    89
}
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
    90
4220
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
    91
static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y) {
4179
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
    92
    Sint16 rotatedX;
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
    93
    Sint16 rotatedY;
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
    94
4220
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
    95
    if(gapiInfo->userOrientation == SDL_ORIENTATION_UP &&
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
    96
       gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
    97
    {
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
    98
        rotatedX = *x;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
    99
        rotatedY = *y;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   100
        *x = rotatedX;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   101
        *y = rotatedY;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   102
     }
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   103
    else
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   104
    if(gapiInfo->userOrientation == SDL_ORIENTATION_RIGHT &&
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   105
       gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   106
    {
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   107
        rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   108
                    SDL_VideoSurface->format->BytesPerPixel))
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   109
                    + SDL_VideoSurface->w - *y;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   110
        rotatedY = *x;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   111
        *x = rotatedX;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   112
        *y = rotatedY;
4179
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   113
    }
4220
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   114
    else
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   115
    {
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   116
        rotatedX = SDL_VideoSurface->w - *y;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   117
        rotatedY = *x;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   118
        *y = rotatedY;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   119
        *x = rotatedX;
4179
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   120
    }
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   121
}
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   122
#endif 
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   123
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   124
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   125
/* The main Win32 event handler */
1456
84de7511f79f Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
   126
LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   127
{
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   128
	extern int posted;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   129
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   130
	switch (msg) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   131
		case WM_SYSKEYDOWN:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   132
		case WM_KEYDOWN: {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   133
			SDL_keysym keysym;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   134
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   135
#ifdef SDL_VIDEO_DRIVER_GAPI
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   136
			if(this->hidden->gapiInfo)
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   137
			{
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   138
				// Drop GAPI artefacts
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   139
				if (wParam == 0x84 || wParam == 0x5B)
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   140
					return 0;
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   141
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   142
				wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   143
			}
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   144
#endif 
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   145
			/* Ignore repeated keys */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   146
			if ( lParam&REPEATED_KEYMASK ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   147
				return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   148
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   149
			switch (wParam) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   150
				case VK_CONTROL:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   151
					if ( lParam&EXTENDED_KEYMASK )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   152
						wParam = VK_RCONTROL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   153
					else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   154
						wParam = VK_LCONTROL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   155
					break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   156
				case VK_SHIFT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   157
					/* EXTENDED trick doesn't work here */
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   158
					{
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   159
					Uint8 *state = SDL_GetKeyState(NULL);
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   160
					if (state[SDLK_LSHIFT] == SDL_RELEASED && (GetKeyState(VK_LSHIFT) & 0x8000)) {
558
2312d983e1fe Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents: 523
diff changeset
   161
						wParam = VK_LSHIFT;
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   162
					} else if (state[SDLK_RSHIFT] == SDL_RELEASED && (GetKeyState(VK_RSHIFT) & 0x8000)) {
558
2312d983e1fe Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents: 523
diff changeset
   163
						wParam = VK_RSHIFT;
2312d983e1fe Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents: 523
diff changeset
   164
					} else {
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   165
						/* Win9x */
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   166
						int sc = HIWORD(lParam) & 0xFF;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   167
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   168
						if (sc == 0x2A)
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   169
							wParam = VK_LSHIFT;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   170
						else
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   171
						if (sc == 0x36)
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   172
							wParam = VK_RSHIFT;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   173
						else
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   174
							wParam = VK_LSHIFT;
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   175
					}
558
2312d983e1fe Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents: 523
diff changeset
   176
					}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   177
					break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   178
				case VK_MENU:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   179
					if ( lParam&EXTENDED_KEYMASK )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   180
						wParam = VK_RMENU;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   181
					else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   182
						wParam = VK_LMENU;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   183
					break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   184
			}
112
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   185
#ifdef NO_GETKEYBOARDSTATE
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   186
			/* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   187
			if ( SDL_TranslateUNICODE ) {
140
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   188
				MSG m;
112
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   189
140
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   190
				m.hwnd = hwnd;
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   191
				m.message = msg;
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   192
				m.wParam = wParam;
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   193
				m.lParam = lParam;
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   194
				m.time = 0;
3c35d8f160bd Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 112
diff changeset
   195
				if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
112
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   196
					GetMessage(&m, hwnd, 0, WM_USER);
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   197
			    		wParam = m.wParam;
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   198
				}
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   199
			}
9ef74357a5fb Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents: 36
diff changeset
   200
#endif /* NO_GETKEYBOARDSTATE */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   201
			posted = SDL_PrivateKeyboard(SDL_PRESSED,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   202
				TranslateKey(wParam,HIWORD(lParam),&keysym,1));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   203
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   204
		return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   205
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   206
		case WM_SYSKEYUP:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   207
		case WM_KEYUP: {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   208
			SDL_keysym keysym;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   209
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   210
#ifdef SDL_VIDEO_DRIVER_GAPI
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   211
			if(this->hidden->gapiInfo)
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   212
			{
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   213
				// Drop GAPI artifacts
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   214
				if (wParam == 0x84 || wParam == 0x5B)
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   215
					return 0;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   216
	
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   217
				wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   218
			}
1251
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   219
#endif
86d0d01290ea Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents: 1152
diff changeset
   220
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   221
			switch (wParam) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   222
				case VK_CONTROL:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   223
					if ( lParam&EXTENDED_KEYMASK )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   224
						wParam = VK_RCONTROL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   225
					else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   226
						wParam = VK_LCONTROL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   227
					break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   228
				case VK_SHIFT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   229
					/* EXTENDED trick doesn't work here */
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   230
					{
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   231
					Uint8 *state = SDL_GetKeyState(NULL);
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   232
					if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
572
4c740ee76027 Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents: 558
diff changeset
   233
						wParam = VK_LSHIFT;
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   234
					} else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
572
4c740ee76027 Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents: 558
diff changeset
   235
						wParam = VK_RSHIFT;
4c740ee76027 Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents: 558
diff changeset
   236
					} else {
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   237
						/* Win9x */
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   238
						int sc = HIWORD(lParam) & 0xFF;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   239
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   240
						if (sc == 0x2A)
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   241
							wParam = VK_LSHIFT;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   242
						else
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   243
						if (sc == 0x36)
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   244
							wParam = VK_RSHIFT;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   245
						else
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   246
							wParam = VK_LSHIFT;
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1280
diff changeset
   247
					}
572
4c740ee76027 Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents: 558
diff changeset
   248
					}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   249
					break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   250
				case VK_MENU:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   251
					if ( lParam&EXTENDED_KEYMASK )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   252
						wParam = VK_RMENU;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   253
					else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   254
						wParam = VK_LMENU;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   255
					break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   256
			}
1526
89f90f32f6c0 Fixed bug #124
Sam Lantinga <slouken@libsdl.org>
parents: 1523
diff changeset
   257
			/* Windows only reports keyup for print screen */
89f90f32f6c0 Fixed bug #124
Sam Lantinga <slouken@libsdl.org>
parents: 1523
diff changeset
   258
			if ( wParam == VK_SNAPSHOT && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED ) {
89f90f32f6c0 Fixed bug #124
Sam Lantinga <slouken@libsdl.org>
parents: 1523
diff changeset
   259
				posted = SDL_PrivateKeyboard(SDL_PRESSED,
89f90f32f6c0 Fixed bug #124
Sam Lantinga <slouken@libsdl.org>
parents: 1523
diff changeset
   260
					TranslateKey(wParam,HIWORD(lParam),&keysym,1));
89f90f32f6c0 Fixed bug #124
Sam Lantinga <slouken@libsdl.org>
parents: 1523
diff changeset
   261
			}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   262
			posted = SDL_PrivateKeyboard(SDL_RELEASED,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   263
				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   264
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   265
		return(0);
726
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   266
#if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   267
		case WM_SYSCOMMAND: {
3981
b0d021cf41b6 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.
Ryan C. Gordon <icculus@icculus.org>
parents: 3868
diff changeset
   268
			const DWORD val = (DWORD) (wParam & 0xFFF0);
b0d021cf41b6 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.
Ryan C. Gordon <icculus@icculus.org>
parents: 3868
diff changeset
   269
			if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   270
				if (this->hidden->dibInfo && !allow_screensaver) {
3981
b0d021cf41b6 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.
Ryan C. Gordon <icculus@icculus.org>
parents: 3868
diff changeset
   271
					/* Note that this doesn't stop anything on Vista
b0d021cf41b6 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.
Ryan C. Gordon <icculus@icculus.org>
parents: 3868
diff changeset
   272
					   if the screensaver has a password. */
726
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   273
					return(0);
3981
b0d021cf41b6 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.
Ryan C. Gordon <icculus@icculus.org>
parents: 3868
diff changeset
   274
				}
b0d021cf41b6 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.
Ryan C. Gordon <icculus@icculus.org>
parents: 3868
diff changeset
   275
			}
726
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   276
		}
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   277
		/* Fall through to default processing */
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   278
#endif /* SC_SCREENSAVE && SC_MONITORPOWER */
5429a06aa816 SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   279
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   280
		default: {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   281
			/* Only post the event if we're watching for it */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   282
			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   283
			        SDL_SysWMmsg wmmsg;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   284
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   285
				SDL_VERSION(&wmmsg.version);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   286
				wmmsg.hwnd = hwnd;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   287
				wmmsg.msg = msg;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   288
				wmmsg.wParam = wParam;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   289
				wmmsg.lParam = lParam;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   290
				posted = SDL_PrivateSysWMEvent(&wmmsg);
145
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
   291
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
   292
			/* DJM: If the user isn't watching for private
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
   293
				messages in her SDL event loop, then pass it
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
   294
				along to any win32 specific window proc.
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
   295
			 */
29a638dc26db Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 140
diff changeset
   296
			} else if (userWindowProc) {
721
ab0656314eef Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 572
diff changeset
   297
				return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   298
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   299
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   300
		break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   301
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   302
	return(DefWindowProc(hwnd, msg, wParam, lParam));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   303
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   304
4220
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   305
#ifdef _WIN32_WCE
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   306
static BOOL GetLastStylusPos(POINT* ptLast)
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   307
{
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   308
    BOOL bResult = FALSE;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   309
    UINT nRet;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   310
    GetMouseMovePoints(ptLast, 1, &nRet);
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   311
    if ( nRet == 1 ) {
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   312
        ptLast->x /= 4;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   313
        ptLast->y /= 4;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   314
        bResult = TRUE;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   315
    }
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   316
    return bResult;
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   317
}
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   318
#endif
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   319
4179
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   320
static void DIB_GenerateMouseMotionEvent(_THIS)
4167
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   321
{
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   322
	extern int mouse_relative;
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   323
	extern int posted;
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   324
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   325
	POINT mouse;
4220
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   326
	if(!GetCursorPos( &mouse ) && !GetLastStylusPos( &mouse )) return;
4167
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   327
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   328
	if ( mouse_relative ) {
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   329
		POINT center;
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   330
		center.x = (SDL_VideoSurface->w/2);
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   331
		center.y = (SDL_VideoSurface->h/2);
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   332
		ClientToScreen(SDL_Window, &center);
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   333
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   334
		mouse.x -= (Sint16)center.x;
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   335
		mouse.y -= (Sint16)center.y;
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   336
		if ( mouse.x || mouse.y ) {
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   337
			SetCursorPos(center.x, center.y);
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   338
			posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y);
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   339
		}
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   340
	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   341
		ScreenToClient(SDL_Window, &mouse);
4179
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   342
#ifdef SDL_VIDEO_DRIVER_GAPI
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   343
       if (SDL_VideoSurface && this->hidden->gapiInfo)
4220
cf958451fd8d Fixed bug #795
Sam Lantinga <slouken@libsdl.org>
parents: 4219
diff changeset
   344
			GapiTransform(this->hidden->gapiInfo, &mouse.x, &mouse.y);
4167
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   345
#endif
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   346
		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   347
	}
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   348
}
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   349
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   350
void DIB_PumpEvents(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   351
{
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   352
	MSG msg;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   353
523
c210010f50f4 Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents: 515
diff changeset
   354
	while ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
c210010f50f4 Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents: 515
diff changeset
   355
		if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   356
			DispatchMessage(&msg);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   357
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   358
	}
4167
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   359
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   360
	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
4179
d7294b7c732d Date: Fri, 24 Apr 2009 17:47:07 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 4170
diff changeset
   361
		DIB_GenerateMouseMotionEvent( this );
4167
a6f635e5eaa6 Fixed bug #611
Sam Lantinga <slouken@libsdl.org>
parents: 4162
diff changeset
   362
	}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   363
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   364
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   365
static HKL hLayoutUS = NULL;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   366
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   367
void DIB_InitOSKeymap(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   368
{
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   369
	int	i;
3868
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   370
#ifndef _WIN32_WCE
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   371
	char	current_layout[KL_NAMELENGTH];
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   372
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   373
	GetKeyboardLayoutName(current_layout);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   374
	//printf("Initial Keyboard Layout Name: '%s'\n", current_layout);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   375
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   376
	hLayoutUS = LoadKeyboardLayout("00000409", KLF_NOTELLSHELL);
3868
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   377
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   378
	if (!hLayoutUS) {
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   379
		//printf("Failed to load US keyboard layout. Using current.\n");
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   380
		hLayoutUS = GetKeyboardLayout(0);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   381
	}
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   382
	LoadKeyboardLayout(current_layout, KLF_ACTIVATE);
3868
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   383
#else
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   384
#if _WIN32_WCE >=420
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   385
	TCHAR	current_layout[KL_NAMELENGTH];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   386
3868
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   387
	GetKeyboardLayoutName(current_layout);
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   388
	//printf("Initial Keyboard Layout Name: '%s'\n", current_layout);
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   389
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   390
	hLayoutUS = LoadKeyboardLayout(L"00000409", 0);
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   391
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   392
	if (!hLayoutUS) {
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   393
		//printf("Failed to load US keyboard layout. Using current.\n");
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   394
		hLayoutUS = GetKeyboardLayout(0);
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   395
	}
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   396
	LoadKeyboardLayout(current_layout, 0);
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   397
#endif // _WIN32_WCE >=420
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   398
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   399
	/* Map the VK keysyms */
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
   400
	for ( i=0; i<SDL_arraysize(VK_keymap); ++i )
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   401
		VK_keymap[i] = SDLK_UNKNOWN;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   402
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   403
	VK_keymap[VK_BACK] = SDLK_BACKSPACE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   404
	VK_keymap[VK_TAB] = SDLK_TAB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   405
	VK_keymap[VK_CLEAR] = SDLK_CLEAR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   406
	VK_keymap[VK_RETURN] = SDLK_RETURN;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   407
	VK_keymap[VK_PAUSE] = SDLK_PAUSE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   408
	VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   409
	VK_keymap[VK_SPACE] = SDLK_SPACE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   410
	VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   411
	VK_keymap[VK_COMMA] = SDLK_COMMA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   412
	VK_keymap[VK_MINUS] = SDLK_MINUS;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   413
	VK_keymap[VK_PERIOD] = SDLK_PERIOD;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   414
	VK_keymap[VK_SLASH] = SDLK_SLASH;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   415
	VK_keymap[VK_0] = SDLK_0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   416
	VK_keymap[VK_1] = SDLK_1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   417
	VK_keymap[VK_2] = SDLK_2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   418
	VK_keymap[VK_3] = SDLK_3;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   419
	VK_keymap[VK_4] = SDLK_4;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   420
	VK_keymap[VK_5] = SDLK_5;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   421
	VK_keymap[VK_6] = SDLK_6;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   422
	VK_keymap[VK_7] = SDLK_7;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   423
	VK_keymap[VK_8] = SDLK_8;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   424
	VK_keymap[VK_9] = SDLK_9;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   425
	VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   426
	VK_keymap[VK_EQUALS] = SDLK_EQUALS;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   427
	VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   428
	VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
1253
7c7ddaf195bf Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents: 1251
diff changeset
   429
	VK_keymap[VK_OEM_102] = SDLK_LESS;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   430
	VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   431
	VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
327
13fc64213765 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   432
	VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   433
	VK_keymap[VK_A] = SDLK_a;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   434
	VK_keymap[VK_B] = SDLK_b;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   435
	VK_keymap[VK_C] = SDLK_c;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   436
	VK_keymap[VK_D] = SDLK_d;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   437
	VK_keymap[VK_E] = SDLK_e;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   438
	VK_keymap[VK_F] = SDLK_f;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   439
	VK_keymap[VK_G] = SDLK_g;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   440
	VK_keymap[VK_H] = SDLK_h;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   441
	VK_keymap[VK_I] = SDLK_i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   442
	VK_keymap[VK_J] = SDLK_j;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   443
	VK_keymap[VK_K] = SDLK_k;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   444
	VK_keymap[VK_L] = SDLK_l;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   445
	VK_keymap[VK_M] = SDLK_m;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   446
	VK_keymap[VK_N] = SDLK_n;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   447
	VK_keymap[VK_O] = SDLK_o;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   448
	VK_keymap[VK_P] = SDLK_p;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   449
	VK_keymap[VK_Q] = SDLK_q;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   450
	VK_keymap[VK_R] = SDLK_r;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   451
	VK_keymap[VK_S] = SDLK_s;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   452
	VK_keymap[VK_T] = SDLK_t;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   453
	VK_keymap[VK_U] = SDLK_u;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   454
	VK_keymap[VK_V] = SDLK_v;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   455
	VK_keymap[VK_W] = SDLK_w;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   456
	VK_keymap[VK_X] = SDLK_x;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   457
	VK_keymap[VK_Y] = SDLK_y;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   458
	VK_keymap[VK_Z] = SDLK_z;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   459
	VK_keymap[VK_DELETE] = SDLK_DELETE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   460
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   461
	VK_keymap[VK_NUMPAD0] = SDLK_KP0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   462
	VK_keymap[VK_NUMPAD1] = SDLK_KP1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   463
	VK_keymap[VK_NUMPAD2] = SDLK_KP2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   464
	VK_keymap[VK_NUMPAD3] = SDLK_KP3;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   465
	VK_keymap[VK_NUMPAD4] = SDLK_KP4;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   466
	VK_keymap[VK_NUMPAD5] = SDLK_KP5;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   467
	VK_keymap[VK_NUMPAD6] = SDLK_KP6;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   468
	VK_keymap[VK_NUMPAD7] = SDLK_KP7;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   469
	VK_keymap[VK_NUMPAD8] = SDLK_KP8;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   470
	VK_keymap[VK_NUMPAD9] = SDLK_KP9;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   471
	VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   472
	VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   473
	VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   474
	VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   475
	VK_keymap[VK_ADD] = SDLK_KP_PLUS;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   476
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   477
	VK_keymap[VK_UP] = SDLK_UP;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   478
	VK_keymap[VK_DOWN] = SDLK_DOWN;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   479
	VK_keymap[VK_RIGHT] = SDLK_RIGHT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   480
	VK_keymap[VK_LEFT] = SDLK_LEFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   481
	VK_keymap[VK_INSERT] = SDLK_INSERT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   482
	VK_keymap[VK_HOME] = SDLK_HOME;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   483
	VK_keymap[VK_END] = SDLK_END;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   484
	VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   485
	VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   486
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   487
	VK_keymap[VK_F1] = SDLK_F1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   488
	VK_keymap[VK_F2] = SDLK_F2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   489
	VK_keymap[VK_F3] = SDLK_F3;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   490
	VK_keymap[VK_F4] = SDLK_F4;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   491
	VK_keymap[VK_F5] = SDLK_F5;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   492
	VK_keymap[VK_F6] = SDLK_F6;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   493
	VK_keymap[VK_F7] = SDLK_F7;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   494
	VK_keymap[VK_F8] = SDLK_F8;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   495
	VK_keymap[VK_F9] = SDLK_F9;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   496
	VK_keymap[VK_F10] = SDLK_F10;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   497
	VK_keymap[VK_F11] = SDLK_F11;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   498
	VK_keymap[VK_F12] = SDLK_F12;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   499
	VK_keymap[VK_F13] = SDLK_F13;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   500
	VK_keymap[VK_F14] = SDLK_F14;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   501
	VK_keymap[VK_F15] = SDLK_F15;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   502
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   503
	VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   504
	VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   505
	VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   506
	VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   507
	VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   508
	VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   509
	VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   510
	VK_keymap[VK_RMENU] = SDLK_RALT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   511
	VK_keymap[VK_LMENU] = SDLK_LALT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   512
	VK_keymap[VK_RWIN] = SDLK_RSUPER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   513
	VK_keymap[VK_LWIN] = SDLK_LSUPER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   514
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   515
	VK_keymap[VK_HELP] = SDLK_HELP;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   516
#ifdef VK_PRINT
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   517
	VK_keymap[VK_PRINT] = SDLK_PRINT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   518
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   519
	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   520
	VK_keymap[VK_CANCEL] = SDLK_BREAK;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   521
	VK_keymap[VK_APPS] = SDLK_MENU;
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   522
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   523
	Arrows_keymap[3] = 0x25;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   524
	Arrows_keymap[2] = 0x26;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   525
	Arrows_keymap[1] = 0x27;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   526
	Arrows_keymap[0] = 0x28;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   527
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   528
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   529
#define EXTKEYPAD(keypad) ((scancode & 0x100)?(mvke):(keypad))
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   530
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   531
static int SDL_MapVirtualKey(int scancode, int vkey)
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   532
{
3868
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   533
#ifndef _WIN32_WCE
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   534
	int	mvke  = MapVirtualKeyEx(scancode & 0xFF, 1, hLayoutUS);
3868
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   535
#else
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   536
	int	mvke  = MapVirtualKey(scancode & 0xFF, 1);
b2f59aadec0d Fixed bug #294
Sam Lantinga <slouken@libsdl.org>
parents: 1852
diff changeset
   537
#endif
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   538
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   539
	switch(vkey) {
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   540
		/* These are always correct */
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   541
		case VK_DIVIDE:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   542
		case VK_MULTIPLY:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   543
		case VK_SUBTRACT:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   544
		case VK_ADD:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   545
		case VK_LWIN:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   546
		case VK_RWIN:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   547
		case VK_APPS:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   548
		/* These are already handled */
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   549
		case VK_LCONTROL:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   550
		case VK_RCONTROL:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   551
		case VK_LSHIFT:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   552
		case VK_RSHIFT:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   553
		case VK_LMENU:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   554
		case VK_RMENU:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   555
		case VK_SNAPSHOT:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   556
		case VK_PAUSE:
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   557
			return vkey;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   558
	}	
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   559
	switch(mvke) {
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   560
		/* Distinguish between keypad and extended keys */
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   561
		case VK_INSERT: return EXTKEYPAD(VK_NUMPAD0);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   562
		case VK_DELETE: return EXTKEYPAD(VK_DECIMAL);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   563
		case VK_END:    return EXTKEYPAD(VK_NUMPAD1);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   564
		case VK_DOWN:   return EXTKEYPAD(VK_NUMPAD2);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   565
		case VK_NEXT:   return EXTKEYPAD(VK_NUMPAD3);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   566
		case VK_LEFT:   return EXTKEYPAD(VK_NUMPAD4);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   567
		case VK_CLEAR:  return EXTKEYPAD(VK_NUMPAD5);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   568
		case VK_RIGHT:  return EXTKEYPAD(VK_NUMPAD6);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   569
		case VK_HOME:   return EXTKEYPAD(VK_NUMPAD7);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   570
		case VK_UP:     return EXTKEYPAD(VK_NUMPAD8);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   571
		case VK_PRIOR:  return EXTKEYPAD(VK_NUMPAD9);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   572
	}
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   573
	return mvke?mvke:vkey;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   574
}
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   575
1472
4aac8563c296 Fixed more Win64 portability issues
Sam Lantinga <slouken@libsdl.org>
parents: 1456
diff changeset
   576
static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   577
{
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   578
	/* Set the keysym information */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   579
	keysym->scancode = (unsigned char) scancode;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   580
	keysym->mod = KMOD_NONE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   581
	keysym->unicode = 0;
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   582
	
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   583
	if ((vkey == VK_RETURN) && (scancode & 0x100)) {
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   584
		/* No VK_ code for the keypad enter key */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   585
		keysym->sym = SDLK_KP_ENTER;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   586
	}
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   587
	else {
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   588
		keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   589
	}
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   590
1253
7c7ddaf195bf Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents: 1251
diff changeset
   591
	if ( pressed && SDL_TranslateUNICODE ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   592
#ifdef NO_GETKEYBOARDSTATE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   593
		/* Uh oh, better hope the vkey is close enough.. */
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
   594
		if((keysym->sym == vkey) || (vkey > 0x7f))
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   595
		keysym->unicode = vkey;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   596
#else
1253
7c7ddaf195bf Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents: 1251
diff changeset
   597
		BYTE	keystate[256];
7c7ddaf195bf Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents: 1251
diff changeset
   598
		Uint16	wchars[2];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   599
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   600
		GetKeyboardState(keystate);
4170
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   601
		/* Numlock isn't taken into account in ToUnicode,
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   602
		 * so we handle it as a special case here */
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   603
		if ((keystate[VK_NUMLOCK] & 1) && vkey >= VK_NUMPAD0 && vkey <= VK_NUMPAD9)
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   604
		{
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   605
			keysym->unicode = vkey - VK_NUMPAD0 + '0';
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   606
		}
092c0bc69155 Fixed bug #618
Sam Lantinga <slouken@libsdl.org>
parents: 4167
diff changeset
   607
		else if (SDL_ToUnicode((UINT)vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) > 0)
1253
7c7ddaf195bf Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents: 1251
diff changeset
   608
		{
7c7ddaf195bf Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents: 1251
diff changeset
   609
			keysym->unicode = wchars[0];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   610
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   611
#endif /* NO_GETKEYBOARDSTATE */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   612
	}
1852
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   613
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   614
#if 0
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   615
	{
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   616
		HKL     hLayoutCurrent = GetKeyboardLayout(0);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   617
		int     sc = scancode & 0xFF;
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   618
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   619
		printf("SYM:%d, VK:0x%02X, SC:0x%04X, US:(1:0x%02X, 3:0x%02X), "
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   620
			"Current:(1:0x%02X, 3:0x%02X)\n",
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   621
			keysym->sym, vkey, scancode,
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   622
			MapVirtualKeyEx(sc, 1, hLayoutUS),
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   623
			MapVirtualKeyEx(sc, 3, hLayoutUS),
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   624
			MapVirtualKeyEx(sc, 1, hLayoutCurrent),
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   625
			MapVirtualKeyEx(sc, 3, hLayoutCurrent)
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   626
		);
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   627
	}
eb2d5480ae95 Try to keep SDL keysyms sane regardless of keyboard layout in windib target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1526
diff changeset
   628
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   629
	return(keysym);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   630
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   631
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   632
int DIB_CreateWindow(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   633
{
4219
0a7481888fd1 Fixed bug #695
Sam Lantinga <slouken@libsdl.org>
parents: 4179
diff changeset
   634
	char *windowid;
1152
51a8702d8ecd Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents: 1048
diff changeset
   635
1288
ea3888b472bf Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents: 1282
diff changeset
   636
	SDL_RegisterApp(NULL, 0, 0);
1280
f61f045343d3 Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents: 1264
diff changeset
   637
4219
0a7481888fd1 Fixed bug #695
Sam Lantinga <slouken@libsdl.org>
parents: 4179
diff changeset
   638
	windowid = SDL_getenv("SDL_WINDOWID");
1280
f61f045343d3 Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents: 1264
diff changeset
   639
	SDL_windowid = (windowid != NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   640
	if ( SDL_windowid ) {
1152
51a8702d8ecd Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents: 1048
diff changeset
   641
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
1280
f61f045343d3 Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents: 1264
diff changeset
   642
		/* wince 2.1 does not have strtol */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
   643
		wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
   644
		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1);
1280
f61f045343d3 Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents: 1264
diff changeset
   645
		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
   646
		SDL_free(windowid_t);
1152
51a8702d8ecd Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents: 1048
diff changeset
   647
#else
1456
84de7511f79f Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
   648
		SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
1152
51a8702d8ecd Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents: 1048
diff changeset
   649
#endif
974
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   650
		if ( SDL_Window == NULL ) {
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   651
			SDL_SetError("Couldn't get user specified window");
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   652
			return(-1);
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   653
		}
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   654
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   655
		/* DJM: we want all event's for the user specified
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   656
			window to be handled by SDL.
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   657
		 */
1472
4aac8563c296 Fixed more Win64 portability issues
Sam Lantinga <slouken@libsdl.org>
parents: 1456
diff changeset
   658
		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
4aac8563c296 Fixed more Win64 portability issues
Sam Lantinga <slouken@libsdl.org>
parents: 1456
diff changeset
   659
		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   660
	} else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   661
		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   662
                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
833
31fa08b36380 Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   663
                        CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   664
		if ( SDL_Window == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   665
			SDL_SetError("Couldn't create window");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   666
			return(-1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   667
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   668
		ShowWindow(SDL_Window, SW_HIDE);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   669
	}
1523
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   670
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   671
	/* JC 14 Mar 2006
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   672
		Flush the message loop or this can cause big problems later
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   673
		Especially if the user decides to use dialog boxes or assert()!
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   674
	*/
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   675
	WIN_FlushMessageQueue();
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   676
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   677
	return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   678
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   679
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   680
void DIB_DestroyWindow(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   681
{
974
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   682
	if ( SDL_windowid ) {
1472
4aac8563c296 Fixed more Win64 portability issues
Sam Lantinga <slouken@libsdl.org>
parents: 1456
diff changeset
   683
		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)userWindowProc);
974
b8427b5151ed Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents: 833
diff changeset
   684
	} else {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   685
		DestroyWindow(SDL_Window);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   686
	}
1288
ea3888b472bf Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents: 1282
diff changeset
   687
	SDL_UnregisterApp();
1523
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   688
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   689
	/* JC 14 Mar 2006
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   690
		Flush the message loop or this can cause big problems later
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   691
		Especially if the user decides to use dialog boxes or assert()!
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   692
	*/
21b1fbb53f4a (patch tweaked a bit)
Sam Lantinga <slouken@libsdl.org>
parents: 1480
diff changeset
   693
	WIN_FlushMessageQueue();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   694
}