Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_sysevents.c @ 1291:31331c444ea2
Only save the window position if we're in windowed mode
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 29 Jan 2006 22:09:26 +0000 |
parents | c4a5a772c5d9 |
children | c3e36ac8a94c |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
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 | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
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 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <windows.h> | |
31 | |
32 #include "SDL_getenv.h" | |
33 #include "SDL_events.h" | |
34 #include "SDL_video.h" | |
35 #include "SDL_error.h" | |
36 #include "SDL_syswm.h" | |
37 #include "SDL_sysevents.h" | |
38 #include "SDL_events_c.h" | |
39 #include "SDL_sysvideo.h" | |
40 #include "SDL_lowvideo.h" | |
41 #include "SDL_syswm_c.h" | |
42 #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
|
43 #include "SDL_loadso.h" |
0 | 44 |
45 #ifdef WMMSG_DEBUG | |
46 #include "wmmsg.h" | |
47 #endif | |
48 | |
49 #ifdef _WIN32_WCE | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
50 #include "SDL_gapivideo.h" |
0 | 51 #define NO_GETKEYBOARDSTATE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
52 #define NO_CHANGEDISPLAYSETTINGS |
0 | 53 #endif |
54 | |
55 /* The window we use for everything... */ | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
56 #ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
57 LPWSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
58 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
59 LPSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
60 #endif |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
61 Uint32 SDL_Appstyle = 0; |
0 | 62 HINSTANCE SDL_Instance = NULL; |
63 HWND SDL_Window = NULL; | |
64 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
|
65 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
|
66 int SDL_windowY = 0; |
0 | 67 int SDL_resizing = 0; |
68 int mouse_relative = 0; | |
69 int posted = 0; | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
70 #ifndef NO_CHANGEDISPLAYSETTINGS |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
71 DEVMODE SDL_fullscreen_mode; |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
72 #endif |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
73 WORD *gamma_saved = NULL; |
0 | 74 |
75 | |
76 /* 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
|
77 LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; |
0 | 78 void (*WIN_RealizePalette)(_THIS); |
79 void (*WIN_PaletteChanged)(_THIS, HWND window); | |
80 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
|
81 extern void DIB_SwapGamma(_THIS); |
0 | 82 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
83 #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
|
84 /* 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
|
85 static int codepage; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
86 static int Is9xME(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
87 static int GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
88 static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, BYTE *keystate, Uint16 *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
|
89 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
90 ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
91 #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
|
92 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
93 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
94 #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
|
95 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
96 // 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
|
97 HINSTANCE aygshell = NULL; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
98 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
|
99 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
100 #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
|
101 #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
|
102 #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
|
103 #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
|
104 #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
|
105 #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
|
106 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
107 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
|
108 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
109 if( !aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
110 aygshell = SDL_LoadObject("aygshell.dll"); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
111 if( aygshell ) |
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 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
|
114 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
115 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
116 |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
117 /* 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
|
118 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
|
119 Sint16 rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
120 Sint16 rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
121 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
122 if (hires) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
123 *x = *x * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
124 *y = *y * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
125 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
126 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
127 switch(rotate) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
128 case SDL_ORIENTATION_UP: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
129 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
130 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
|
131 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
132 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
133 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
|
134 rotatedY = *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
135 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
136 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
137 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
138 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
|
139 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
140 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
141 rotatedX = *y; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
142 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
|
143 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
144 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
145 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
146 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
147 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
148 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
149 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
150 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
151 static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
152 { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
153 #ifndef NO_CHANGEDISPLAYSETTINGS |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
154 ShowWindow(SDL_Window, SW_RESTORE); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
155 ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
156 #endif |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
157 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
158 static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
159 { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
160 #ifndef NO_CHANGEDISPLAYSETTINGS |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
161 ShowWindow(SDL_Window, SW_MINIMIZE); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
162 ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
163 #endif |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
164 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
165 |
0 | 166 #ifdef WM_MOUSELEAVE |
167 /* | |
168 Special code to handle mouse leave events - this sucks... | |
169 http://support.microsoft.com/support/kb/articles/q183/1/07.asp | |
170 | |
171 TrackMouseEvent() is only available on Win98 and WinNT. | |
172 _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 | |
173 development environment, and only works on systems that have had IE 3.0 | |
174 or newer installed on them (which is not the case with the base Win95). | |
175 Therefore, we implement our own version of _TrackMouseEvent() which | |
176 uses our own implementation if TrackMouseEvent() is not available. | |
177 */ | |
178 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; | |
179 | |
180 static VOID CALLBACK | |
181 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) | |
182 { | |
183 RECT rect; | |
184 POINT pt; | |
185 | |
186 GetClientRect(hWnd, &rect); | |
187 MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); | |
188 GetCursorPos(&pt); | |
189 if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { | |
190 if ( !KillTimer(hWnd, idEvent) ) { | |
191 /* Error killing the timer! */ | |
192 } | |
193 PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); | |
194 } | |
195 } | |
196 static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) | |
197 { | |
198 if ( ptme->dwFlags == TME_LEAVE ) { | |
199 return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, | |
200 (TIMERPROC)TrackMouseTimerProc); | |
201 } | |
202 return FALSE; | |
203 } | |
204 #endif /* WM_MOUSELEAVE */ | |
205 | |
206 /* Function to retrieve the current keyboard modifiers */ | |
207 static void WIN_GetKeyboardState(void) | |
208 { | |
209 #ifndef NO_GETKEYBOARDSTATE | |
210 SDLMod state; | |
211 BYTE keyboard[256]; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
212 Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 213 |
214 state = KMOD_NONE; | |
215 if ( GetKeyboardState(keyboard) ) { | |
216 if ( keyboard[VK_LSHIFT] & 0x80) { | |
217 state |= KMOD_LSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
218 kstate[SDLK_LSHIFT] = SDL_PRESSED; |
0 | 219 } |
220 if ( keyboard[VK_RSHIFT] & 0x80) { | |
221 state |= KMOD_RSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
222 kstate[SDLK_RSHIFT] = SDL_PRESSED; |
0 | 223 } |
224 if ( keyboard[VK_LCONTROL] & 0x80) { | |
225 state |= KMOD_LCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
226 kstate[SDLK_LCTRL] = SDL_PRESSED; |
0 | 227 } |
228 if ( keyboard[VK_RCONTROL] & 0x80) { | |
229 state |= KMOD_RCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
230 kstate[SDLK_RCTRL] = SDL_PRESSED; |
0 | 231 } |
232 if ( keyboard[VK_LMENU] & 0x80) { | |
233 state |= KMOD_LALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
234 kstate[SDLK_LALT] = SDL_PRESSED; |
0 | 235 } |
236 if ( keyboard[VK_RMENU] & 0x80) { | |
237 state |= KMOD_RALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
238 kstate[SDLK_RALT] = SDL_PRESSED; |
0 | 239 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
240 if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 241 state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
242 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 243 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
244 if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 245 state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
246 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 247 } |
248 } | |
249 SDL_SetModState(state); | |
250 #endif /* !NO_GETKEYBOARDSTATE */ | |
251 } | |
252 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
253 /* 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
|
254 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
|
255 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
256 LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 257 { |
258 SDL_VideoDevice *this = current_video; | |
259 static int mouse_pressed = 0; | |
260 static int in_window = 0; | |
261 #ifdef WMMSG_DEBUG | |
262 fprintf(stderr, "Received windows message: "); | |
263 if ( msg > MAX_WMMSG ) { | |
264 fprintf(stderr, "%d", msg); | |
265 } else { | |
266 fprintf(stderr, "%s", wmtab[msg]); | |
267 } | |
268 fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); | |
269 #endif | |
270 switch (msg) { | |
271 | |
272 case WM_ACTIVATE: { | |
273 SDL_VideoDevice *this = current_video; | |
274 BOOL minimized; | |
275 Uint8 appstate; | |
276 | |
277 minimized = HIWORD(wParam); | |
278 if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) { | |
279 /* Gain the following states */ | |
280 appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; | |
281 if ( this->input_grab != SDL_GRAB_OFF ) { | |
282 WIN_GrabInput(this, SDL_GRAB_ON); | |
283 } | |
284 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
|
285 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
286 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
287 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
288 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
289 SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
290 } |
0 | 291 } |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
292 #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
|
293 if ( WINDIB_FULLSCREEN() ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
294 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
295 LoadAygshell(); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
296 if( aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
297 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
|
298 else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
299 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
|
300 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
301 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
302 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
303 |
0 | 304 posted = SDL_PrivateAppActive(1, appstate); |
305 WIN_GetKeyboardState(); | |
306 } else { | |
307 /* Lose the following states */ | |
308 appstate = SDL_APPINPUTFOCUS; | |
309 if ( minimized ) { | |
310 appstate |= SDL_APPACTIVE; | |
311 } | |
312 if ( this->input_grab != SDL_GRAB_OFF ) { | |
313 WIN_GrabInput(this, SDL_GRAB_OFF); | |
314 } | |
315 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
|
316 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
317 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
318 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
319 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
320 SDL_RestoreDesktopMode(); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
321 #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
|
322 LoadAygshell(); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
323 if( aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
324 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
|
325 else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
326 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
|
327 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
328 #endif |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
329 } |
0 | 330 } |
331 posted = SDL_PrivateAppActive(0, appstate); | |
332 } | |
333 return(0); | |
334 } | |
335 break; | |
336 | |
337 case WM_MOUSEMOVE: { | |
338 | |
339 /* 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
|
340 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 341 Sint16 x, y; |
342 | |
343 /* mouse has entered the window */ | |
344 if ( ! in_window ) { | |
345 #ifdef WM_MOUSELEAVE | |
346 TRACKMOUSEEVENT tme; | |
347 | |
348 tme.cbSize = sizeof(tme); | |
349 tme.dwFlags = TME_LEAVE; | |
350 tme.hwndTrack = SDL_Window; | |
351 _TrackMouseEvent(&tme); | |
352 #endif /* WM_MOUSELEAVE */ | |
353 in_window = TRUE; | |
354 | |
355 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
356 } | |
357 | |
358 /* mouse has moved within the window */ | |
359 x = LOWORD(lParam); | |
360 y = HIWORD(lParam); | |
361 if ( mouse_relative ) { | |
362 POINT center; | |
363 center.x = (SDL_VideoSurface->w/2); | |
364 center.y = (SDL_VideoSurface->h/2); | |
365 x -= (Sint16)center.x; | |
366 y -= (Sint16)center.y; | |
367 if ( x || y ) { | |
368 ClientToScreen(SDL_Window, ¢er); | |
369 SetCursorPos(center.x, center.y); | |
370 posted = SDL_PrivateMouseMotion(0, 1, x, y); | |
371 } | |
372 } else { | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
373 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
374 if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
375 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
|
376 #endif |
0 | 377 posted = SDL_PrivateMouseMotion(0, 0, x, y); |
378 } | |
379 } | |
380 } | |
381 return(0); | |
382 | |
383 #ifdef WM_MOUSELEAVE | |
384 case WM_MOUSELEAVE: { | |
385 | |
386 /* 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
|
387 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 388 /* mouse has left the window */ |
389 /* or */ | |
390 /* Elvis has left the building! */ | |
391 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
392 } | |
829
77bca0665b69
Fixed mouse focus events after resetting video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
565
diff
changeset
|
393 in_window = FALSE; |
0 | 394 } |
395 return(0); | |
396 #endif /* WM_MOUSELEAVE */ | |
397 | |
398 case WM_LBUTTONDOWN: | |
399 case WM_LBUTTONUP: | |
400 case WM_MBUTTONDOWN: | |
401 case WM_MBUTTONUP: | |
402 case WM_RBUTTONDOWN: | |
403 case WM_RBUTTONUP: { | |
404 /* 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
|
405 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 406 Sint16 x, y; |
407 Uint8 button, state; | |
408 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
409 /* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
410 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
|
411 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
|
412 (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
|
413 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
414 SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
415 |
0 | 416 /* Figure out which button to use */ |
417 switch (msg) { | |
418 case WM_LBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
419 button = SDL_BUTTON_LEFT; |
0 | 420 state = SDL_PRESSED; |
421 break; | |
422 case WM_LBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
423 button = SDL_BUTTON_LEFT; |
0 | 424 state = SDL_RELEASED; |
425 break; | |
426 case WM_MBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
427 button = SDL_BUTTON_MIDDLE; |
0 | 428 state = SDL_PRESSED; |
429 break; | |
430 case WM_MBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
431 button = SDL_BUTTON_MIDDLE; |
0 | 432 state = SDL_RELEASED; |
433 break; | |
434 case WM_RBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
435 button = SDL_BUTTON_RIGHT; |
0 | 436 state = SDL_PRESSED; |
437 break; | |
438 case WM_RBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
439 button = SDL_BUTTON_RIGHT; |
0 | 440 state = SDL_RELEASED; |
441 break; | |
442 default: | |
443 /* Eh? Unknown button? */ | |
444 return(0); | |
445 } | |
446 if ( state == SDL_PRESSED ) { | |
447 /* Grab mouse so we get up events */ | |
448 if ( ++mouse_pressed > 0 ) { | |
449 SetCapture(hwnd); | |
450 } | |
451 } else { | |
452 /* Release mouse after all up events */ | |
453 if ( --mouse_pressed <= 0 ) { | |
454 ReleaseCapture(); | |
455 mouse_pressed = 0; | |
456 } | |
457 } | |
458 if ( mouse_relative ) { | |
459 /* RJR: March 28, 2000 | |
460 report internal mouse position if in relative mode */ | |
461 x = 0; y = 0; | |
462 } else { | |
463 x = (Sint16)LOWORD(lParam); | |
464 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
|
465 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
466 if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
467 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
|
468 #endif |
0 | 469 } |
470 posted = SDL_PrivateMouseButton( | |
471 state, button, x, y); | |
472 } | |
473 } | |
474 return(0); | |
475 | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
476 |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
477 #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
|
478 case WM_MOUSEWHEEL: |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
479 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
|
480 int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
481 if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
482 Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
483 if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
484 button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
485 else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
486 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
|
487 posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
488 SDL_PRESSED, button, 0, 0); |
332 | 489 posted |= SDL_PrivateMouseButton( |
490 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
|
491 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
492 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
493 return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
494 #endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
495 |
0 | 496 #ifdef WM_GETMINMAXINFO |
497 /* This message is sent as a way for us to "check" the values | |
498 * of a position change. If we don't like it, we can adjust | |
499 * the values before they are changed. | |
500 */ | |
501 case WM_GETMINMAXINFO: { | |
502 MINMAXINFO *info; | |
503 RECT size; | |
504 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
|
505 int style; |
0 | 506 int width; |
507 int height; | |
508 | |
509 /* We don't want to clobber an internal resize */ | |
510 if ( SDL_resizing ) | |
511 return(0); | |
512 | |
513 /* We allow resizing with the SDL_RESIZABLE flag */ | |
514 if ( SDL_PublicSurface && | |
515 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
516 return(0); | |
517 } | |
518 | |
519 /* Get the current position of our window */ | |
520 GetWindowRect(SDL_Window, &size); | |
521 x = size.left; | |
522 y = size.top; | |
523 | |
524 /* Calculate current width and height of our window */ | |
525 size.top = 0; | |
526 size.left = 0; | |
527 if ( SDL_PublicSurface != NULL ) { | |
528 size.bottom = SDL_PublicSurface->h; | |
529 size.right = SDL_PublicSurface->w; | |
530 } else { | |
531 size.bottom = 0; | |
532 size.right = 0; | |
533 } | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
534 |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
535 /* 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
|
536 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
|
537 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
|
538 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
|
539 */ |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
540 style = GetWindowLong(hwnd, GWL_STYLE); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
541 AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
542 &size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
543 style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
544 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
|
545 : GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
546 |
0 | 547 width = size.right - size.left; |
548 height = size.bottom - size.top; | |
549 | |
550 /* Fix our size to the current size */ | |
551 info = (MINMAXINFO *)lParam; | |
552 info->ptMaxSize.x = width; | |
553 info->ptMaxSize.y = height; | |
554 info->ptMaxPosition.x = x; | |
555 info->ptMaxPosition.y = y; | |
556 info->ptMinTrackSize.x = width; | |
557 info->ptMinTrackSize.y = height; | |
558 info->ptMaxTrackSize.x = width; | |
559 info->ptMaxTrackSize.y = height; | |
560 } | |
561 return(0); | |
562 #endif /* WM_GETMINMAXINFO */ | |
563 | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
564 case WM_WINDOWPOSCHANGED: { |
0 | 565 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
|
566 int w, h; |
0 | 567 |
568 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
|
569 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
|
570 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
|
571 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
|
572 SDL_PublicSurface && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
573 !(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
|
574 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
|
575 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
|
576 } |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
577 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
|
578 h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 579 if ( this->input_grab != SDL_GRAB_OFF ) { |
580 ClipCursor(&SDL_bounds); | |
581 } | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
582 if ( SDL_PublicSurface && |
0 | 583 (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
|
584 SDL_PrivateResize(w, h); |
0 | 585 } |
586 } | |
587 break; | |
588 | |
589 /* We need to set the cursor */ | |
590 case WM_SETCURSOR: { | |
591 Uint16 hittest; | |
592 | |
593 hittest = LOWORD(lParam); | |
594 if ( hittest == HTCLIENT ) { | |
595 SetCursor(SDL_hcursor); | |
596 return(TRUE); | |
597 } | |
598 } | |
599 break; | |
600 | |
601 /* We are about to get palette focus! */ | |
602 case WM_QUERYNEWPALETTE: { | |
603 WIN_RealizePalette(current_video); | |
604 return(TRUE); | |
605 } | |
606 break; | |
607 | |
608 /* Another application changed the palette */ | |
609 case WM_PALETTECHANGED: { | |
610 WIN_PaletteChanged(current_video, (HWND)wParam); | |
611 } | |
612 break; | |
613 | |
614 /* We were occluded, refresh our display */ | |
615 case WM_PAINT: { | |
616 HDC hdc; | |
617 PAINTSTRUCT ps; | |
618 | |
619 hdc = BeginPaint(SDL_Window, &ps); | |
620 if ( current_video->screen && | |
621 !(current_video->screen->flags & SDL_OPENGL) ) { | |
622 WIN_WinPAINT(current_video, hdc); | |
623 } | |
624 EndPaint(SDL_Window, &ps); | |
625 } | |
626 return(0); | |
627 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
628 /* DJM: Send an expose event in this case */ |
0 | 629 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
|
630 posted = SDL_PrivateExpose(); |
0 | 631 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
632 return(0); |
0 | 633 |
634 case WM_CLOSE: { | |
635 if ( (posted = SDL_PrivateQuit()) ) | |
636 PostQuitMessage(0); | |
637 } | |
638 return(0); | |
639 | |
640 case WM_DESTROY: { | |
641 PostQuitMessage(0); | |
642 } | |
643 return(0); | |
644 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
645 #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
|
646 case WM_INPUTLANGCHANGE: { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
647 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
648 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
649 return(TRUE); |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
650 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
651 |
0 | 652 default: { |
653 /* Special handling by the video driver */ | |
654 if (HandleMessage) { | |
655 return(HandleMessage(current_video, | |
656 hwnd, msg, wParam, lParam)); | |
657 } | |
658 } | |
659 break; | |
660 } | |
661 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
662 } | |
663 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
664 /* 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
|
665 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
|
666 |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
667 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
|
668 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
669 SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
670 } |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
671 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
|
672 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
673 void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
674 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
675 if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
676 handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
677 } else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
678 handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
679 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
680 return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
681 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
682 |
0 | 683 /* 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
|
684 BOOL SDL_windowid = FALSE; |
0 | 685 |
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
|
686 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
|
687 |
0 | 688 /* 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
|
689 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 690 { |
691 WNDCLASS class; | |
692 #ifdef WM_MOUSELEAVE | |
693 HMODULE handle; | |
694 #endif | |
695 | |
696 /* 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
|
697 if ( app_registered ) { |
0 | 698 return(0); |
699 } | |
700 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
701 #ifndef CS_BYTEALIGNCLIENT |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
702 #define CS_BYTEALIGNCLIENT 0 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
703 #endif |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
704 if ( ! name && ! SDL_Appname ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
705 name = "SDL_app"; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
706 SDL_Appstyle = CS_BYTEALIGNCLIENT; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
707 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
0 | 708 } |
709 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
710 if ( name ) { |
0 | 711 #ifdef _WIN32_WCE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
712 /* WinCE uses the UNICODE version */ |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
713 int nLen = strlen(name)+1; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
714 SDL_Appname = malloc(nLen*2); |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
715 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
|
716 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
717 int nLen = strlen(name)+1; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
718 SDL_Appname = malloc(nLen); |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
719 strcpy(SDL_Appname, name); |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
720 #endif /* _WIN32_WCE */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
721 SDL_Appstyle = style; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
722 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
723 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
724 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
725 /* Register the application class */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
726 class.hCursor = NULL; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
727 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
|
728 IMAGE_ICON, |
0 | 729 0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
730 class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
731 class.lpszClassName = SDL_Appname; |
0 | 732 class.hbrBackground = NULL; |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
733 class.hInstance = SDL_Instance; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
734 class.style = SDL_Appstyle; |
0 | 735 #ifdef HAVE_OPENGL |
736 class.style |= CS_OWNDC; | |
737 #endif | |
738 class.lpfnWndProc = WinMessage; | |
739 class.cbWndExtra = 0; | |
740 class.cbClsExtra = 0; | |
741 if ( ! RegisterClass(&class) ) { | |
742 SDL_SetError("Couldn't register application class"); | |
743 return(-1); | |
744 } | |
745 | |
746 #ifdef WM_MOUSELEAVE | |
747 /* Get the version of TrackMouseEvent() we use */ | |
748 _TrackMouseEvent = NULL; | |
749 handle = GetModuleHandle("USER32.DLL"); | |
750 if ( handle ) { | |
751 _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); | |
752 } | |
753 if ( _TrackMouseEvent == NULL ) { | |
754 _TrackMouseEvent = WIN_TrackMouseEvent; | |
755 } | |
756 #endif /* WM_MOUSELEAVE */ | |
757 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
758 #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
|
759 /* 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
|
760 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
761 SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
762 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
763 |
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
|
764 app_registered = 1; |
0 | 765 return(0); |
766 } | |
767 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
768 /* 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
|
769 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
|
770 { |
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
|
771 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
|
772 |
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
|
773 /* SDL_RegisterApp might not have been called before */ |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
774 if ( app_registered ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
775 /* Check for any registered window classes. */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
776 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
|
777 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
|
778 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
779 app_registered = 0; |
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
|
780 } |
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
|
781 } |
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
|
782 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
783 #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
|
784 /* 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
|
785 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
786 static int Is9xME() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
787 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
788 OSVERSIONINFO info; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
789 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
790 memset(&info, 0, sizeof(info)); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
791 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
|
792 if (!GetVersionEx(&info)) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
793 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
794 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
795 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
|
796 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
797 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
798 static int GetCodePage() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
799 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
800 char buff[8]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
801 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
|
802 int cp = GetACP(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
803 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
804 if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
805 cp = atoi(buff); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
806 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
807 return cp; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
808 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
809 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
810 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
|
811 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
812 BYTE chars[2]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
813 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
814 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
|
815 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
|
816 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
817 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
818 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
819 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
820 #endif /* !NO_GETKEYBOARDSTATE */ |