Mercurial > sdl-ios-xcode
annotate src/video/windib/SDL_dibevents.c @ 1216:f8fc6fdd589d
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 02 Jan 2006 09:13:16 +0000 |
parents | 51a8702d8ecd |
children | 86d0d01290ea |
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 } |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
120 #endif /* NO_GETKEYBOARDSTATE */ |
0 | 121 posted = SDL_PrivateKeyboard(SDL_PRESSED, |
122 TranslateKey(wParam,HIWORD(lParam),&keysym,1)); | |
123 } | |
124 return(0); | |
125 | |
126 case WM_SYSKEYUP: | |
127 case WM_KEYUP: { | |
128 SDL_keysym keysym; | |
129 | |
130 switch (wParam) { | |
131 case VK_CONTROL: | |
132 if ( lParam&EXTENDED_KEYMASK ) | |
133 wParam = VK_RCONTROL; | |
134 else | |
135 wParam = VK_LCONTROL; | |
136 break; | |
137 case VK_SHIFT: | |
138 /* 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
|
139 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
|
140 wParam = VK_LSHIFT; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
141 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
|
142 } 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
|
143 wParam = VK_RSHIFT; |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
144 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
|
145 } else { |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
146 /* Huh? */ |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
147 } |
0 | 148 break; |
149 case VK_MENU: | |
150 if ( lParam&EXTENDED_KEYMASK ) | |
151 wParam = VK_RMENU; | |
152 else | |
153 wParam = VK_LMENU; | |
154 break; | |
155 } | |
156 posted = SDL_PrivateKeyboard(SDL_RELEASED, | |
157 TranslateKey(wParam,HIWORD(lParam),&keysym,0)); | |
158 } | |
159 return(0); | |
160 | |
726
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
161 #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER) |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
162 case WM_SYSCOMMAND: { |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
163 if ((wParam&0xFFF0)==SC_SCREENSAVE || |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
164 (wParam&0xFFF0)==SC_MONITORPOWER) |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
165 return(0); |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
166 } |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
167 /* Fall through to default processing */ |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
168 #endif /* SC_SCREENSAVE && SC_MONITORPOWER */ |
5429a06aa816
SDL12: Disable screensaver in windib driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
721
diff
changeset
|
169 |
0 | 170 default: { |
171 /* Only post the event if we're watching for it */ | |
172 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | |
173 SDL_SysWMmsg wmmsg; | |
174 | |
175 SDL_VERSION(&wmmsg.version); | |
176 wmmsg.hwnd = hwnd; | |
177 wmmsg.msg = msg; | |
178 wmmsg.wParam = wParam; | |
179 wmmsg.lParam = lParam; | |
180 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
|
181 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
182 /* 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
|
183 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
|
184 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
|
185 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
186 } else if (userWindowProc) { |
721
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
572
diff
changeset
|
187 return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam); |
0 | 188 } |
189 } | |
190 break; | |
191 } | |
192 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
193 } | |
194 | |
195 void DIB_PumpEvents(_THIS) | |
196 { | |
197 MSG msg; | |
198 | |
523
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
199 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
|
200 if ( GetMessage(&msg, NULL, 0, 0) > 0 ) { |
0 | 201 DispatchMessage(&msg); |
202 } | |
203 } | |
204 } | |
205 | |
206 void DIB_InitOSKeymap(_THIS) | |
207 { | |
208 int i; | |
209 | |
210 /* Map the VK keysyms */ | |
211 for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i ) | |
212 VK_keymap[i] = SDLK_UNKNOWN; | |
213 | |
214 VK_keymap[VK_BACK] = SDLK_BACKSPACE; | |
215 VK_keymap[VK_TAB] = SDLK_TAB; | |
216 VK_keymap[VK_CLEAR] = SDLK_CLEAR; | |
217 VK_keymap[VK_RETURN] = SDLK_RETURN; | |
218 VK_keymap[VK_PAUSE] = SDLK_PAUSE; | |
219 VK_keymap[VK_ESCAPE] = SDLK_ESCAPE; | |
220 VK_keymap[VK_SPACE] = SDLK_SPACE; | |
221 VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE; | |
222 VK_keymap[VK_COMMA] = SDLK_COMMA; | |
223 VK_keymap[VK_MINUS] = SDLK_MINUS; | |
224 VK_keymap[VK_PERIOD] = SDLK_PERIOD; | |
225 VK_keymap[VK_SLASH] = SDLK_SLASH; | |
226 VK_keymap[VK_0] = SDLK_0; | |
227 VK_keymap[VK_1] = SDLK_1; | |
228 VK_keymap[VK_2] = SDLK_2; | |
229 VK_keymap[VK_3] = SDLK_3; | |
230 VK_keymap[VK_4] = SDLK_4; | |
231 VK_keymap[VK_5] = SDLK_5; | |
232 VK_keymap[VK_6] = SDLK_6; | |
233 VK_keymap[VK_7] = SDLK_7; | |
234 VK_keymap[VK_8] = SDLK_8; | |
235 VK_keymap[VK_9] = SDLK_9; | |
236 VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON; | |
237 VK_keymap[VK_EQUALS] = SDLK_EQUALS; | |
238 VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET; | |
239 VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH; | |
240 VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET; | |
241 VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
242 VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE; |
0 | 243 VK_keymap[VK_A] = SDLK_a; |
244 VK_keymap[VK_B] = SDLK_b; | |
245 VK_keymap[VK_C] = SDLK_c; | |
246 VK_keymap[VK_D] = SDLK_d; | |
247 VK_keymap[VK_E] = SDLK_e; | |
248 VK_keymap[VK_F] = SDLK_f; | |
249 VK_keymap[VK_G] = SDLK_g; | |
250 VK_keymap[VK_H] = SDLK_h; | |
251 VK_keymap[VK_I] = SDLK_i; | |
252 VK_keymap[VK_J] = SDLK_j; | |
253 VK_keymap[VK_K] = SDLK_k; | |
254 VK_keymap[VK_L] = SDLK_l; | |
255 VK_keymap[VK_M] = SDLK_m; | |
256 VK_keymap[VK_N] = SDLK_n; | |
257 VK_keymap[VK_O] = SDLK_o; | |
258 VK_keymap[VK_P] = SDLK_p; | |
259 VK_keymap[VK_Q] = SDLK_q; | |
260 VK_keymap[VK_R] = SDLK_r; | |
261 VK_keymap[VK_S] = SDLK_s; | |
262 VK_keymap[VK_T] = SDLK_t; | |
263 VK_keymap[VK_U] = SDLK_u; | |
264 VK_keymap[VK_V] = SDLK_v; | |
265 VK_keymap[VK_W] = SDLK_w; | |
266 VK_keymap[VK_X] = SDLK_x; | |
267 VK_keymap[VK_Y] = SDLK_y; | |
268 VK_keymap[VK_Z] = SDLK_z; | |
269 VK_keymap[VK_DELETE] = SDLK_DELETE; | |
270 | |
271 VK_keymap[VK_NUMPAD0] = SDLK_KP0; | |
272 VK_keymap[VK_NUMPAD1] = SDLK_KP1; | |
273 VK_keymap[VK_NUMPAD2] = SDLK_KP2; | |
274 VK_keymap[VK_NUMPAD3] = SDLK_KP3; | |
275 VK_keymap[VK_NUMPAD4] = SDLK_KP4; | |
276 VK_keymap[VK_NUMPAD5] = SDLK_KP5; | |
277 VK_keymap[VK_NUMPAD6] = SDLK_KP6; | |
278 VK_keymap[VK_NUMPAD7] = SDLK_KP7; | |
279 VK_keymap[VK_NUMPAD8] = SDLK_KP8; | |
280 VK_keymap[VK_NUMPAD9] = SDLK_KP9; | |
281 VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD; | |
282 VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE; | |
283 VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY; | |
284 VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS; | |
285 VK_keymap[VK_ADD] = SDLK_KP_PLUS; | |
286 | |
287 VK_keymap[VK_UP] = SDLK_UP; | |
288 VK_keymap[VK_DOWN] = SDLK_DOWN; | |
289 VK_keymap[VK_RIGHT] = SDLK_RIGHT; | |
290 VK_keymap[VK_LEFT] = SDLK_LEFT; | |
291 VK_keymap[VK_INSERT] = SDLK_INSERT; | |
292 VK_keymap[VK_HOME] = SDLK_HOME; | |
293 VK_keymap[VK_END] = SDLK_END; | |
294 VK_keymap[VK_PRIOR] = SDLK_PAGEUP; | |
295 VK_keymap[VK_NEXT] = SDLK_PAGEDOWN; | |
296 | |
297 VK_keymap[VK_F1] = SDLK_F1; | |
298 VK_keymap[VK_F2] = SDLK_F2; | |
299 VK_keymap[VK_F3] = SDLK_F3; | |
300 VK_keymap[VK_F4] = SDLK_F4; | |
301 VK_keymap[VK_F5] = SDLK_F5; | |
302 VK_keymap[VK_F6] = SDLK_F6; | |
303 VK_keymap[VK_F7] = SDLK_F7; | |
304 VK_keymap[VK_F8] = SDLK_F8; | |
305 VK_keymap[VK_F9] = SDLK_F9; | |
306 VK_keymap[VK_F10] = SDLK_F10; | |
307 VK_keymap[VK_F11] = SDLK_F11; | |
308 VK_keymap[VK_F12] = SDLK_F12; | |
309 VK_keymap[VK_F13] = SDLK_F13; | |
310 VK_keymap[VK_F14] = SDLK_F14; | |
311 VK_keymap[VK_F15] = SDLK_F15; | |
312 | |
313 VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK; | |
314 VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK; | |
315 VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK; | |
316 VK_keymap[VK_RSHIFT] = SDLK_RSHIFT; | |
317 VK_keymap[VK_LSHIFT] = SDLK_LSHIFT; | |
318 VK_keymap[VK_RCONTROL] = SDLK_RCTRL; | |
319 VK_keymap[VK_LCONTROL] = SDLK_LCTRL; | |
320 VK_keymap[VK_RMENU] = SDLK_RALT; | |
321 VK_keymap[VK_LMENU] = SDLK_LALT; | |
322 VK_keymap[VK_RWIN] = SDLK_RSUPER; | |
323 VK_keymap[VK_LWIN] = SDLK_LSUPER; | |
324 | |
325 VK_keymap[VK_HELP] = SDLK_HELP; | |
326 #ifdef VK_PRINT | |
327 VK_keymap[VK_PRINT] = SDLK_PRINT; | |
328 #endif | |
329 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; | |
330 VK_keymap[VK_CANCEL] = SDLK_BREAK; | |
331 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
|
332 |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
333 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
|
334 prev_shiftstates[1] = FALSE; |
0 | 335 } |
336 | |
337 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed) | |
338 { | |
339 /* Set the keysym information */ | |
340 keysym->scancode = (unsigned char) scancode; | |
341 keysym->sym = VK_keymap[vkey]; | |
342 keysym->mod = KMOD_NONE; | |
343 keysym->unicode = 0; | |
344 if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ | |
345 #ifdef NO_GETKEYBOARDSTATE | |
346 /* Uh oh, better hope the vkey is close enough.. */ | |
347 keysym->unicode = vkey; | |
348 #else | |
349 BYTE keystate[256]; | |
350 BYTE chars[2]; | |
351 | |
352 GetKeyboardState(keystate); | |
353 if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { | |
354 keysym->unicode = chars[0]; | |
355 } | |
356 #endif /* NO_GETKEYBOARDSTATE */ | |
357 } | |
358 return(keysym); | |
359 } | |
360 | |
361 int DIB_CreateWindow(_THIS) | |
362 { | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
363 #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
364 wchar_t *SDL_windowid_t; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
365 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
366 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
367 #ifndef CS_BYTEALIGNCLIENT |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
368 #define CS_BYTEALIGNCLIENT 0 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
369 #endif |
0 | 370 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); |
371 if ( SDL_windowid ) { | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
372 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
373 // wince 2.1 does not have strtol |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
374 #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
375 SDL_windowid_t = malloc((strlen(SDL_windowid) + 1) * sizeof(wchar_t)); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
376 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, SDL_windowid, -1, SDL_windowid_t, strlen(SDL_windowid) + 1); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
377 SDL_Window = (HWND)wcstol(SDL_windowid_t, NULL, 0); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
378 free(SDL_windowid_t); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
379 #else |
0 | 380 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1048
diff
changeset
|
381 #endif |
974
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
382 if ( SDL_Window == NULL ) { |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
383 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
|
384 return(-1); |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
385 } |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
386 |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
387 /* 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
|
388 window to be handled by SDL. |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
389 */ |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
390 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
|
391 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage); |
0 | 392 } else { |
393 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, | |
394 (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
|
395 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL); |
0 | 396 if ( SDL_Window == NULL ) { |
397 SDL_SetError("Couldn't create window"); | |
398 return(-1); | |
399 } | |
400 ShowWindow(SDL_Window, SW_HIDE); | |
401 } | |
402 return(0); | |
403 } | |
404 | |
405 void DIB_DestroyWindow(_THIS) | |
406 { | |
974
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
407 if ( SDL_windowid ) { |
b8427b5151ed
Restore the user specified window proc after shutdown
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
408 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
|
409 } else { |
0 | 410 DestroyWindow(SDL_Window); |
411 } | |
412 } |