Mercurial > sdl-ios-xcode
annotate src/video/windib/SDL_dibevents.c @ 572:4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 20 Jan 2003 02:11:07 +0000 |
parents | 2312d983e1fe |
children | ab0656314eef |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 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 | |
163 default: { | |
164 /* Only post the event if we're watching for it */ | |
165 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | |
166 SDL_SysWMmsg wmmsg; | |
167 | |
168 SDL_VERSION(&wmmsg.version); | |
169 wmmsg.hwnd = hwnd; | |
170 wmmsg.msg = msg; | |
171 wmmsg.wParam = wParam; | |
172 wmmsg.lParam = lParam; | |
173 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
|
174 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
175 /* 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
|
176 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
|
177 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
|
178 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
179 } else if (userWindowProc) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
180 return userWindowProc(hwnd, msg, wParam, lParam); |
0 | 181 } |
182 } | |
183 break; | |
184 } | |
185 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
186 } | |
187 | |
188 void DIB_PumpEvents(_THIS) | |
189 { | |
190 MSG msg; | |
191 | |
523
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
192 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
|
193 if ( GetMessage(&msg, NULL, 0, 0) > 0 ) { |
0 | 194 DispatchMessage(&msg); |
195 } | |
196 } | |
197 } | |
198 | |
199 void DIB_InitOSKeymap(_THIS) | |
200 { | |
201 int i; | |
202 | |
203 /* Map the VK keysyms */ | |
204 for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i ) | |
205 VK_keymap[i] = SDLK_UNKNOWN; | |
206 | |
207 VK_keymap[VK_BACK] = SDLK_BACKSPACE; | |
208 VK_keymap[VK_TAB] = SDLK_TAB; | |
209 VK_keymap[VK_CLEAR] = SDLK_CLEAR; | |
210 VK_keymap[VK_RETURN] = SDLK_RETURN; | |
211 VK_keymap[VK_PAUSE] = SDLK_PAUSE; | |
212 VK_keymap[VK_ESCAPE] = SDLK_ESCAPE; | |
213 VK_keymap[VK_SPACE] = SDLK_SPACE; | |
214 VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE; | |
215 VK_keymap[VK_COMMA] = SDLK_COMMA; | |
216 VK_keymap[VK_MINUS] = SDLK_MINUS; | |
217 VK_keymap[VK_PERIOD] = SDLK_PERIOD; | |
218 VK_keymap[VK_SLASH] = SDLK_SLASH; | |
219 VK_keymap[VK_0] = SDLK_0; | |
220 VK_keymap[VK_1] = SDLK_1; | |
221 VK_keymap[VK_2] = SDLK_2; | |
222 VK_keymap[VK_3] = SDLK_3; | |
223 VK_keymap[VK_4] = SDLK_4; | |
224 VK_keymap[VK_5] = SDLK_5; | |
225 VK_keymap[VK_6] = SDLK_6; | |
226 VK_keymap[VK_7] = SDLK_7; | |
227 VK_keymap[VK_8] = SDLK_8; | |
228 VK_keymap[VK_9] = SDLK_9; | |
229 VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON; | |
230 VK_keymap[VK_EQUALS] = SDLK_EQUALS; | |
231 VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET; | |
232 VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH; | |
233 VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET; | |
234 VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
235 VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE; |
0 | 236 VK_keymap[VK_A] = SDLK_a; |
237 VK_keymap[VK_B] = SDLK_b; | |
238 VK_keymap[VK_C] = SDLK_c; | |
239 VK_keymap[VK_D] = SDLK_d; | |
240 VK_keymap[VK_E] = SDLK_e; | |
241 VK_keymap[VK_F] = SDLK_f; | |
242 VK_keymap[VK_G] = SDLK_g; | |
243 VK_keymap[VK_H] = SDLK_h; | |
244 VK_keymap[VK_I] = SDLK_i; | |
245 VK_keymap[VK_J] = SDLK_j; | |
246 VK_keymap[VK_K] = SDLK_k; | |
247 VK_keymap[VK_L] = SDLK_l; | |
248 VK_keymap[VK_M] = SDLK_m; | |
249 VK_keymap[VK_N] = SDLK_n; | |
250 VK_keymap[VK_O] = SDLK_o; | |
251 VK_keymap[VK_P] = SDLK_p; | |
252 VK_keymap[VK_Q] = SDLK_q; | |
253 VK_keymap[VK_R] = SDLK_r; | |
254 VK_keymap[VK_S] = SDLK_s; | |
255 VK_keymap[VK_T] = SDLK_t; | |
256 VK_keymap[VK_U] = SDLK_u; | |
257 VK_keymap[VK_V] = SDLK_v; | |
258 VK_keymap[VK_W] = SDLK_w; | |
259 VK_keymap[VK_X] = SDLK_x; | |
260 VK_keymap[VK_Y] = SDLK_y; | |
261 VK_keymap[VK_Z] = SDLK_z; | |
262 VK_keymap[VK_DELETE] = SDLK_DELETE; | |
263 | |
264 VK_keymap[VK_NUMPAD0] = SDLK_KP0; | |
265 VK_keymap[VK_NUMPAD1] = SDLK_KP1; | |
266 VK_keymap[VK_NUMPAD2] = SDLK_KP2; | |
267 VK_keymap[VK_NUMPAD3] = SDLK_KP3; | |
268 VK_keymap[VK_NUMPAD4] = SDLK_KP4; | |
269 VK_keymap[VK_NUMPAD5] = SDLK_KP5; | |
270 VK_keymap[VK_NUMPAD6] = SDLK_KP6; | |
271 VK_keymap[VK_NUMPAD7] = SDLK_KP7; | |
272 VK_keymap[VK_NUMPAD8] = SDLK_KP8; | |
273 VK_keymap[VK_NUMPAD9] = SDLK_KP9; | |
274 VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD; | |
275 VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE; | |
276 VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY; | |
277 VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS; | |
278 VK_keymap[VK_ADD] = SDLK_KP_PLUS; | |
279 | |
280 VK_keymap[VK_UP] = SDLK_UP; | |
281 VK_keymap[VK_DOWN] = SDLK_DOWN; | |
282 VK_keymap[VK_RIGHT] = SDLK_RIGHT; | |
283 VK_keymap[VK_LEFT] = SDLK_LEFT; | |
284 VK_keymap[VK_INSERT] = SDLK_INSERT; | |
285 VK_keymap[VK_HOME] = SDLK_HOME; | |
286 VK_keymap[VK_END] = SDLK_END; | |
287 VK_keymap[VK_PRIOR] = SDLK_PAGEUP; | |
288 VK_keymap[VK_NEXT] = SDLK_PAGEDOWN; | |
289 | |
290 VK_keymap[VK_F1] = SDLK_F1; | |
291 VK_keymap[VK_F2] = SDLK_F2; | |
292 VK_keymap[VK_F3] = SDLK_F3; | |
293 VK_keymap[VK_F4] = SDLK_F4; | |
294 VK_keymap[VK_F5] = SDLK_F5; | |
295 VK_keymap[VK_F6] = SDLK_F6; | |
296 VK_keymap[VK_F7] = SDLK_F7; | |
297 VK_keymap[VK_F8] = SDLK_F8; | |
298 VK_keymap[VK_F9] = SDLK_F9; | |
299 VK_keymap[VK_F10] = SDLK_F10; | |
300 VK_keymap[VK_F11] = SDLK_F11; | |
301 VK_keymap[VK_F12] = SDLK_F12; | |
302 VK_keymap[VK_F13] = SDLK_F13; | |
303 VK_keymap[VK_F14] = SDLK_F14; | |
304 VK_keymap[VK_F15] = SDLK_F15; | |
305 | |
306 VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK; | |
307 VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK; | |
308 VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK; | |
309 VK_keymap[VK_RSHIFT] = SDLK_RSHIFT; | |
310 VK_keymap[VK_LSHIFT] = SDLK_LSHIFT; | |
311 VK_keymap[VK_RCONTROL] = SDLK_RCTRL; | |
312 VK_keymap[VK_LCONTROL] = SDLK_LCTRL; | |
313 VK_keymap[VK_RMENU] = SDLK_RALT; | |
314 VK_keymap[VK_LMENU] = SDLK_LALT; | |
315 VK_keymap[VK_RWIN] = SDLK_RSUPER; | |
316 VK_keymap[VK_LWIN] = SDLK_LSUPER; | |
317 | |
318 VK_keymap[VK_HELP] = SDLK_HELP; | |
319 #ifdef VK_PRINT | |
320 VK_keymap[VK_PRINT] = SDLK_PRINT; | |
321 #endif | |
322 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; | |
323 VK_keymap[VK_CANCEL] = SDLK_BREAK; | |
324 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
|
325 |
4c740ee76027
Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
Sam Lantinga <slouken@libsdl.org>
parents:
558
diff
changeset
|
326 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
|
327 prev_shiftstates[1] = FALSE; |
0 | 328 } |
329 | |
330 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed) | |
331 { | |
332 /* Set the keysym information */ | |
333 keysym->scancode = (unsigned char) scancode; | |
334 keysym->sym = VK_keymap[vkey]; | |
335 keysym->mod = KMOD_NONE; | |
336 keysym->unicode = 0; | |
337 if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ | |
338 #ifdef NO_GETKEYBOARDSTATE | |
339 /* Uh oh, better hope the vkey is close enough.. */ | |
340 keysym->unicode = vkey; | |
341 #else | |
342 BYTE keystate[256]; | |
343 BYTE chars[2]; | |
344 | |
345 GetKeyboardState(keystate); | |
346 if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { | |
347 keysym->unicode = chars[0]; | |
348 } | |
349 #endif /* NO_GETKEYBOARDSTATE */ | |
350 } | |
351 return(keysym); | |
352 } | |
353 | |
354 int DIB_CreateWindow(_THIS) | |
355 { | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
356 #ifndef CS_BYTEALIGNCLIENT |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
357 #define CS_BYTEALIGNCLIENT 0 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
421
diff
changeset
|
358 #endif |
0 | 359 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); |
360 if ( SDL_windowid ) { | |
361 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
|
362 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
363 /* DJM: we want all event's for the user specified |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
364 window to be handled by SDL. |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
365 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
366 if (SDL_Window) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
367 userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
368 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
140
diff
changeset
|
369 } |
0 | 370 } else { |
371 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, | |
372 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX), | |
373 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL); | |
374 if ( SDL_Window == NULL ) { | |
375 SDL_SetError("Couldn't create window"); | |
376 return(-1); | |
377 } | |
378 ShowWindow(SDL_Window, SW_HIDE); | |
379 } | |
380 return(0); | |
381 } | |
382 | |
383 void DIB_DestroyWindow(_THIS) | |
384 { | |
385 if ( SDL_windowid == NULL ) { | |
386 DestroyWindow(SDL_Window); | |
387 } | |
388 } |