Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
944 lines (869 loc) · 29.8 KB

SDL_dx5events.c

File metadata and controls

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