Mercurial > sdl-ios-xcode
annotate src/video/windib/SDL_dibevents.c @ 974:b8427b5151ed
Restore the user specified window proc after shutdown
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 15 Nov 2004 21:09:54 +0000 |
parents | 31fa08b36380 |
children | add87cc1de0a |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
726
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 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:
145
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_events.h" | |
33 #include "SDL_error.h" | |
34 #include "SDL_syswm.h" | |
35 #include "SDL_sysevents.h" | |
36 #include "SDL_events_c.h" | |
37 #include "SDL_lowvideo.h" | |
38 #include "SDL_dibvideo.h" | |
39 #include "SDL_vkeys.h" | |
40 | |
41 #ifndef WM_APP | |
42 #define WM_APP 0x8000 | |
43 #endif | |
44 | |
45 #ifdef _WIN32_WCE | |
46 #define NO_GETKEYBOARDSTATE | |
47 #endif | |
48 | |
49 /* The translation table from a Microsoft VK keysym to a SDL keysym */ | |
50 static SDLKey VK_keymap[SDLK_LAST]; | |
51 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed); | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
52 static BOOL prev_shiftstates[2]; |
0 | 53 |
54 /* Masks for processing the windows KEYDOWN and KEYUP messages */ | |
55 #define REPEATED_KEYMASK (1<<30) | |
56 #define EXTENDED_KEYMASK (1<<24) | |
57 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
58 /* DJM: If the user setup the window for us, we want to save his window proc, |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
59 and give him a chance to handle some messages. */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
60 static WNDPROC userWindowProc = NULL; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
61 |
0 | 62 /* The main Win32 event handler */ |
63 LONG | |
64 DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
65 { | |
66 extern int posted; | |
67 | |
68 switch (msg) { | |
69 case WM_SYSKEYDOWN: | |
70 case WM_KEYDOWN: { | |
71 SDL_keysym keysym; | |
72 | |
73 /* Ignore repeated keys */ | |
74 if ( lParam&REPEATED_KEYMASK ) { | |
75 return(0); | |
76 } | |
77 switch (wParam) { | |
78 case VK_CONTROL: | |
79 if ( lParam&EXTENDED_KEYMASK ) | |
80 wParam = VK_RCONTROL; | |
81 else | |
82 wParam = VK_LCONTROL; | |
83 break; | |
84 case VK_SHIFT: | |
85 /* EXTENDED trick doesn't work here */ | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
86 if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) { |
558
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
87 wParam = VK_LSHIFT; |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
88 prev_shiftstates[0] = TRUE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
89 } else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) { |
558
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
90 wParam = VK_RSHIFT; |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
91 prev_shiftstates[1] = TRUE; |
558
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
92 } else { |
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
93 /* Huh? */ |
2312d983e1fe
Fixed left/right shift detection on Windows (thanks Mike!)
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
94 } |
0 | 95 break; |
96 case VK_MENU: | |
97 if ( lParam&EXTENDED_KEYMASK ) | |
98 wParam = VK_RMENU; | |
99 else | |
100 wParam = VK_LMENU; | |
101 break; | |
102 } | |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
103 #ifdef NO_GETKEYBOARDSTATE |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
104 /* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */ |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
105 if ( SDL_TranslateUNICODE ) { |
140
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
106 MSG m; |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
107 |
140
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
108 m.hwnd = hwnd; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
109 m.message = msg; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
110 m.wParam = wParam; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
111 m.lParam = lParam; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
112 m.time = 0; |
3c35d8f160bd
Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
113 if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) { |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
114 GetMessage(&m, hwnd, 0, WM_USER); |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
115 wParam = m.wParam; |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
116 } else { |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
117 wParam = 0; |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
118 } |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
119 } else { |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
120 wParam = 0; |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
121 } |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
122 #endif /* NO_GETKEYBOARDSTATE */ |
0 | 123 posted = SDL_PrivateKeyboard(SDL_PRESSED, |
124 TranslateKey(wParam,HIWORD(lParam),&keysym,1)); | |
125 } | |
126 return(0); | |
127 | |
128 case WM_SYSKEYUP: | |
129 case WM_KEYUP: { | |
130 SDL_keysym keysym; | |
131 | |
132 switch (wParam) { | |
133 case VK_CONTROL: | |
134 if ( lParam&EXTENDED_KEYMASK ) | |
135 wParam = VK_RCONTROL; | |
136 else | |
137 wParam = VK_LCONTROL; | |
138 break; | |
139 case VK_SHIFT: | |
140 /* EXTENDED trick doesn't work here */ | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
141 if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
142 wParam = VK_LSHIFT; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
143 prev_shiftstates[0] = FALSE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
144 } else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
145 wParam = VK_RSHIFT; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
146 prev_shiftstates[1] = FALSE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
147 } else { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
148 /* Huh? */ |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
149 } |
0 | 150 break; |
151 case VK_MENU: | |
152 if ( lParam&EXTENDED_KEYMASK ) | |
153 wParam = VK_RMENU; | |
154 else | |
155 wParam = VK_LMENU; | |
156 break; | |
157 } | |
158 posted = SDL_PrivateKeyboard(SDL_RELEASED, | |
159 TranslateKey(wParam,HIWORD(lParam),&keysym,0)); | |
160 } | |
161 return(0); | |
162 | |
726
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
163 #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER) |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
164 case WM_SYSCOMMAND: { |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
165 if ((wParam&0xFFF0)==SC_SCREENSAVE || |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
166 (wParam&0xFFF0)==SC_MONITORPOWER) |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
167 return(0); |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
168 } |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
169 /* Fall through to default processing */ |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
170 #endif /* SC_SCREENSAVE && SC_MONITORPOWER */ |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
171 |
0 | 172 default: { |
173 /* Only post the event if we're watching for it */ | |
174 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | |
175 SDL_SysWMmsg wmmsg; | |
176 | |
177 SDL_VERSION(&wmmsg.version); | |
178 wmmsg.hwnd = hwnd; | |
179 wmmsg.msg = msg; | |
180 wmmsg.wParam = wParam; | |
181 wmmsg.lParam = lParam; | |
182 posted = SDL_PrivateSysWMEvent(&wmmsg); | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
183 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
184 /* DJM: If the user isn't watching for private |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
185 messages in her SDL event loop, then pass it |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
186 along to any win32 specific window proc. |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
187 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
188 } else if (userWindowProc) { |
721
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
572
diff
changeset
|
189 return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam); |
0 | 190 } |
191 } | |
192 break; | |
193 } | |
194 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
195 } | |
196 | |
197 void DIB_PumpEvents(_THIS) | |
198 { | |
199 MSG msg; | |
200 | |
523
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
201 while ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) { |
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
202 if ( GetMessage(&msg, NULL, 0, 0) > 0 ) { |
0 | 203 DispatchMessage(&msg); |
204 } | |
205 } | |
206 } | |
207 | |
208 void DIB_InitOSKeymap(_THIS) | |
209 { | |
210 int i; | |
211 | |
212 /* Map the VK keysyms */ | |
213 for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i ) | |
214 VK_keymap[i] = SDLK_UNKNOWN; | |
215 | |
216 VK_keymap[VK_BACK] = SDLK_BACKSPACE; | |
217 VK_keymap[VK_TAB] = SDLK_TAB; | |
218 VK_keymap[VK_CLEAR] = SDLK_CLEAR; | |
219 VK_keymap[VK_RETURN] = SDLK_RETURN; | |
220 VK_keymap[VK_PAUSE] = SDLK_PAUSE; | |
221 VK_keymap[VK_ESCAPE] = SDLK_ESCAPE; | |
222 VK_keymap[VK_SPACE] = SDLK_SPACE; | |
223 VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE; | |
224 VK_keymap[VK_COMMA] = SDLK_COMMA; | |
225 VK_keymap[VK_MINUS] = SDLK_MINUS; | |
226 VK_keymap[VK_PERIOD] = SDLK_PERIOD; | |
227 VK_keymap[VK_SLASH] = SDLK_SLASH; | |
228 VK_keymap[VK_0] = SDLK_0; | |
229 VK_keymap[VK_1] = SDLK_1; | |
230 VK_keymap[VK_2] = SDLK_2; | |
231 VK_keymap[VK_3] = SDLK_3; | |
232 VK_keymap[VK_4] = SDLK_4; | |
233 VK_keymap[VK_5] = SDLK_5; | |
234 VK_keymap[VK_6] = SDLK_6; | |
235 VK_keymap[VK_7] = SDLK_7; | |
236 VK_keymap[VK_8] = SDLK_8; | |
237 VK_keymap[VK_9] = SDLK_9; | |
238 VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON; | |
239 VK_keymap[VK_EQUALS] = SDLK_EQUALS; | |
240 VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET; | |
241 VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH; | |
242 VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET; | |
243 VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
244 VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE; |
0 | 245 VK_keymap[VK_A] = SDLK_a; |
246 VK_keymap[VK_B] = SDLK_b; | |
247 VK_keymap[VK_C] = SDLK_c; | |
248 VK_keymap[VK_D] = SDLK_d; | |
249 VK_keymap[VK_E] = SDLK_e; | |
250 VK_keymap[VK_F] = SDLK_f; | |
251 VK_keymap[VK_G] = SDLK_g; | |
252 VK_keymap[VK_H] = SDLK_h; | |
253 VK_keymap[VK_I] = SDLK_i; | |
254 VK_keymap[VK_J] = SDLK_j; | |
255 VK_keymap[VK_K] = SDLK_k; | |
256 VK_keymap[VK_L] = SDLK_l; | |
257 VK_keymap[VK_M] = SDLK_m; | |
258 VK_keymap[VK_N] = SDLK_n; | |
259 VK_keymap[VK_O] = SDLK_o; | |
260 VK_keymap[VK_P] = SDLK_p; | |
261 VK_keymap[VK_Q] = SDLK_q; | |
262 VK_keymap[VK_R] = SDLK_r; | |
263 VK_keymap[VK_S] = SDLK_s; | |
264 VK_keymap[VK_T] = SDLK_t; | |
265 VK_keymap[VK_U] = SDLK_u; | |
266 VK_keymap[VK_V] = SDLK_v; | |
267 VK_keymap[VK_W] = SDLK_w; | |
268 VK_keymap[VK_X] = SDLK_x; | |
269 VK_keymap[VK_Y] = SDLK_y; | |
270 VK_keymap[VK_Z] = SDLK_z; | |
271 VK_keymap[VK_DELETE] = SDLK_DELETE; | |
272 | |
273 VK_keymap[VK_NUMPAD0] = SDLK_KP0; | |
274 VK_keymap[VK_NUMPAD1] = SDLK_KP1; | |
275 VK_keymap[VK_NUMPAD2] = SDLK_KP2; | |
276 VK_keymap[VK_NUMPAD3] = SDLK_KP3; | |
277 VK_keymap[VK_NUMPAD4] = SDLK_KP4; | |
278 VK_keymap[VK_NUMPAD5] = SDLK_KP5; | |
279 VK_keymap[VK_NUMPAD6] = SDLK_KP6; | |
280 VK_keymap[VK_NUMPAD7] = SDLK_KP7; | |
281 VK_keymap[VK_NUMPAD8] = SDLK_KP8; | |
282 VK_keymap[VK_NUMPAD9] = SDLK_KP9; | |
283 VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD; | |
284 VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE; | |
285 VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY; | |
286 VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS; | |
287 VK_keymap[VK_ADD] = SDLK_KP_PLUS; | |
288 | |
289 VK_keymap[VK_UP] = SDLK_UP; | |
290 VK_keymap[VK_DOWN] = SDLK_DOWN; | |
291 VK_keymap[VK_RIGHT] = SDLK_RIGHT; | |
292 VK_keymap[VK_LEFT] = SDLK_LEFT; | |
293 VK_keymap[VK_INSERT] = SDLK_INSERT; | |
294 VK_keymap[VK_HOME] = SDLK_HOME; | |
295 VK_keymap[VK_END] = SDLK_END; | |
296 VK_keymap[VK_PRIOR] = SDLK_PAGEUP; | |
297 VK_keymap[VK_NEXT] = SDLK_PAGEDOWN; | |
298 | |
299 VK_keymap[VK_F1] = SDLK_F1; | |
300 VK_keymap[VK_F2] = SDLK_F2; | |
301 VK_keymap[VK_F3] = SDLK_F3; | |
302 VK_keymap[VK_F4] = SDLK_F4; | |
303 VK_keymap[VK_F5] = SDLK_F5; | |
304 VK_keymap[VK_F6] = SDLK_F6; | |
305 VK_keymap[VK_F7] = SDLK_F7; | |
306 VK_keymap[VK_F8] = SDLK_F8; | |
307 VK_keymap[VK_F9] = SDLK_F9; | |
308 VK_keymap[VK_F10] = SDLK_F10; | |
309 VK_keymap[VK_F11] = SDLK_F11; | |
310 VK_keymap[VK_F12] = SDLK_F12; | |
311 VK_keymap[VK_F13] = SDLK_F13; | |
312 VK_keymap[VK_F14] = SDLK_F14; | |
313 VK_keymap[VK_F15] = SDLK_F15; | |
314 | |
315 VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK; | |
316 VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK; | |
317 VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK; | |
318 VK_keymap[VK_RSHIFT] = SDLK_RSHIFT; | |
319 VK_keymap[VK_LSHIFT] = SDLK_LSHIFT; | |
320 VK_keymap[VK_RCONTROL] = SDLK_RCTRL; | |
321 VK_keymap[VK_LCONTROL] = SDLK_LCTRL; | |
322 VK_keymap[VK_RMENU] = SDLK_RALT; | |
323 VK_keymap[VK_LMENU] = SDLK_LALT; | |
324 VK_keymap[VK_RWIN] = SDLK_RSUPER; | |
325 VK_keymap[VK_LWIN] = SDLK_LSUPER; | |
326 | |
327 VK_keymap[VK_HELP] = SDLK_HELP; | |
328 #ifdef VK_PRINT | |
329 VK_keymap[VK_PRINT] = SDLK_PRINT; | |
330 #endif | |
331 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; | |
332 VK_keymap[VK_CANCEL] = SDLK_BREAK; | |
333 VK_keymap[VK_APPS] = SDLK_MENU; | |
572
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
334 |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
335 prev_shiftstates[0] = FALSE; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
336 prev_shiftstates[1] = FALSE; |
0 | 337 } |
338 | |
339 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed) | |
340 { | |
341 /* Set the keysym information */ | |
342 keysym->scancode = (unsigned char) scancode; | |
343 keysym->sym = VK_keymap[vkey]; | |
344 keysym->mod = KMOD_NONE; | |
345 keysym->unicode = 0; | |
346 if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ | |
347 #ifdef NO_GETKEYBOARDSTATE | |
348 /* Uh oh, better hope the vkey is close enough.. */ | |
349 keysym->unicode = vkey; | |
350 #else | |
351 BYTE keystate[256]; | |
352 BYTE chars[2]; | |
353 | |
354 GetKeyboardState(keystate); | |
355 if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { | |
356 keysym->unicode = chars[0]; | |
357 } | |
358 #endif /* NO_GETKEYBOARDSTATE */ | |
359 } | |
360 return(keysym); | |
361 } | |
362 | |
363 int DIB_CreateWindow(_THIS) | |
364 { | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
365 #ifndef CS_BYTEALIGNCLIENT |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
366 #define CS_BYTEALIGNCLIENT 0 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
367 #endif |
0 | 368 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); |
369 if ( SDL_windowid ) { | |
370 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
371 |
974
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
372 if ( SDL_Window == NULL ) { |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
373 SDL_SetError("Couldn't get user specified window"); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
374 return(-1); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
375 } |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
376 |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
377 /* DJM: we want all event's for the user specified |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
378 window to be handled by SDL. |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
379 */ |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
380 userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
381 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage); |
0 | 382 } else { |
383 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, | |
384 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX), | |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
385 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL); |
0 | 386 if ( SDL_Window == NULL ) { |
387 SDL_SetError("Couldn't create window"); | |
388 return(-1); | |
389 } | |
390 ShowWindow(SDL_Window, SW_HIDE); | |
391 } | |
392 return(0); | |
393 } | |
394 | |
395 void DIB_DestroyWindow(_THIS) | |
396 { | |
974
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
397 if ( SDL_windowid ) { |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
398 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
399 } else { |
0 | 400 DestroyWindow(SDL_Window); |
401 } | |
402 } |