author | Sam Lantinga <slouken@libsdl.org> |
Sun, 12 Mar 2006 00:57:50 +0000 | |
changeset 1498 | 3968f7cba10c |
parent 1497 | 420b3f47806d |
child 1505 | 4d005dfbb7f5 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
SDL - Simple DirectMedia Layer |
|
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
3 |
Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
|
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:
1295
diff
changeset
|
6 |
modify it under the terms of the GNU Lesser General Public |
0 | 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:
1295
diff
changeset
|
8 |
version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
|
10 |
This library is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
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:
1295
diff
changeset
|
13 |
Lesser General Public License for more details. |
0 | 14 |
|
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
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:
1295
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:
1295
diff
changeset
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
|
19 |
Sam Lantinga |
|
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
179
diff
changeset
|
20 |
slouken@libsdl.org |
0 | 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 | 23 |
|
1433
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
24 |
#define WIN32_LEAN_AND_MEAN |
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
25 |
#include <windows.h> |
0 | 26 |
|
27 |
#include "SDL_events.h" |
|
28 |
#include "SDL_video.h" |
|
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 "../SDL_sysvideo.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_sysevents.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 "../../events/SDL_events_c.h" |
0 | 33 |
#include "SDL_lowvideo.h" |
34 |
#include "SDL_syswm_c.h" |
|
35 |
#include "SDL_main.h" |
|
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
36 |
#include "SDL_loadso.h" |
0 | 37 |
|
38 |
#ifdef WMMSG_DEBUG |
|
39 |
#include "wmmsg.h" |
|
40 |
#endif |
|
41 |
||
42 |
#ifdef _WIN32_WCE |
|
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
43 |
#include "../gapi/SDL_gapivideo.h" |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
44 |
|
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
45 |
#define IsZoomed(HWND) 1 |
0 | 46 |
#define NO_GETKEYBOARDSTATE |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
47 |
#if _WIN32_WCE < 420 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
48 |
#define NO_CHANGEDISPLAYSETTINGS |
0 | 49 |
#endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
50 |
#endif |
0 | 51 |
|
52 |
/* The window we use for everything... */ |
|
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
53 |
#ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
54 |
LPWSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
55 |
#else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
56 |
LPSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
57 |
#endif |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
58 |
Uint32 SDL_Appstyle = 0; |
0 | 59 |
HINSTANCE SDL_Instance = NULL; |
60 |
HWND SDL_Window = NULL; |
|
61 |
RECT SDL_bounds = {0, 0, 0, 0}; |
|
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
829
diff
changeset
|
62 |
int SDL_windowX = 0; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
829
diff
changeset
|
63 |
int SDL_windowY = 0; |
0 | 64 |
int SDL_resizing = 0; |
65 |
int mouse_relative = 0; |
|
66 |
int posted = 0; |
|
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
67 |
#ifndef NO_CHANGEDISPLAYSETTINGS |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
68 |
DEVMODE SDL_desktop_mode; |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
69 |
DEVMODE SDL_fullscreen_mode; |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
70 |
#endif |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
71 |
WORD *gamma_saved = NULL; |
0 | 72 |
|
73 |
||
74 |
/* Functions called by the message processing function */ |
|
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
75 |
LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; |
0 | 76 |
void (*WIN_RealizePalette)(_THIS); |
77 |
void (*WIN_PaletteChanged)(_THIS, HWND window); |
|
78 |
void (*WIN_WinPAINT)(_THIS, HDC hdc); |
|
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
79 |
extern void DIB_SwapGamma(_THIS); |
0 | 80 |
|
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
81 |
#ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
82 |
/* Variables and support functions for SDL_ToUnicode() */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
83 |
static int codepage; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
84 |
static int Is9xME(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
85 |
static int GetCodePage(); |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
86 |
static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, BYTE *keystate, LPWSTR wchars, int wsize, UINT flags); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
87 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
88 |
ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
89 |
#endif /* !NO_GETKEYBOARDSTATE */ |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
90 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
91 |
|
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
92 |
#if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
93 |
|
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
94 |
// dynamically load aygshell dll because we want SDL to work on HPC and be300 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
95 |
HINSTANCE aygshell = NULL; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
96 |
BOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
97 |
|
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
98 |
#define SHFS_SHOWTASKBAR 0x0001 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
99 |
#define SHFS_HIDETASKBAR 0x0002 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
100 |
#define SHFS_SHOWSIPBUTTON 0x0004 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
101 |
#define SHFS_HIDESIPBUTTON 0x0008 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
102 |
#define SHFS_SHOWSTARTICON 0x0010 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
103 |
#define SHFS_HIDESTARTICON 0x0020 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
104 |
|
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
105 |
static void LoadAygshell(void) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
106 |
{ |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
107 |
if( !aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
108 |
aygshell = SDL_LoadObject("aygshell.dll"); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
109 |
if( (aygshell != 0) && (SHFullScreen == 0) ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
110 |
{ |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
111 |
SHFullScreen = (int (WINAPI *)(struct HWND__ *,unsigned long)) SDL_LoadFunction(aygshell, "SHFullScreen"); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
112 |
} |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
113 |
} |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
114 |
|
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
115 |
/* for gapi landscape mode */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
116 |
static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
117 |
Sint16 rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
118 |
Sint16 rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
119 |
|
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
120 |
if (hires) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
121 |
*x = *x * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
122 |
*y = *y * 2; |
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 |
|
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
125 |
switch(rotate) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
126 |
case SDL_ORIENTATION_UP: |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
127 |
{ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
128 |
/* this code needs testing on a real device! |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
129 |
So it will be enabled later */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
130 |
/* |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
131 |
#ifdef _WIN32_WCE |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
132 |
#if _WIN32_WCE >= 420 |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
133 |
// test device orientation |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
134 |
// FIXME: do not check every mouse message |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
135 |
DEVMODE settings; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
136 |
SDL_memset(&settings, 0, sizeof(DEVMODE)); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
137 |
settings.dmSize = sizeof(DEVMODE); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
138 |
settings.dmFields = DM_DISPLAYORIENTATION; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
139 |
ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
140 |
if( settings.dmOrientation == DMDO_90 ) |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
141 |
{ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
142 |
rotatedX = SDL_VideoSurface->h - *x; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
143 |
rotatedY = *y; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
144 |
*x = rotatedX; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
145 |
*y = rotatedY; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
146 |
} |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
147 |
#endif |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
148 |
#endif */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
149 |
} |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
150 |
break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
151 |
case SDL_ORIENTATION_RIGHT: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
152 |
if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
153 |
break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
154 |
rotatedX = SDL_VideoSurface->w - *y; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
155 |
rotatedY = *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
156 |
*x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
157 |
*y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
158 |
break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
159 |
case SDL_ORIENTATION_LEFT: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
160 |
if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
161 |
break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
162 |
rotatedX = *y; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
163 |
rotatedY = SDL_VideoSurface->h - *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
164 |
*x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
165 |
*y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
166 |
break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
167 |
} |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
168 |
} |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
169 |
|
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
170 |
#endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
171 |
|
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
172 |
static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
173 |
{ |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
174 |
#ifdef _WIN32_WCE |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
175 |
SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
176 |
if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
177 |
{ |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
178 |
if( this->hidden->suspended ) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
179 |
{ |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
180 |
this->hidden->suspended = 0; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
181 |
} |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
182 |
} |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
183 |
#else |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
184 |
ShowWindow(SDL_Window, SW_RESTORE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
185 |
#endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
186 |
|
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
187 |
#ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
188 |
#ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
189 |
ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
190 |
#endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
191 |
#endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
192 |
} |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
193 |
static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
194 |
{ |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
195 |
|
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
196 |
#ifdef _WIN32_WCE |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
197 |
SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
198 |
if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
199 |
{ |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
200 |
if( !this->hidden->suspended ) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
201 |
{ |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
202 |
this->hidden->suspended = 1; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
203 |
} |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
204 |
} |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
205 |
#else |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
206 |
/* WinCE does not have a taskbar, so minimizing is not convenient */ |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
207 |
ShowWindow(SDL_Window, SW_MINIMIZE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
208 |
#endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
209 |
|
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
210 |
#ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
211 |
#ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
212 |
ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
213 |
#endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
214 |
#endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
215 |
} |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
216 |
|
0 | 217 |
#ifdef WM_MOUSELEAVE |
218 |
/* |
|
219 |
Special code to handle mouse leave events - this sucks... |
|
220 |
http://support.microsoft.com/support/kb/articles/q183/1/07.asp |
|
221 |
||
222 |
TrackMouseEvent() is only available on Win98 and WinNT. |
|
223 |
_TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 |
|
224 |
development environment, and only works on systems that have had IE 3.0 |
|
225 |
or newer installed on them (which is not the case with the base Win95). |
|
226 |
Therefore, we implement our own version of _TrackMouseEvent() which |
|
227 |
uses our own implementation if TrackMouseEvent() is not available. |
|
228 |
*/ |
|
229 |
static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; |
|
230 |
||
231 |
static VOID CALLBACK |
|
232 |
TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) |
|
233 |
{ |
|
234 |
RECT rect; |
|
235 |
POINT pt; |
|
236 |
||
237 |
GetClientRect(hWnd, &rect); |
|
238 |
MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); |
|
239 |
GetCursorPos(&pt); |
|
240 |
if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { |
|
241 |
if ( !KillTimer(hWnd, idEvent) ) { |
|
242 |
/* Error killing the timer! */ |
|
243 |
} |
|
244 |
PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); |
|
245 |
} |
|
246 |
} |
|
247 |
static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) |
|
248 |
{ |
|
249 |
if ( ptme->dwFlags == TME_LEAVE ) { |
|
250 |
return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, |
|
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
251 |
(TIMERPROC)TrackMouseTimerProc) != 0; |
0 | 252 |
} |
253 |
return FALSE; |
|
254 |
} |
|
255 |
#endif /* WM_MOUSELEAVE */ |
|
256 |
||
257 |
/* Function to retrieve the current keyboard modifiers */ |
|
258 |
static void WIN_GetKeyboardState(void) |
|
259 |
{ |
|
260 |
#ifndef NO_GETKEYBOARDSTATE |
|
261 |
SDLMod state; |
|
262 |
BYTE keyboard[256]; |
|
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
263 |
Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 264 |
|
265 |
state = KMOD_NONE; |
|
266 |
if ( GetKeyboardState(keyboard) ) { |
|
267 |
if ( keyboard[VK_LSHIFT] & 0x80) { |
|
268 |
state |= KMOD_LSHIFT; |
|
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
269 |
kstate[SDLK_LSHIFT] = SDL_PRESSED; |
0 | 270 |
} |
271 |
if ( keyboard[VK_RSHIFT] & 0x80) { |
|
272 |
state |= KMOD_RSHIFT; |
|
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
273 |
kstate[SDLK_RSHIFT] = SDL_PRESSED; |
0 | 274 |
} |
275 |
if ( keyboard[VK_LCONTROL] & 0x80) { |
|
276 |
state |= KMOD_LCTRL; |
|
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
277 |
kstate[SDLK_LCTRL] = SDL_PRESSED; |
0 | 278 |
} |
279 |
if ( keyboard[VK_RCONTROL] & 0x80) { |
|
280 |
state |= KMOD_RCTRL; |
|
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
281 |
kstate[SDLK_RCTRL] = SDL_PRESSED; |
0 | 282 |
} |
283 |
if ( keyboard[VK_LMENU] & 0x80) { |
|
284 |
state |= KMOD_LALT; |
|
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
285 |
kstate[SDLK_LALT] = SDL_PRESSED; |
0 | 286 |
} |
287 |
if ( keyboard[VK_RMENU] & 0x80) { |
|
288 |
state |= KMOD_RALT; |
|
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
289 |
kstate[SDLK_RALT] = SDL_PRESSED; |
0 | 290 |
} |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
291 |
if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 292 |
state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
293 |
kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 294 |
} |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
295 |
if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 296 |
state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
297 |
kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 298 |
} |
299 |
} |
|
300 |
SDL_SetModState(state); |
|
301 |
#endif /* !NO_GETKEYBOARDSTATE */ |
|
302 |
} |
|
303 |
||
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
304 |
/* The main Win32 event handler |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
305 |
DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
306 |
*/ |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
307 |
LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 308 |
{ |
309 |
SDL_VideoDevice *this = current_video; |
|
310 |
static int mouse_pressed = 0; |
|
311 |
static int in_window = 0; |
|
312 |
#ifdef WMMSG_DEBUG |
|
313 |
fprintf(stderr, "Received windows message: "); |
|
314 |
if ( msg > MAX_WMMSG ) { |
|
315 |
fprintf(stderr, "%d", msg); |
|
316 |
} else { |
|
317 |
fprintf(stderr, "%s", wmtab[msg]); |
|
318 |
} |
|
319 |
fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); |
|
320 |
#endif |
|
321 |
switch (msg) { |
|
322 |
||
323 |
case WM_ACTIVATE: { |
|
324 |
SDL_VideoDevice *this = current_video; |
|
325 |
BOOL minimized; |
|
326 |
Uint8 appstate; |
|
327 |
||
328 |
minimized = HIWORD(wParam); |
|
329 |
if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) { |
|
330 |
/* Gain the following states */ |
|
331 |
appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; |
|
332 |
if ( this->input_grab != SDL_GRAB_OFF ) { |
|
333 |
WIN_GrabInput(this, SDL_GRAB_ON); |
|
334 |
} |
|
335 |
if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) { |
|
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
336 |
if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
337 |
DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
338 |
} |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
339 |
if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
340 |
SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
341 |
} |
0 | 342 |
} |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
343 |
#if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
344 |
if ( WINDIB_FULLSCREEN() ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
345 |
{ |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
346 |
LoadAygshell(); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
347 |
if( SHFullScreen ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
348 |
SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
349 |
else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
350 |
ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
351 |
|
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
352 |
} |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
353 |
#endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
354 |
|
0 | 355 |
posted = SDL_PrivateAppActive(1, appstate); |
356 |
WIN_GetKeyboardState(); |
|
357 |
} else { |
|
358 |
/* Lose the following states */ |
|
359 |
appstate = SDL_APPINPUTFOCUS; |
|
360 |
if ( minimized ) { |
|
361 |
appstate |= SDL_APPACTIVE; |
|
362 |
} |
|
363 |
if ( this->input_grab != SDL_GRAB_OFF ) { |
|
364 |
WIN_GrabInput(this, SDL_GRAB_OFF); |
|
365 |
} |
|
366 |
if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { |
|
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
367 |
if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
368 |
DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
369 |
} |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
370 |
if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
371 |
SDL_RestoreDesktopMode(); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
372 |
#if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
373 |
LoadAygshell(); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
374 |
if( SHFullScreen ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
375 |
SHFullScreen(SDL_Window, SHFS_SHOWSTARTICON|SHFS_SHOWTASKBAR|SHFS_SHOWSIPBUTTON); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
376 |
else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
377 |
ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOW); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
378 |
|
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
379 |
#endif |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
380 |
} |
0 | 381 |
} |
382 |
posted = SDL_PrivateAppActive(0, appstate); |
|
383 |
} |
|
384 |
return(0); |
|
385 |
} |
|
386 |
break; |
|
387 |
||
388 |
case WM_MOUSEMOVE: { |
|
389 |
||
390 |
/* Mouse is handled by DirectInput when fullscreen */ |
|
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
391 |
if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 392 |
Sint16 x, y; |
393 |
||
394 |
/* mouse has entered the window */ |
|
395 |
if ( ! in_window ) { |
|
396 |
#ifdef WM_MOUSELEAVE |
|
397 |
TRACKMOUSEEVENT tme; |
|
398 |
||
399 |
tme.cbSize = sizeof(tme); |
|
400 |
tme.dwFlags = TME_LEAVE; |
|
401 |
tme.hwndTrack = SDL_Window; |
|
402 |
_TrackMouseEvent(&tme); |
|
403 |
#endif /* WM_MOUSELEAVE */ |
|
404 |
in_window = TRUE; |
|
405 |
||
406 |
posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
|
407 |
} |
|
408 |
||
409 |
/* mouse has moved within the window */ |
|
410 |
x = LOWORD(lParam); |
|
411 |
y = HIWORD(lParam); |
|
412 |
if ( mouse_relative ) { |
|
413 |
POINT center; |
|
414 |
center.x = (SDL_VideoSurface->w/2); |
|
415 |
center.y = (SDL_VideoSurface->h/2); |
|
416 |
x -= (Sint16)center.x; |
|
417 |
y -= (Sint16)center.y; |
|
418 |
if ( x || y ) { |
|
419 |
ClientToScreen(SDL_Window, ¢er); |
|
420 |
SetCursorPos(center.x, center.y); |
|
421 |
posted = SDL_PrivateMouseMotion(0, 1, x, y); |
|
422 |
} |
|
423 |
} else { |
|
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
424 |
#ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
425 |
if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
426 |
GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
427 |
#endif |
0 | 428 |
posted = SDL_PrivateMouseMotion(0, 0, x, y); |
429 |
} |
|
430 |
} |
|
431 |
} |
|
432 |
return(0); |
|
433 |
||
434 |
#ifdef WM_MOUSELEAVE |
|
435 |
case WM_MOUSELEAVE: { |
|
436 |
||
437 |
/* Mouse is handled by DirectInput when fullscreen */ |
|
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
438 |
if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 439 |
/* mouse has left the window */ |
440 |
/* or */ |
|
441 |
/* Elvis has left the building! */ |
|
442 |
posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
|
443 |
} |
|
829
77bca0665b69
Fixed mouse focus events after resetting video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
565
diff
changeset
|
444 |
in_window = FALSE; |
0 | 445 |
} |
446 |
return(0); |
|
447 |
#endif /* WM_MOUSELEAVE */ |
|
448 |
||
449 |
case WM_LBUTTONDOWN: |
|
450 |
case WM_LBUTTONUP: |
|
451 |
case WM_MBUTTONDOWN: |
|
452 |
case WM_MBUTTONUP: |
|
453 |
case WM_RBUTTONDOWN: |
|
454 |
case WM_RBUTTONUP: { |
|
455 |
/* Mouse is handled by DirectInput when fullscreen */ |
|
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
456 |
if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 457 |
Sint16 x, y; |
458 |
Uint8 button, state; |
|
459 |
||
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
460 |
/* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
461 |
We want the SDL window to take focus so that |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
462 |
it acts like a normal windows "component" |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
463 |
(e.g. gains keyboard focus on a mouse click). |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
464 |
*/ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
465 |
SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
466 |
|
0 | 467 |
/* Figure out which button to use */ |
468 |
switch (msg) { |
|
469 |
case WM_LBUTTONDOWN: |
|
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
470 |
button = SDL_BUTTON_LEFT; |
0 | 471 |
state = SDL_PRESSED; |
472 |
break; |
|
473 |
case WM_LBUTTONUP: |
|
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
474 |
button = SDL_BUTTON_LEFT; |
0 | 475 |
state = SDL_RELEASED; |
476 |
break; |
|
477 |
case WM_MBUTTONDOWN: |
|
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
478 |
button = SDL_BUTTON_MIDDLE; |
0 | 479 |
state = SDL_PRESSED; |
480 |
break; |
|
481 |
case WM_MBUTTONUP: |
|
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
482 |
button = SDL_BUTTON_MIDDLE; |
0 | 483 |
state = SDL_RELEASED; |
484 |
break; |
|
485 |
case WM_RBUTTONDOWN: |
|
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
486 |
button = SDL_BUTTON_RIGHT; |
0 | 487 |
state = SDL_PRESSED; |
488 |
break; |
|
489 |
case WM_RBUTTONUP: |
|
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
490 |
button = SDL_BUTTON_RIGHT; |
0 | 491 |
state = SDL_RELEASED; |
492 |
break; |
|
493 |
default: |
|
494 |
/* Eh? Unknown button? */ |
|
495 |
return(0); |
|
496 |
} |
|
497 |
if ( state == SDL_PRESSED ) { |
|
498 |
/* Grab mouse so we get up events */ |
|
499 |
if ( ++mouse_pressed > 0 ) { |
|
500 |
SetCapture(hwnd); |
|
501 |
} |
|
502 |
} else { |
|
503 |
/* Release mouse after all up events */ |
|
504 |
if ( --mouse_pressed <= 0 ) { |
|
505 |
ReleaseCapture(); |
|
506 |
mouse_pressed = 0; |
|
507 |
} |
|
508 |
} |
|
509 |
if ( mouse_relative ) { |
|
510 |
/* RJR: March 28, 2000 |
|
511 |
report internal mouse position if in relative mode */ |
|
512 |
x = 0; y = 0; |
|
513 |
} else { |
|
514 |
x = (Sint16)LOWORD(lParam); |
|
515 |
y = (Sint16)HIWORD(lParam); |
|
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
516 |
#ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
517 |
if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
518 |
GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
519 |
#endif |
0 | 520 |
} |
521 |
posted = SDL_PrivateMouseButton( |
|
522 |
state, button, x, y); |
|
523 |
} |
|
524 |
} |
|
525 |
return(0); |
|
526 |
||
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
527 |
|
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
528 |
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
529 |
case WM_MOUSEWHEEL: |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
530 |
if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
531 |
int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
532 |
if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
533 |
Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
534 |
if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
535 |
button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
536 |
else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
537 |
button = SDL_BUTTON_WHEELDOWN; |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
538 |
posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
539 |
SDL_PRESSED, button, 0, 0); |
332 | 540 |
posted |= SDL_PrivateMouseButton( |
541 |
SDL_RELEASED, button, 0, 0); |
|
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
542 |
} |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
543 |
} |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
544 |
return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
545 |
#endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
546 |
|
0 | 547 |
#ifdef WM_GETMINMAXINFO |
548 |
/* This message is sent as a way for us to "check" the values |
|
549 |
* of a position change. If we don't like it, we can adjust |
|
550 |
* the values before they are changed. |
|
551 |
*/ |
|
552 |
case WM_GETMINMAXINFO: { |
|
553 |
MINMAXINFO *info; |
|
554 |
RECT size; |
|
555 |
int x, y; |
|
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
556 |
int style; |
0 | 557 |
int width; |
558 |
int height; |
|
559 |
||
560 |
/* We don't want to clobber an internal resize */ |
|
561 |
if ( SDL_resizing ) |
|
562 |
return(0); |
|
563 |
||
564 |
/* We allow resizing with the SDL_RESIZABLE flag */ |
|
565 |
if ( SDL_PublicSurface && |
|
566 |
(SDL_PublicSurface->flags & SDL_RESIZABLE) ) { |
|
567 |
return(0); |
|
568 |
} |
|
569 |
||
570 |
/* Get the current position of our window */ |
|
571 |
GetWindowRect(SDL_Window, &size); |
|
572 |
x = size.left; |
|
573 |
y = size.top; |
|
574 |
||
575 |
/* Calculate current width and height of our window */ |
|
576 |
size.top = 0; |
|
577 |
size.left = 0; |
|
578 |
if ( SDL_PublicSurface != NULL ) { |
|
579 |
size.bottom = SDL_PublicSurface->h; |
|
580 |
size.right = SDL_PublicSurface->w; |
|
581 |
} else { |
|
582 |
size.bottom = 0; |
|
583 |
size.right = 0; |
|
584 |
} |
|
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
585 |
|
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
586 |
/* DJM - according to the docs for GetMenu(), the |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
587 |
return value is undefined if hwnd is a child window. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
588 |
Aparently it's too difficult for MS to check |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
589 |
inside their function, so I have to do it here. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
590 |
*/ |
1480 | 591 |
style = GetWindowLong(hwnd, GWL_STYLE); |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
592 |
AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
593 |
&size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
594 |
style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
595 |
style & WS_CHILDWINDOW ? FALSE |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
596 |
: GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
597 |
|
0 | 598 |
width = size.right - size.left; |
599 |
height = size.bottom - size.top; |
|
600 |
||
601 |
/* Fix our size to the current size */ |
|
602 |
info = (MINMAXINFO *)lParam; |
|
603 |
info->ptMaxSize.x = width; |
|
604 |
info->ptMaxSize.y = height; |
|
605 |
info->ptMaxPosition.x = x; |
|
606 |
info->ptMaxPosition.y = y; |
|
607 |
info->ptMinTrackSize.x = width; |
|
608 |
info->ptMinTrackSize.y = height; |
|
609 |
info->ptMaxTrackSize.x = width; |
|
610 |
info->ptMaxTrackSize.y = height; |
|
611 |
} |
|
612 |
return(0); |
|
613 |
#endif /* WM_GETMINMAXINFO */ |
|
614 |
||
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
615 |
case WM_WINDOWPOSCHANGED: { |
0 | 616 |
SDL_VideoDevice *this = current_video; |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
617 |
int w, h; |
0 | 618 |
|
619 |
GetClientRect(SDL_Window, &SDL_bounds); |
|
1290
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
620 |
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds); |
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
621 |
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1); |
1291
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
622 |
if ( !SDL_resizing && !IsZoomed(SDL_Window) && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
623 |
SDL_PublicSurface && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
624 |
!(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
625 |
SDL_windowX = SDL_bounds.left; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
626 |
SDL_windowY = SDL_bounds.top; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
627 |
} |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
628 |
w = SDL_bounds.right-SDL_bounds.left; |
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
629 |
h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 630 |
if ( this->input_grab != SDL_GRAB_OFF ) { |
631 |
ClipCursor(&SDL_bounds); |
|
632 |
} |
|
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
633 |
if ( SDL_PublicSurface && |
0 | 634 |
(SDL_PublicSurface->flags & SDL_RESIZABLE) ) { |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
635 |
SDL_PrivateResize(w, h); |
0 | 636 |
} |
637 |
} |
|
638 |
break; |
|
639 |
||
640 |
/* We need to set the cursor */ |
|
641 |
case WM_SETCURSOR: { |
|
642 |
Uint16 hittest; |
|
643 |
||
644 |
hittest = LOWORD(lParam); |
|
645 |
if ( hittest == HTCLIENT ) { |
|
646 |
SetCursor(SDL_hcursor); |
|
647 |
return(TRUE); |
|
648 |
} |
|
649 |
} |
|
650 |
break; |
|
651 |
||
652 |
/* We are about to get palette focus! */ |
|
653 |
case WM_QUERYNEWPALETTE: { |
|
654 |
WIN_RealizePalette(current_video); |
|
655 |
return(TRUE); |
|
656 |
} |
|
657 |
break; |
|
658 |
||
659 |
/* Another application changed the palette */ |
|
660 |
case WM_PALETTECHANGED: { |
|
661 |
WIN_PaletteChanged(current_video, (HWND)wParam); |
|
662 |
} |
|
663 |
break; |
|
664 |
||
665 |
/* We were occluded, refresh our display */ |
|
666 |
case WM_PAINT: { |
|
667 |
HDC hdc; |
|
668 |
PAINTSTRUCT ps; |
|
669 |
||
670 |
hdc = BeginPaint(SDL_Window, &ps); |
|
671 |
if ( current_video->screen && |
|
672 |
!(current_video->screen->flags & SDL_OPENGL) ) { |
|
673 |
WIN_WinPAINT(current_video, hdc); |
|
674 |
} |
|
675 |
EndPaint(SDL_Window, &ps); |
|
676 |
} |
|
677 |
return(0); |
|
678 |
||
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
679 |
/* DJM: Send an expose event in this case */ |
0 | 680 |
case WM_ERASEBKGND: { |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
681 |
posted = SDL_PrivateExpose(); |
0 | 682 |
} |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
683 |
return(0); |
0 | 684 |
|
685 |
case WM_CLOSE: { |
|
686 |
if ( (posted = SDL_PrivateQuit()) ) |
|
687 |
PostQuitMessage(0); |
|
688 |
} |
|
689 |
return(0); |
|
690 |
||
691 |
case WM_DESTROY: { |
|
692 |
PostQuitMessage(0); |
|
693 |
} |
|
694 |
return(0); |
|
695 |
||
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
696 |
#ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
697 |
case WM_INPUTLANGCHANGE: { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
698 |
codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
699 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
700 |
return(TRUE); |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
701 |
#endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
702 |
|
0 | 703 |
default: { |
704 |
/* Special handling by the video driver */ |
|
705 |
if (HandleMessage) { |
|
706 |
return(HandleMessage(current_video, |
|
707 |
hwnd, msg, wParam, lParam)); |
|
708 |
} |
|
709 |
} |
|
710 |
break; |
|
711 |
} |
|
712 |
return(DefWindowProc(hwnd, msg, wParam, lParam)); |
|
713 |
} |
|
714 |
||
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
715 |
/* Allow the application handle to be stored and retrieved later */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
716 |
static void *SDL_handle = NULL; |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
717 |
|
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
718 |
void SDL_SetModuleHandle(void *handle) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
719 |
{ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
720 |
SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
721 |
} |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
722 |
void *SDL_GetModuleHandle(void) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
723 |
{ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
724 |
void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
725 |
|
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
726 |
if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
727 |
handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
728 |
} else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
729 |
handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
730 |
} |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
731 |
return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
732 |
} |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
733 |
|
0 | 734 |
/* This allows the SDL_WINDOWID hack */ |
1280
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1272
diff
changeset
|
735 |
BOOL SDL_windowid = FALSE; |
0 | 736 |
|
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
737 |
static int app_registered = 0; |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
738 |
|
0 | 739 |
/* Register the class for this application -- exported for winmain.c */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
740 |
int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 741 |
{ |
742 |
WNDCLASS class; |
|
743 |
#ifdef WM_MOUSELEAVE |
|
744 |
HMODULE handle; |
|
745 |
#endif |
|
746 |
||
747 |
/* Only do this once... */ |
|
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
748 |
if ( app_registered ) { |
1498 | 749 |
++app_registered; |
0 | 750 |
return(0); |
751 |
} |
|
752 |
||
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
753 |
#ifndef CS_BYTEALIGNCLIENT |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
754 |
#define CS_BYTEALIGNCLIENT 0 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
755 |
#endif |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
756 |
if ( ! name && ! SDL_Appname ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
757 |
name = "SDL_app"; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
758 |
SDL_Appstyle = CS_BYTEALIGNCLIENT; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
759 |
SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
0 | 760 |
} |
761 |
||
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
762 |
if ( name ) { |
0 | 763 |
#ifdef _WIN32_WCE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
764 |
/* WinCE uses the UNICODE version */ |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
765 |
size_t nLen = SDL_strlen(name)+1; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
766 |
SDL_Appname = SDL_malloc(nLen*2); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
767 |
MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen); |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
768 |
#else |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
769 |
size_t nLen = SDL_strlen(name)+1; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
770 |
SDL_Appname = SDL_malloc(nLen); |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
771 |
SDL_strlcpy(SDL_Appname, name, nLen); |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
772 |
#endif /* _WIN32_WCE */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
773 |
SDL_Appstyle = style; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
774 |
SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
775 |
} |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
776 |
|
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
777 |
/* Register the application class */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
778 |
class.hCursor = NULL; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
779 |
class.hIcon = LoadImage(SDL_Instance, SDL_Appname, |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
780 |
IMAGE_ICON, |
0 | 781 |
0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
782 |
class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
783 |
class.lpszClassName = SDL_Appname; |
0 | 784 |
class.hbrBackground = NULL; |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
785 |
class.hInstance = SDL_Instance; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
786 |
class.style = SDL_Appstyle; |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
787 |
#if SDL_VIDEO_OPENGL |
0 | 788 |
class.style |= CS_OWNDC; |
789 |
#endif |
|
790 |
class.lpfnWndProc = WinMessage; |
|
791 |
class.cbWndExtra = 0; |
|
792 |
class.cbClsExtra = 0; |
|
793 |
if ( ! RegisterClass(&class) ) { |
|
794 |
SDL_SetError("Couldn't register application class"); |
|
795 |
return(-1); |
|
796 |
} |
|
797 |
||
798 |
#ifdef WM_MOUSELEAVE |
|
799 |
/* Get the version of TrackMouseEvent() we use */ |
|
800 |
_TrackMouseEvent = NULL; |
|
801 |
handle = GetModuleHandle("USER32.DLL"); |
|
802 |
if ( handle ) { |
|
803 |
_TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); |
|
804 |
} |
|
805 |
if ( _TrackMouseEvent == NULL ) { |
|
806 |
_TrackMouseEvent = WIN_TrackMouseEvent; |
|
807 |
} |
|
808 |
#endif /* WM_MOUSELEAVE */ |
|
809 |
||
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
810 |
#ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
811 |
/* Initialise variables for SDL_ToUnicode() */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
812 |
codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
813 |
SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
814 |
#endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
815 |
|
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
816 |
app_registered = 1; |
0 | 817 |
return(0); |
818 |
} |
|
819 |
||
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
820 |
/* Unregisters the windowclass registered in SDL_RegisterApp above. */ |
1150
7d8e1925f35b
Typo that broke Windows builds.
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
821 |
void SDL_UnregisterApp() |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
822 |
{ |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
823 |
WNDCLASS class; |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
824 |
|
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
825 |
/* SDL_RegisterApp might not have been called before */ |
1498 | 826 |
if ( !app_registered ) { |
827 |
return; |
|
828 |
} |
|
829 |
--app_registered; |
|
830 |
if ( app_registered == 0 ) { |
|
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
831 |
/* Check for any registered window classes. */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
832 |
if ( GetClassInfo(SDL_Instance, SDL_Appname, &class) ) { |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
833 |
UnregisterClass(SDL_Appname, SDL_Instance); |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
834 |
} |
1498 | 835 |
SDL_free(SDL_Appname); |
836 |
SDL_Appname = NULL; |
|
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
837 |
} |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
838 |
} |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
839 |
|
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
840 |
#ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
841 |
/* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
842 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
843 |
static int Is9xME() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
844 |
{ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
845 |
OSVERSIONINFO info; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
846 |
|
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
847 |
SDL_memset(&info, 0, sizeof(info)); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
848 |
info.dwOSVersionInfoSize = sizeof(info); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
849 |
if (!GetVersionEx(&info)) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
850 |
return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
851 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
852 |
return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
853 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
854 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
855 |
static int GetCodePage() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
856 |
{ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
857 |
char buff[8]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
858 |
int lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
859 |
int cp = GetACP(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
860 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
861 |
if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
862 |
cp = SDL_atoi(buff); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
863 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
864 |
return cp; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
865 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
866 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
867 |
static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, PBYTE keystate, LPWSTR wchars, int wsize, UINT flags) |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
868 |
{ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
869 |
BYTE chars[2]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
870 |
|
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
871 |
if (ToAsciiEx(vkey, scancode, keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
872 |
return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
873 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
874 |
return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
875 |
} |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
876 |
|
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
877 |
#endif /* !NO_GETKEYBOARDSTATE */ |