Mercurial > sdl-ios-xcode
annotate src/video/windx5/SDL_dx5events.c @ 1348:40d0975c1769
Date: Mon, 6 Feb 2006 11:41:04 -0500
From: "mystml@adinet.com.uy"
Subject: [SDL] ALT-F4 using DirectX
My game isn't getting SDL_QUIT when I press ALT-F4 using the DirectX
driver; it does get SDL_QUIT when I press the red X in the window.
I tracked this down to DX5_HandleMessage() in SDL_dx5events.c;
WM_SYSKEYDOWN is being trapped and ignored which causes Windows not to post
a WM_CLOSE, hence no SDL_QUIT is being generated.
The relevant code is this :
/* The keyboard is handled via DirectInput */
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_KEYDOWN: {
/* Ignore windows keyboard messages */;
}
return(0);
If I comment the WM_SYSKEYDOWN case, it falls through DefWindowProc() and
ALT-F4 starts working again.
I'm not sure about the best way to fix this. One option is handling ALT-F4
as a particular case somehow, but doesn't sound good. Another option would
be to handle WM_SYSKEYDOWN separately and breaking instead of returning 0,
so processing falls through and goes to DefWindowProc which does The Right
Thing (TM). This seems to be the minimal change that makes ALT-F4 work and
normal keyboard input continues to work.
Does this sound reasonable? Am I overlooking anything? Do I submit a patch?
--Gabriel
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 08 Feb 2006 17:19:43 +0000 |
parents | 604d73db6802 |
children | c71e05b4dc2e |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1303
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* CAUTION!!!! If you modify this file, check ../windib/SDL_sysevents.c */ | |
24 | |
25 #include "directx.h" | |
26 | |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
27 #include "SDL_stdlib.h" |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
28 #include "SDL_string.h" |
0 | 29 #include "SDL_events.h" |
30 #include "SDL_video.h" | |
31 #include "SDL_error.h" | |
32 #include "SDL_syswm.h" | |
33 #include "SDL_sysevents.h" | |
34 #include "SDL_events_c.h" | |
35 #include "SDL_lowvideo.h" | |
36 #include "SDL_dx5video.h" | |
37 | |
38 #ifndef WM_APP | |
39 #define WM_APP 0x8000 | |
40 #endif | |
41 | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
42 #ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
43 #define NO_GETKEYBOARDSTATE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
44 #endif |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
45 |
0 | 46 /* The keyboard and mouse device input */ |
47 #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */ | |
536
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
48 #define INPUT_QSIZE 512 /* Buffer up to 512 input messages */ |
0 | 49 |
50 static LPDIRECTINPUT dinput = NULL; | |
51 static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS]; | |
52 static HANDLE SDL_DIevt[MAX_INPUTS]; | |
53 static void (*SDL_DIfun[MAX_INPUTS])(const int, DIDEVICEOBJECTDATA *); | |
54 static int SDL_DIndev = 0; | |
55 static int mouse_lost; | |
56 static int mouse_pressed; | |
491
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
57 static int mouse_buttons_swapped = 0; |
0 | 58 |
59 /* The translation table from a DirectInput scancode to an SDL keysym */ | |
60 static SDLKey DIK_keymap[256]; | |
61 static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed); | |
62 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
63 /* 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:
61
diff
changeset
|
64 and give him a chance to handle some messages. */ |
1303
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
65 #ifdef STRICT |
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
66 #define WNDPROCTYPE WNDPROC |
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
67 #else |
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
68 #define WNDPROCTYPE FARPROC |
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
69 #endif |
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
70 static WNDPROCTYPE userWindowProc = NULL; |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
71 |
1114
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
72 static HWND GetTopLevelParent(HWND hWnd) |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
73 { |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
74 HWND hParentWnd; |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
75 while (1) |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
76 { |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
77 hParentWnd = GetParent(hWnd); |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
78 if (hParentWnd == NULL) |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
79 break; |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
80 hWnd = hParentWnd; |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
81 } |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
82 return hWnd; |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
83 } |
242a35a85852
Patches to make SDL compatible with Win95 again.
Ryan C. Gordon <icculus@icculus.org>
parents:
975
diff
changeset
|
84 |
0 | 85 /* Convert a DirectInput return code to a text message */ |
86 static void SetDIerror(char *function, int code) | |
87 { | |
88 static char *error; | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
89 static char errbuf[1024]; |
0 | 90 |
91 errbuf[0] = 0; | |
92 switch (code) { | |
93 case DIERR_GENERIC: | |
94 error = "Undefined error!"; | |
95 break; | |
96 case DIERR_OLDDIRECTINPUTVERSION: | |
97 error = "Your version of DirectInput needs upgrading"; | |
98 break; | |
99 case DIERR_INVALIDPARAM: | |
100 error = "Invalid parameters"; | |
101 break; | |
102 case DIERR_OUTOFMEMORY: | |
103 error = "Out of memory"; | |
104 break; | |
105 case DIERR_DEVICENOTREG: | |
106 error = "Device not registered"; | |
107 break; | |
108 case DIERR_NOINTERFACE: | |
109 error = "Interface not supported"; | |
110 break; | |
111 case DIERR_NOTINITIALIZED: | |
112 error = "Device not initialized"; | |
113 break; | |
114 default: | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
115 SDL_snprintf(errbuf, SDL_arraysize(errbuf), |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
116 "%s: Unknown DirectInput error: 0x%x", |
0 | 117 function, code); |
118 break; | |
119 } | |
120 if ( ! errbuf[0] ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
121 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); |
0 | 122 } |
123 SDL_SetError("%s", errbuf); | |
124 return; | |
125 } | |
126 | |
127 /* Initialize DirectInput | |
128 Note: If NONEXCLUSIVE access is requested for the devices, normal | |
129 windows input messages will continue to be generated for that | |
130 input device, in addition to DirectInput messages. | |
131 */ | |
132 static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA *events); | |
133 static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *events); | |
134 struct { | |
135 char *name; | |
136 REFGUID guid; | |
137 LPCDIDATAFORMAT format; | |
138 DWORD win_level; | |
139 DWORD raw_level; | |
140 void (*fun)(const int numevents, DIDEVICEOBJECTDATA *events); | |
141 } inputs[] = { | |
142 { "keyboard", | |
143 &GUID_SysKeyboard, &c_dfDIKeyboard, | |
144 (DISCL_FOREGROUND|DISCL_NONEXCLUSIVE), | |
145 (DISCL_FOREGROUND|DISCL_NONEXCLUSIVE), handle_keyboard }, | |
146 { "mouse", | |
147 &GUID_SysMouse, &c_dfDIMouse, | |
148 (DISCL_FOREGROUND|DISCL_NONEXCLUSIVE), | |
149 (DISCL_FOREGROUND|DISCL_EXCLUSIVE), handle_mouse }, | |
150 { NULL, NULL, NULL, 0, 0, NULL } | |
151 }; | |
152 | |
153 static int DX5_DInputInit(_THIS) | |
154 { | |
155 int i; | |
156 LPDIRECTINPUTDEVICE device; | |
157 HRESULT result; | |
158 DIPROPDWORD dipdw; | |
970
fb8b91365766
Date: Tue, 19 Oct 2004 23:04:58 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
159 HWND topwnd; |
0 | 160 |
161 /* Create the DirectInput object */ | |
162 result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION, | |
163 &dinput, NULL); | |
164 if ( result != DI_OK ) { | |
165 SetDIerror("DirectInputCreate", result); | |
166 return(-1); | |
167 } | |
168 | |
169 /* Create all of our registered input devices */ | |
170 SDL_DIndev = 0; | |
171 for ( i=0; inputs[i].name; ++i ) { | |
172 /* Create the DirectInput device */ | |
173 result = IDirectInput_CreateDevice(dinput, inputs[i].guid, | |
174 &device, NULL); | |
175 if ( result != DI_OK ) { | |
176 SetDIerror("DirectInput::CreateDevice", result); | |
177 return(-1); | |
178 } | |
179 result = IDirectInputDevice_QueryInterface(device, | |
180 &IID_IDirectInputDevice2, (LPVOID *)&SDL_DIdev[i]); | |
181 IDirectInputDevice_Release(device); | |
182 if ( result != DI_OK ) { | |
183 SetDIerror("DirectInputDevice::QueryInterface", result); | |
184 return(-1); | |
185 } | |
1115
040aa1bea9fc
Fixed mismerged patch.
Ryan C. Gordon <icculus@icculus.org>
parents:
1114
diff
changeset
|
186 topwnd = GetTopLevelParent(SDL_Window); |
0 | 187 result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], |
970
fb8b91365766
Date: Tue, 19 Oct 2004 23:04:58 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
188 topwnd, inputs[i].win_level); |
0 | 189 if ( result != DI_OK ) { |
190 SetDIerror("DirectInputDevice::SetCooperativeLevel", | |
191 result); | |
192 return(-1); | |
193 } | |
194 result = IDirectInputDevice2_SetDataFormat(SDL_DIdev[i], | |
195 inputs[i].format); | |
196 if ( result != DI_OK ) { | |
197 SetDIerror("DirectInputDevice::SetDataFormat", result); | |
198 return(-1); | |
199 } | |
200 | |
201 /* Set buffered input -- we aren't polling */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
202 SDL_memset(&dipdw, 0, sizeof(dipdw)); |
0 | 203 dipdw.diph.dwSize = sizeof(dipdw); |
204 dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); | |
205 dipdw.diph.dwObj = 0; | |
206 dipdw.diph.dwHow = DIPH_DEVICE; | |
207 dipdw.dwData = INPUT_QSIZE; | |
208 result = IDirectInputDevice2_SetProperty(SDL_DIdev[i], | |
209 DIPROP_BUFFERSIZE, &dipdw.diph); | |
210 if ( result != DI_OK ) { | |
211 SetDIerror("DirectInputDevice::SetProperty", result); | |
212 return(-1); | |
213 } | |
214 | |
215 /* Create an event to be signaled when input is ready */ | |
216 SDL_DIevt[i] = CreateEvent(NULL, FALSE, FALSE, NULL); | |
217 if ( SDL_DIevt[i] == NULL ) { | |
218 SDL_SetError("Couldn't create DirectInput event"); | |
219 return(-1); | |
220 } | |
221 result = IDirectInputDevice2_SetEventNotification(SDL_DIdev[i], | |
222 SDL_DIevt[i]); | |
223 if ( result != DI_OK ) { | |
224 SetDIerror("DirectInputDevice::SetEventNotification", | |
225 result); | |
226 return(-1); | |
227 } | |
228 SDL_DIfun[i] = inputs[i].fun; | |
229 | |
230 /* Acquire the device for input */ | |
231 IDirectInputDevice2_Acquire(SDL_DIdev[i]); | |
232 | |
233 /* Increment the number of devices we have */ | |
234 ++SDL_DIndev; | |
235 } | |
236 mouse_pressed = 0; | |
491
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
237 mouse_buttons_swapped = GetSystemMetrics(SM_SWAPBUTTON); |
0 | 238 |
239 /* DirectInput is ready! */ | |
240 return(0); | |
241 } | |
242 | |
243 /* Clean up DirectInput */ | |
244 static void DX5_DInputQuit(_THIS) | |
245 { | |
246 int i; | |
247 | |
248 if ( dinput != NULL ) { | |
249 /* Close and release all DirectInput devices */ | |
250 for ( i=0; i<MAX_INPUTS; ++i ) { | |
251 if ( SDL_DIdev[i] != NULL ) { | |
252 IDirectInputDevice2_Unacquire(SDL_DIdev[i]); | |
253 IDirectInputDevice2_SetEventNotification( | |
254 SDL_DIdev[i], NULL); | |
255 if ( SDL_DIevt[i] != NULL ) { | |
256 CloseHandle(SDL_DIevt[i]); | |
257 SDL_DIevt[i] = NULL; | |
258 } | |
259 IDirectInputDevice2_Release(SDL_DIdev[i]); | |
260 SDL_DIdev[i] = NULL; | |
261 } | |
262 } | |
263 /* Release DirectInput */ | |
264 IDirectInput_Release(dinput); | |
265 dinput = NULL; | |
266 } | |
267 } | |
268 | |
269 /* Flag to tell SDL whether or not we queued an event */ | |
270 static int posted = 0; | |
271 | |
272 /* Input event handler functions */ | |
273 static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA *keybuf) | |
274 { | |
275 int i; | |
276 SDL_keysym keysym; | |
277 | |
278 /* Translate keyboard messages */ | |
279 for ( i=0; i<numevents; ++i ) { | |
280 if ( keybuf[i].dwData & 0x80 ) { | |
281 posted = SDL_PrivateKeyboard(SDL_PRESSED, | |
282 TranslateKey(keybuf[i].dwOfs, &keysym, 1)); | |
283 } else { | |
284 posted = SDL_PrivateKeyboard(SDL_RELEASED, | |
285 TranslateKey(keybuf[i].dwOfs, &keysym, 0)); | |
286 } | |
287 } | |
288 } | |
289 static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf) | |
290 { | |
291 int i; | |
292 Sint16 xrel, yrel; | |
293 Uint8 state; | |
294 Uint8 button; | |
536
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
295 DWORD timestamp = 0; |
0 | 296 |
717
42ed44b2c8b6
Date: Sun, 14 Sep 2003 17:04:55 -0400
Ryan C. Gordon <icculus@icculus.org>
parents:
536
diff
changeset
|
297 /* Sanity check. Mailing list reports this being NULL unexpectedly. */ |
42ed44b2c8b6
Date: Sun, 14 Sep 2003 17:04:55 -0400
Ryan C. Gordon <icculus@icculus.org>
parents:
536
diff
changeset
|
298 if (SDL_PublicSurface == NULL) { |
42ed44b2c8b6
Date: Sun, 14 Sep 2003 17:04:55 -0400
Ryan C. Gordon <icculus@icculus.org>
parents:
536
diff
changeset
|
299 return; |
42ed44b2c8b6
Date: Sun, 14 Sep 2003 17:04:55 -0400
Ryan C. Gordon <icculus@icculus.org>
parents:
536
diff
changeset
|
300 } |
42ed44b2c8b6
Date: Sun, 14 Sep 2003 17:04:55 -0400
Ryan C. Gordon <icculus@icculus.org>
parents:
536
diff
changeset
|
301 |
0 | 302 /* If we are in windowed mode, Windows is taking care of the mouse */ |
325
1b5457c0a8ad
Fixed the bug where mouse cursor and SDL mouse coordinates didn't match
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
303 if ( (SDL_PublicSurface->flags & SDL_OPENGL) || |
1b5457c0a8ad
Fixed the bug where mouse cursor and SDL mouse coordinates didn't match
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
304 !(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { |
0 | 305 return; |
306 } | |
307 | |
308 /* If the mouse was lost, regain some sense of mouse state */ | |
309 if ( mouse_lost ) { | |
310 POINT mouse_pos; | |
311 Uint8 old_state; | |
312 Uint8 new_state; | |
313 | |
314 /* Set ourselves up with the current cursor position */ | |
315 GetCursorPos(&mouse_pos); | |
316 ScreenToClient(SDL_Window, &mouse_pos); | |
317 posted = SDL_PrivateMouseMotion(0, 0, | |
318 (Sint16)mouse_pos.x, (Sint16)mouse_pos.y); | |
319 | |
320 /* Check for mouse button changes */ | |
321 old_state = SDL_GetMouseState(NULL, NULL); | |
322 new_state = 0; | |
323 { /* Get the new DirectInput button state for the mouse */ | |
324 DIMOUSESTATE distate; | |
325 HRESULT result; | |
326 | |
327 result=IDirectInputDevice2_GetDeviceState(SDL_DIdev[1], | |
328 sizeof(distate), &distate); | |
329 if ( result != DI_OK ) { | |
330 /* Try again next time */ | |
331 SetDIerror( | |
332 "IDirectInputDevice2::GetDeviceState", result); | |
333 return; | |
334 } | |
335 for ( i=3; i>=0; --i ) { | |
336 if ( (distate.rgbButtons[i]&0x80) == 0x80 ) { | |
337 new_state |= 0x01; | |
338 } | |
339 new_state <<= 1; | |
340 } | |
341 } | |
342 for ( i=0; i<8; ++i ) { | |
343 if ( (old_state&0x01) != (new_state&0x01) ) { | |
344 button = (Uint8)(i+1); | |
345 /* Button #2 on two button mice is button 3 | |
346 (the middle button is button 2) | |
347 */ | |
348 if ( button == 2 ) { | |
349 button = 3; | |
350 } else | |
351 if ( button == 3 ) { | |
352 button = 2; | |
353 } | |
354 if ( new_state & 0x01 ) { | |
355 /* Grab mouse so we get mouse-up */ | |
356 if ( ++mouse_pressed > 0 ) { | |
357 SetCapture(SDL_Window); | |
358 } | |
359 state = SDL_PRESSED; | |
360 } else { | |
361 /* Release mouse after all mouse-ups */ | |
362 if ( --mouse_pressed <= 0 ) { | |
363 ReleaseCapture(); | |
364 mouse_pressed = 0; | |
365 } | |
366 state = SDL_RELEASED; | |
367 } | |
491
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
368 if ( mouse_buttons_swapped ) { |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
369 if ( button == 1 ) button = 3; |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
370 else |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
371 if ( button == 3 ) button = 1; |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
372 } |
0 | 373 posted = SDL_PrivateMouseButton(state, button, |
374 0, 0); | |
375 } | |
376 old_state >>= 1; | |
377 new_state >>= 1; | |
378 } | |
379 mouse_lost = 0; | |
380 return; | |
381 } | |
382 | |
383 /* Translate mouse messages */ | |
384 xrel = 0; | |
385 yrel = 0; | |
386 for ( i=0; i<(int)numevents; ++i ) { | |
387 switch (ptrbuf[i].dwOfs) { | |
388 case DIMOFS_X: | |
536
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
389 if ( timestamp != ptrbuf[i].dwTimeStamp ) { |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
390 if ( xrel || yrel ) { |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
391 posted = SDL_PrivateMouseMotion( |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
392 0, 1, xrel, yrel); |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
393 xrel = 0; |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
394 yrel = 0; |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
395 } |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
396 timestamp = ptrbuf[i].dwTimeStamp; |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
397 } |
0 | 398 xrel += (Sint16)ptrbuf[i].dwData; |
399 break; | |
400 case DIMOFS_Y: | |
536
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
401 if ( timestamp != ptrbuf[i].dwTimeStamp ) { |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
402 if ( xrel || yrel ) { |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
403 posted = SDL_PrivateMouseMotion( |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
404 0, 1, xrel, yrel); |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
405 xrel = 0; |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
406 yrel = 0; |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
407 } |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
408 timestamp = ptrbuf[i].dwTimeStamp; |
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
409 } |
0 | 410 yrel += (Sint16)ptrbuf[i].dwData; |
411 break; | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
412 case DIMOFS_Z: |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
413 if ( xrel || yrel ) { |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
414 posted = SDL_PrivateMouseMotion( |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
415 0, 1, xrel, yrel); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
416 xrel = 0; |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
417 yrel = 0; |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
418 } |
536
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
419 timestamp = 0; |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
420 if((int)ptrbuf[i].dwData > 0) |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
421 button = SDL_BUTTON_WHEELUP; |
332 | 422 else |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
423 button = SDL_BUTTON_WHEELDOWN; |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
424 posted = SDL_PrivateMouseButton( |
332 | 425 SDL_PRESSED, button, 0, 0); |
426 posted |= SDL_PrivateMouseButton( | |
427 SDL_RELEASED, button, 0, 0); | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
428 break; |
0 | 429 case DIMOFS_BUTTON0: |
430 case DIMOFS_BUTTON1: | |
431 case DIMOFS_BUTTON2: | |
432 case DIMOFS_BUTTON3: | |
433 if ( xrel || yrel ) { | |
434 posted = SDL_PrivateMouseMotion( | |
435 0, 1, xrel, yrel); | |
436 xrel = 0; | |
437 yrel = 0; | |
438 } | |
536
bf7f477fb2b2
Fixed potential dropped events under DirectInput
Sam Lantinga <slouken@libsdl.org>
parents:
523
diff
changeset
|
439 timestamp = 0; |
0 | 440 button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1; |
441 /* Button #2 on two button mice is button 3 | |
442 (the middle button is button 2) | |
443 */ | |
444 if ( button == 2 ) { | |
445 button = 3; | |
446 } else | |
447 if ( button == 3 ) { | |
448 button = 2; | |
449 } | |
450 if ( ptrbuf[i].dwData & 0x80 ) { | |
451 /* Grab mouse so we get mouse-up */ | |
452 if ( ++mouse_pressed > 0 ) { | |
453 SetCapture(SDL_Window); | |
454 } | |
455 state = SDL_PRESSED; | |
456 } else { | |
457 /* Release mouse after all mouse-ups */ | |
458 if ( --mouse_pressed <= 0 ) { | |
459 ReleaseCapture(); | |
460 mouse_pressed = 0; | |
461 } | |
462 state = SDL_RELEASED; | |
463 } | |
491
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
464 if ( mouse_buttons_swapped ) { |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
465 if ( button == 1 ) button = 3; |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
466 else |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
467 if ( button == 3 ) button = 1; |
da6a7e859616
Applied John Popplewell's fix for left-handed mice under Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
460
diff
changeset
|
468 } |
0 | 469 posted = SDL_PrivateMouseButton(state, button, |
470 0, 0); | |
471 break; | |
472 } | |
473 } | |
474 if ( xrel || yrel ) { | |
475 posted = SDL_PrivateMouseMotion( 0, 1, xrel, yrel); | |
476 } | |
477 } | |
478 | |
479 /* The main Win32 event handler */ | |
480 LONG | |
481 DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
482 { | |
483 switch (msg) { | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
484 #ifdef WM_ACTIVATEAPP |
0 | 485 case WM_ACTIVATEAPP: { |
486 int i, active; | |
487 | |
488 active = (wParam && (GetForegroundWindow() == hwnd)); | |
489 if ( active ) { | |
490 for ( i=0; SDL_DIdev[i]; ++i ) { | |
491 IDirectInputDevice2_Acquire( | |
492 SDL_DIdev[i]); | |
493 } | |
494 } else { | |
495 for ( i=0; SDL_DIdev[i]; ++i ) { | |
496 IDirectInputDevice2_Unacquire( | |
497 SDL_DIdev[i]); | |
498 } | |
499 mouse_lost = 1; | |
500 } | |
501 } | |
502 break; | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
503 #endif /* WM_ACTIVATEAPP */ |
0 | 504 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
505 #ifdef WM_DISPLAYCHANGE |
0 | 506 case WM_DISPLAYCHANGE: { |
507 WORD BitsPerPixel; | |
508 WORD SizeX, SizeY; | |
509 | |
510 /* Ack! The display changed size and/or depth! */ | |
511 SizeX = LOWORD(lParam); | |
512 SizeY = HIWORD(lParam); | |
513 BitsPerPixel = wParam; | |
514 /* We cause this message when we go fullscreen */ | |
515 } | |
516 break; | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
517 #endif /* WM_DISPLAYCHANGE */ |
0 | 518 |
519 /* The keyboard is handled via DirectInput */ | |
520 case WM_SYSKEYUP: | |
1348
40d0975c1769
Date: Mon, 6 Feb 2006 11:41:04 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
521 case WM_SYSKEYDOWN: { |
40d0975c1769
Date: Mon, 6 Feb 2006 11:41:04 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
522 /* Pass syskey to DefWindwoProc (ALT-F4, etc.) */ |
40d0975c1769
Date: Mon, 6 Feb 2006 11:41:04 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
523 } |
40d0975c1769
Date: Mon, 6 Feb 2006 11:41:04 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
524 break; |
0 | 525 case WM_KEYUP: |
526 case WM_KEYDOWN: { | |
527 /* Ignore windows keyboard messages */; | |
528 } | |
529 return(0); | |
530 | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
531 #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER) |
0 | 532 /* Don't allow screen savers or monitor power downs. |
533 This is because they quietly clear DirectX surfaces. | |
534 It would be better to allow the application to | |
535 decide whether or not to blow these off, but the | |
536 semantics of SDL_PrivateSysWMEvent() don't allow | |
537 the application that choice. | |
538 */ | |
539 case WM_SYSCOMMAND: { | |
540 if ((wParam&0xFFF0)==SC_SCREENSAVE || | |
541 (wParam&0xFFF0)==SC_MONITORPOWER) | |
542 return(0); | |
543 } | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
544 /* Fall through to default processing */ |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
545 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
546 #endif /* SC_SCREENSAVE || SC_MONITORPOWER */ |
0 | 547 |
548 default: { | |
549 /* Only post the event if we're watching for it */ | |
550 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | |
551 SDL_SysWMmsg wmmsg; | |
552 | |
553 SDL_VERSION(&wmmsg.version); | |
554 wmmsg.hwnd = hwnd; | |
555 wmmsg.msg = msg; | |
556 wmmsg.wParam = wParam; | |
557 wmmsg.lParam = lParam; | |
558 posted = SDL_PrivateSysWMEvent(&wmmsg); | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
559 |
721
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
560 /* DJM: If the user isn't watching for private |
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
561 messages in her SDL event loop, then pass it |
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
562 along to any win32 specific window proc. |
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
563 */ |
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
564 } else if (userWindowProc) { |
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
565 return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam); |
ab0656314eef
Date: Thu, 18 Sep 2003 14:24:35 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
717
diff
changeset
|
566 } |
0 | 567 } |
568 break; | |
569 } | |
570 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
571 } | |
572 | |
573 /* This function checks the windows message queue and DirectInput and returns | |
574 1 if there was input, 0 if there was no input, or -1 if the application has | |
575 posted a quit message. | |
576 */ | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
577 static int DX5_CheckInput(_THIS, int timeout, BOOL processInput) |
0 | 578 { |
579 MSG msg; | |
580 int i; | |
581 HRESULT result; | |
582 DWORD event; | |
583 | |
584 /* Check the normal windows queue (highest preference) */ | |
585 posted = 0; | |
586 while ( ! posted && | |
523
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
491
diff
changeset
|
587 PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) { |
c210010f50f4
Fixed windows event handling for ActiveX controls (thanks Huib-Jan!)
Sam Lantinga <slouken@libsdl.org>
parents:
491
diff
changeset
|
588 if ( GetMessage(&msg, NULL, 0, 0) > 0 ) { |
0 | 589 DispatchMessage(&msg); |
590 } else { | |
591 return(-1); | |
592 } | |
593 } | |
594 if ( posted ) { | |
595 return(1); | |
596 } | |
597 | |
598 /* Pump the DirectInput flow */ | |
599 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
600 for ( i=0; i<SDL_DIndev; ++i ) { | |
601 result = IDirectInputDevice2_Poll(SDL_DIdev[i]); | |
602 if ( (result == DIERR_INPUTLOST) || | |
603 (result == DIERR_NOTACQUIRED) ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
604 if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) { |
0 | 605 mouse_lost = 1; |
606 } | |
607 IDirectInputDevice2_Acquire(SDL_DIdev[i]); | |
608 IDirectInputDevice2_Poll(SDL_DIdev[i]); | |
609 } | |
610 } | |
611 } | |
612 | |
613 /* Wait for messages and input events */ | |
614 event = MsgWaitForMultipleObjects(SDL_DIndev, SDL_DIevt, FALSE, | |
615 timeout, QS_ALLEVENTS); | |
616 if ((event >= WAIT_OBJECT_0) && (event < (WAIT_OBJECT_0+SDL_DIndev))) { | |
617 DWORD numevents; | |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
618 static DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE]; |
0 | 619 |
620 event -= WAIT_OBJECT_0; | |
621 numevents = INPUT_QSIZE; | |
622 result = IDirectInputDevice2_GetDeviceData( | |
623 SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA), | |
624 evtbuf, &numevents, 0); | |
625 if ( (result == DIERR_INPUTLOST) || | |
626 (result == DIERR_NOTACQUIRED) ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
627 if ( SDL_strcmp(inputs[event].name, "mouse") == 0 ) { |
0 | 628 mouse_lost = 1; |
629 } | |
630 IDirectInputDevice2_Acquire(SDL_DIdev[event]); | |
631 result = IDirectInputDevice2_GetDeviceData( | |
632 SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA), | |
633 evtbuf, &numevents, 0); | |
634 } | |
635 /* Handle the events */ | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
636 if ( result == DI_OK && processInput ) { |
0 | 637 /* Note: This can post multiple events to event queue |
638 */ | |
639 (*SDL_DIfun[event])((int)numevents, evtbuf); | |
640 return(1); | |
641 } | |
642 } | |
643 if ( event != WAIT_TIMEOUT ) { | |
644 /* Maybe there was a windows message? */ | |
645 if ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) { | |
646 if ( GetMessage(&msg, NULL, 0, 0) > 0 ) { | |
647 DispatchMessage(&msg); | |
648 } else { | |
649 return(-1); | |
650 } | |
651 return(1); | |
652 } | |
653 } | |
654 return(0); | |
655 } | |
656 | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
657 /* Change cooperative level based on whether or not we are fullscreen */ |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
658 void DX5_DInputReset(_THIS, int fullscreen) |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
659 { |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
660 DWORD level; |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
661 int i; |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
662 HRESULT result; |
970
fb8b91365766
Date: Tue, 19 Oct 2004 23:04:58 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
663 HWND topwnd; |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
664 |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
665 for ( i=0; i<MAX_INPUTS; ++i ) { |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
666 if ( SDL_DIdev[i] != NULL ) { |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
667 if ( fullscreen ) { |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
668 level = inputs[i].raw_level; |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
669 } else { |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
670 level = inputs[i].win_level; |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
671 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
672 IDirectInputDevice2_Unacquire(SDL_DIdev[i]); |
1115
040aa1bea9fc
Fixed mismerged patch.
Ryan C. Gordon <icculus@icculus.org>
parents:
1114
diff
changeset
|
673 topwnd = GetTopLevelParent(SDL_Window); |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
674 result = IDirectInputDevice2_SetCooperativeLevel( |
970
fb8b91365766
Date: Tue, 19 Oct 2004 23:04:58 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
675 SDL_DIdev[i], topwnd, level); |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
676 IDirectInputDevice2_Acquire(SDL_DIdev[i]); |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
677 if ( result != DI_OK ) { |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
678 SetDIerror( |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
679 "DirectInputDevice::SetCooperativeLevel", result); |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
680 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
681 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
682 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
683 mouse_lost = 1; |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
684 |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
685 /* Flush pending input */ |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
686 DX5_CheckInput(this, 0, FALSE); |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
687 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
688 |
0 | 689 void DX5_PumpEvents(_THIS) |
690 { | |
691 /* Wait for messages and DirectInput */ | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
458
diff
changeset
|
692 while ( DX5_CheckInput(this, 0, TRUE) > 0 ) { |
0 | 693 /* Loop and check again */; |
694 } | |
695 } | |
696 | |
697 void DX5_InitOSKeymap(_THIS) | |
698 { | |
275
53fc686e9428
Added support for the pause key under DirectX
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
699 #ifndef DIK_PAUSE |
53fc686e9428
Added support for the pause key under DirectX
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
700 #define DIK_PAUSE 0xC5 |
53fc686e9428
Added support for the pause key under DirectX
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
701 #endif |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
325
diff
changeset
|
702 #ifndef DIK_OEM_102 |
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
325
diff
changeset
|
703 #define DIK_OEM_102 0x56 /* < > | on UK/Germany keyboards */ |
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
325
diff
changeset
|
704 #endif |
0 | 705 int i; |
706 | |
707 /* Map the DIK scancodes to SDL keysyms */ | |
708 for ( i=0; i<SDL_TABLESIZE(DIK_keymap); ++i ) | |
709 DIK_keymap[i] = 0; | |
710 | |
711 /* Defined DIK_* constants */ | |
712 DIK_keymap[DIK_ESCAPE] = SDLK_ESCAPE; | |
713 DIK_keymap[DIK_1] = SDLK_1; | |
714 DIK_keymap[DIK_2] = SDLK_2; | |
715 DIK_keymap[DIK_3] = SDLK_3; | |
716 DIK_keymap[DIK_4] = SDLK_4; | |
717 DIK_keymap[DIK_5] = SDLK_5; | |
718 DIK_keymap[DIK_6] = SDLK_6; | |
719 DIK_keymap[DIK_7] = SDLK_7; | |
720 DIK_keymap[DIK_8] = SDLK_8; | |
721 DIK_keymap[DIK_9] = SDLK_9; | |
722 DIK_keymap[DIK_0] = SDLK_0; | |
723 DIK_keymap[DIK_MINUS] = SDLK_MINUS; | |
724 DIK_keymap[DIK_EQUALS] = SDLK_EQUALS; | |
725 DIK_keymap[DIK_BACK] = SDLK_BACKSPACE; | |
726 DIK_keymap[DIK_TAB] = SDLK_TAB; | |
727 DIK_keymap[DIK_Q] = SDLK_q; | |
728 DIK_keymap[DIK_W] = SDLK_w; | |
729 DIK_keymap[DIK_E] = SDLK_e; | |
730 DIK_keymap[DIK_R] = SDLK_r; | |
731 DIK_keymap[DIK_T] = SDLK_t; | |
732 DIK_keymap[DIK_Y] = SDLK_y; | |
733 DIK_keymap[DIK_U] = SDLK_u; | |
734 DIK_keymap[DIK_I] = SDLK_i; | |
735 DIK_keymap[DIK_O] = SDLK_o; | |
736 DIK_keymap[DIK_P] = SDLK_p; | |
737 DIK_keymap[DIK_LBRACKET] = SDLK_LEFTBRACKET; | |
738 DIK_keymap[DIK_RBRACKET] = SDLK_RIGHTBRACKET; | |
739 DIK_keymap[DIK_RETURN] = SDLK_RETURN; | |
740 DIK_keymap[DIK_LCONTROL] = SDLK_LCTRL; | |
741 DIK_keymap[DIK_A] = SDLK_a; | |
742 DIK_keymap[DIK_S] = SDLK_s; | |
743 DIK_keymap[DIK_D] = SDLK_d; | |
744 DIK_keymap[DIK_F] = SDLK_f; | |
745 DIK_keymap[DIK_G] = SDLK_g; | |
746 DIK_keymap[DIK_H] = SDLK_h; | |
747 DIK_keymap[DIK_J] = SDLK_j; | |
748 DIK_keymap[DIK_K] = SDLK_k; | |
749 DIK_keymap[DIK_L] = SDLK_l; | |
750 DIK_keymap[DIK_SEMICOLON] = SDLK_SEMICOLON; | |
751 DIK_keymap[DIK_APOSTROPHE] = SDLK_QUOTE; | |
752 DIK_keymap[DIK_GRAVE] = SDLK_BACKQUOTE; | |
753 DIK_keymap[DIK_LSHIFT] = SDLK_LSHIFT; | |
754 DIK_keymap[DIK_BACKSLASH] = SDLK_BACKSLASH; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
325
diff
changeset
|
755 DIK_keymap[DIK_OEM_102] = SDLK_BACKSLASH; |
0 | 756 DIK_keymap[DIK_Z] = SDLK_z; |
757 DIK_keymap[DIK_X] = SDLK_x; | |
758 DIK_keymap[DIK_C] = SDLK_c; | |
759 DIK_keymap[DIK_V] = SDLK_v; | |
760 DIK_keymap[DIK_B] = SDLK_b; | |
761 DIK_keymap[DIK_N] = SDLK_n; | |
762 DIK_keymap[DIK_M] = SDLK_m; | |
763 DIK_keymap[DIK_COMMA] = SDLK_COMMA; | |
764 DIK_keymap[DIK_PERIOD] = SDLK_PERIOD; | |
765 DIK_keymap[DIK_SLASH] = SDLK_SLASH; | |
766 DIK_keymap[DIK_RSHIFT] = SDLK_RSHIFT; | |
767 DIK_keymap[DIK_MULTIPLY] = SDLK_KP_MULTIPLY; | |
768 DIK_keymap[DIK_LMENU] = SDLK_LALT; | |
769 DIK_keymap[DIK_SPACE] = SDLK_SPACE; | |
770 DIK_keymap[DIK_CAPITAL] = SDLK_CAPSLOCK; | |
771 DIK_keymap[DIK_F1] = SDLK_F1; | |
772 DIK_keymap[DIK_F2] = SDLK_F2; | |
773 DIK_keymap[DIK_F3] = SDLK_F3; | |
774 DIK_keymap[DIK_F4] = SDLK_F4; | |
775 DIK_keymap[DIK_F5] = SDLK_F5; | |
776 DIK_keymap[DIK_F6] = SDLK_F6; | |
777 DIK_keymap[DIK_F7] = SDLK_F7; | |
778 DIK_keymap[DIK_F8] = SDLK_F8; | |
779 DIK_keymap[DIK_F9] = SDLK_F9; | |
780 DIK_keymap[DIK_F10] = SDLK_F10; | |
781 DIK_keymap[DIK_NUMLOCK] = SDLK_NUMLOCK; | |
782 DIK_keymap[DIK_SCROLL] = SDLK_SCROLLOCK; | |
783 DIK_keymap[DIK_NUMPAD7] = SDLK_KP7; | |
784 DIK_keymap[DIK_NUMPAD8] = SDLK_KP8; | |
785 DIK_keymap[DIK_NUMPAD9] = SDLK_KP9; | |
786 DIK_keymap[DIK_SUBTRACT] = SDLK_KP_MINUS; | |
787 DIK_keymap[DIK_NUMPAD4] = SDLK_KP4; | |
788 DIK_keymap[DIK_NUMPAD5] = SDLK_KP5; | |
789 DIK_keymap[DIK_NUMPAD6] = SDLK_KP6; | |
790 DIK_keymap[DIK_ADD] = SDLK_KP_PLUS; | |
791 DIK_keymap[DIK_NUMPAD1] = SDLK_KP1; | |
792 DIK_keymap[DIK_NUMPAD2] = SDLK_KP2; | |
793 DIK_keymap[DIK_NUMPAD3] = SDLK_KP3; | |
794 DIK_keymap[DIK_NUMPAD0] = SDLK_KP0; | |
795 DIK_keymap[DIK_DECIMAL] = SDLK_KP_PERIOD; | |
796 DIK_keymap[DIK_F11] = SDLK_F11; | |
797 DIK_keymap[DIK_F12] = SDLK_F12; | |
798 | |
799 DIK_keymap[DIK_F13] = SDLK_F13; | |
800 DIK_keymap[DIK_F14] = SDLK_F14; | |
801 DIK_keymap[DIK_F15] = SDLK_F15; | |
802 | |
803 DIK_keymap[DIK_NUMPADEQUALS] = SDLK_KP_EQUALS; | |
804 DIK_keymap[DIK_NUMPADENTER] = SDLK_KP_ENTER; | |
805 DIK_keymap[DIK_RCONTROL] = SDLK_RCTRL; | |
806 DIK_keymap[DIK_DIVIDE] = SDLK_KP_DIVIDE; | |
807 DIK_keymap[DIK_SYSRQ] = SDLK_SYSREQ; | |
808 DIK_keymap[DIK_RMENU] = SDLK_RALT; | |
290
9a02597bc1b0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
275
diff
changeset
|
809 DIK_keymap[DIK_PAUSE] = SDLK_PAUSE; |
0 | 810 DIK_keymap[DIK_HOME] = SDLK_HOME; |
811 DIK_keymap[DIK_UP] = SDLK_UP; | |
812 DIK_keymap[DIK_PRIOR] = SDLK_PAGEUP; | |
813 DIK_keymap[DIK_LEFT] = SDLK_LEFT; | |
814 DIK_keymap[DIK_RIGHT] = SDLK_RIGHT; | |
815 DIK_keymap[DIK_END] = SDLK_END; | |
816 DIK_keymap[DIK_DOWN] = SDLK_DOWN; | |
817 DIK_keymap[DIK_NEXT] = SDLK_PAGEDOWN; | |
818 DIK_keymap[DIK_INSERT] = SDLK_INSERT; | |
819 DIK_keymap[DIK_DELETE] = SDLK_DELETE; | |
820 DIK_keymap[DIK_LWIN] = SDLK_LMETA; | |
821 DIK_keymap[DIK_RWIN] = SDLK_RMETA; | |
822 DIK_keymap[DIK_APPS] = SDLK_MENU; | |
823 } | |
824 | |
825 static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed) | |
826 { | |
827 /* Set the keysym information */ | |
828 keysym->scancode = (unsigned char)scancode; | |
829 keysym->sym = DIK_keymap[scancode]; | |
830 keysym->mod = KMOD_NONE; | |
831 keysym->unicode = 0; | |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
832 if ( pressed && SDL_TranslateUNICODE ) { |
0 | 833 UINT vkey; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
834 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
835 BYTE keystate[256]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
836 Uint16 wchars[2]; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
837 #endif |
0 | 838 |
839 vkey = MapVirtualKey(scancode, 1); | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
840 #ifdef NO_GETKEYBOARDSTATE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
841 /* Uh oh, better hope the vkey is close enough.. */ |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
842 keysym->unicode = vkey; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
332
diff
changeset
|
843 #else |
0 | 844 GetKeyboardState(keystate); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
845 if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1) |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
846 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
847 keysym->unicode = wchars[0]; |
0 | 848 } |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1115
diff
changeset
|
849 #endif /* NO_GETKEYBOARDSTATE */ |
0 | 850 } |
851 return(keysym); | |
852 } | |
853 | |
854 int DX5_CreateWindow(_THIS) | |
855 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
856 char *windowid = SDL_getenv("SDL_WINDOWID"); |
0 | 857 int i; |
858 | |
859 /* Clear out DirectInput variables in case we fail */ | |
860 for ( i=0; i<MAX_INPUTS; ++i ) { | |
861 SDL_DIdev[i] = NULL; | |
862 SDL_DIevt[i] = NULL; | |
863 SDL_DIfun[i] = NULL; | |
864 } | |
865 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
866 SDL_RegisterApp(NULL, 0, 0); |
1280
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
867 |
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
868 SDL_windowid = (windowid != NULL); |
0 | 869 if ( SDL_windowid ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
870 SDL_Window = (HWND)SDL_strtol(windowid, NULL, 0); |
975
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
871 if ( SDL_Window == NULL ) { |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
872 SDL_SetError("Couldn't get user specified window"); |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
873 return(-1); |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
874 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
875 |
458
a8a0a4f19df7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
876 /* DJM: we want all event's for the user specified |
975
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
877 window to be handled by SDL. |
458
a8a0a4f19df7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
878 */ |
1303
52b5afd7ecee
Date: Tue, 05 Jul 2005 21:43:26 +1000
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
879 userWindowProc = (WNDPROCTYPE)GetWindowLong(SDL_Window, GWL_WNDPROC); |
975
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
880 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage); |
0 | 881 } else { |
882 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, | |
883 (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
|
884 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL); |
0 | 885 if ( SDL_Window == NULL ) { |
886 SDL_SetError("Couldn't create window"); | |
887 return(-1); | |
888 } | |
889 ShowWindow(SDL_Window, SW_HIDE); | |
890 } | |
891 | |
892 /* Initialize DirectInput */ | |
893 if ( DX5_DInputInit(this) < 0 ) { | |
894 return(-1); | |
895 } | |
896 | |
897 /* Ready to roll */ | |
898 return(0); | |
899 } | |
900 | |
901 void DX5_DestroyWindow(_THIS) | |
902 { | |
903 /* Close down DirectInput */ | |
904 DX5_DInputQuit(this); | |
905 | |
906 /* Destroy our window */ | |
975
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
907 if ( SDL_windowid ) { |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
908 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc); |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
909 } else { |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
910 DestroyWindow(SDL_Window); |
add87cc1de0a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
970
diff
changeset
|
911 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
912 SDL_UnregisterApp(); |
0 | 913 } |