Skip to content

Latest commit

 

History

History
1010 lines (927 loc) · 27.3 KB

SDL_dx5events.c

File metadata and controls

1010 lines (927 loc) · 27.3 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
/*
SDL - Simple DirectMedia Layer
Dec 8, 2008
Dec 8, 2008
3
Copyright (C) 1997-2009 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 */
Sep 23, 2009
Sep 23, 2009
46
#define MAX_INPUTS 2
Nov 9, 2002
Nov 9, 2002
47
#define INPUT_QSIZE 512 /* Buffer up to 512 input messages */
Apr 26, 2001
Apr 26, 2001
48
49
50
51
52
53
54
55
static LPDIRECTINPUT dinput = NULL;
static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
static HANDLE SDL_DIevt[MAX_INPUTS];
static void (*SDL_DIfun[MAX_INPUTS])(const int, DIDEVICEOBJECTDATA *);
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
60
61
/* The translation table from a DirectInput scancode to an SDL keysym */
static SDLKey DIK_keymap[256];
static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed);
Aug 9, 2001
Aug 9, 2001
62
63
/* 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
64
65
66
67
68
69
#ifdef STRICT
#define WNDPROCTYPE WNDPROC
#else
#define WNDPROCTYPE FARPROC
#endif
static WNDPROCTYPE userWindowProc = NULL;
Aug 9, 2001
Aug 9, 2001
70
Aug 11, 2005
Aug 11, 2005
71
72
73
74
75
76
77
78
79
80
81
82
83
static HWND GetTopLevelParent(HWND hWnd)
{
HWND hParentWnd;
while (1)
{
hParentWnd = GetParent(hWnd);
if (hParentWnd == NULL)
break;
hWnd = hParentWnd;
}
return hWnd;
}
Apr 26, 2001
Apr 26, 2001
84
85
86
87
/* Convert a DirectInput return code to a text message */
static void SetDIerror(char *function, int code)
{
static char *error;
Aug 20, 2002
Aug 20, 2002
88
static char errbuf[1024];
Apr 26, 2001
Apr 26, 2001
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
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:
Feb 7, 2006
Feb 7, 2006
114
SDL_snprintf(errbuf, SDL_arraysize(errbuf),
Feb 6, 2006
Feb 6, 2006
115
"%s: Unknown DirectInput error: 0x%x",
Apr 26, 2001
Apr 26, 2001
116
117
118
119
function, code);
break;
}
if ( ! errbuf[0] ) {
Feb 7, 2006
Feb 7, 2006
120
SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
Apr 26, 2001
Apr 26, 2001
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
}
SDL_SetError("%s", errbuf);
return;
}
/* 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.
*/
static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA *events);
static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *events);
struct {
char *name;
REFGUID guid;
LPCDIDATAFORMAT format;
DWORD win_level;
DWORD raw_level;
void (*fun)(const int numevents, DIDEVICEOBJECTDATA *events);
} inputs[] = {
{ "keyboard",
&GUID_SysKeyboard, &c_dfDIKeyboard,
(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE),
(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE), handle_keyboard },
{ "mouse",
Apr 2, 2009
Apr 2, 2009
146
147
148
149
150
151
&GUID_SysMouse,
#if DIRECTINPUT_VERSION >= 0x700
&c_dfDIMouse2,
#else
&c_dfDIMouse,
#endif
Apr 26, 2001
Apr 26, 2001
152
(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE),
Apr 2, 2009
Apr 2, 2009
153
(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE), handle_mouse },
Apr 26, 2001
Apr 26, 2001
154
155
156
157
158
159
160
161
162
{ NULL, NULL, NULL, 0, 0, NULL }
};
static int DX5_DInputInit(_THIS)
{
int i;
LPDIRECTINPUTDEVICE device;
HRESULT result;
DIPROPDWORD dipdw;
Nov 12, 2004
Nov 12, 2004
163
HWND topwnd;
Apr 26, 2001
Apr 26, 2001
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* Create the DirectInput object */
result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION,
&dinput, NULL);
if ( result != DI_OK ) {
SetDIerror("DirectInputCreate", result);
return(-1);
}
/* Create all of our registered input devices */
SDL_DIndev = 0;
for ( i=0; inputs[i].name; ++i ) {
/* Create the DirectInput device */
result = IDirectInput_CreateDevice(dinput, inputs[i].guid,
&device, NULL);
if ( result != DI_OK ) {
SetDIerror("DirectInput::CreateDevice", result);
return(-1);
}
result = IDirectInputDevice_QueryInterface(device,
&IID_IDirectInputDevice2, (LPVOID *)&SDL_DIdev[i]);
IDirectInputDevice_Release(device);
if ( result != DI_OK ) {
SetDIerror("DirectInputDevice::QueryInterface", result);
return(-1);
}
Aug 11, 2005
Aug 11, 2005
190
topwnd = GetTopLevelParent(SDL_Window);
Apr 26, 2001
Apr 26, 2001
191
result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i],
Nov 12, 2004
Nov 12, 2004
192
topwnd, inputs[i].win_level);
Apr 26, 2001
Apr 26, 2001
193
194
195
196
197
198
199
200
201
202
203
204
205
if ( result != DI_OK ) {
SetDIerror("DirectInputDevice::SetCooperativeLevel",
result);
return(-1);
}
result = IDirectInputDevice2_SetDataFormat(SDL_DIdev[i],
inputs[i].format);
if ( result != DI_OK ) {
SetDIerror("DirectInputDevice::SetDataFormat", result);
return(-1);
}
/* Set buffered input -- we aren't polling */
Feb 7, 2006
Feb 7, 2006
206
SDL_memset(&dipdw, 0, sizeof(dipdw));
Apr 26, 2001
Apr 26, 2001
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
dipdw.diph.dwSize = sizeof(dipdw);
dipdw.diph.dwHeaderSize = sizeof(dipdw.diph);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = INPUT_QSIZE;
result = IDirectInputDevice2_SetProperty(SDL_DIdev[i],
DIPROP_BUFFERSIZE, &dipdw.diph);
if ( result != DI_OK ) {
SetDIerror("DirectInputDevice::SetProperty", result);
return(-1);
}
/* Create an event to be signaled when input is ready */
SDL_DIevt[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
if ( SDL_DIevt[i] == NULL ) {
SDL_SetError("Couldn't create DirectInput event");
return(-1);
}
result = IDirectInputDevice2_SetEventNotification(SDL_DIdev[i],
SDL_DIevt[i]);
if ( result != DI_OK ) {
SetDIerror("DirectInputDevice::SetEventNotification",
result);
return(-1);
}
SDL_DIfun[i] = inputs[i].fun;
/* Acquire the device for input */
IDirectInputDevice2_Acquire(SDL_DIdev[i]);
/* Increment the number of devices we have */
++SDL_DIndev;
}
mouse_pressed = 0;
Sep 16, 2002
Sep 16, 2002
241
mouse_buttons_swapped = GetSystemMetrics(SM_SWAPBUTTON);
Apr 26, 2001
Apr 26, 2001
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/* DirectInput is ready! */
return(0);
}
/* Clean up DirectInput */
static void DX5_DInputQuit(_THIS)
{
int i;
if ( dinput != NULL ) {
/* Close and release all DirectInput devices */
for ( i=0; i<MAX_INPUTS; ++i ) {
if ( SDL_DIdev[i] != NULL ) {
IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
IDirectInputDevice2_SetEventNotification(
SDL_DIdev[i], NULL);
if ( SDL_DIevt[i] != NULL ) {
CloseHandle(SDL_DIevt[i]);
SDL_DIevt[i] = NULL;
}
IDirectInputDevice2_Release(SDL_DIdev[i]);
SDL_DIdev[i] = NULL;
}
}
Sep 23, 2009
Sep 23, 2009
267
268
SDL_DIndev = 0;
Apr 26, 2001
Apr 26, 2001
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/* Release DirectInput */
IDirectInput_Release(dinput);
dinput = NULL;
}
}
/* Flag to tell SDL whether or not we queued an event */
static int posted = 0;
/* Input event handler functions */
static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA *keybuf)
{
int i;
SDL_keysym keysym;
/* Translate keyboard messages */
for ( i=0; i<numevents; ++i ) {
if ( keybuf[i].dwData & 0x80 ) {
posted = SDL_PrivateKeyboard(SDL_PRESSED,
TranslateKey(keybuf[i].dwOfs, &keysym, 1));
} else {
posted = SDL_PrivateKeyboard(SDL_RELEASED,
TranslateKey(keybuf[i].dwOfs, &keysym, 0));
}
}
}
Apr 2, 2009
Apr 2, 2009
295
296
297
298
299
static void post_mouse_motion(int relative, Sint16 x, Sint16 y)
{
extern int mouse_relative;
Sep 12, 2009
Sep 12, 2009
300
if ( (SDL_GetAppState() & (SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS)) ==
Apr 2, 2009
Apr 2, 2009
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
(SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS) ) {
posted = SDL_PrivateMouseMotion(
0, relative, x, y);
if ( !mouse_relative ) {
/* As DirectInput reads raw device coordinates, it has no notion of
* cursors or absolute position. We must assume responsibility for
* keeping track of this. */
int current_x, current_y;
POINT cursor;
RECT trap;
RECT window;
int at_edge;
/* Get the current cursor position */
SDL_GetMouseState(&current_x, &current_y);
cursor.x = current_x;
cursor.y = current_y;
ClientToScreen(SDL_Window, &cursor);
/* Construct a 1 pixel square RECT that is used to confine the cursor
* pointer to a specific pixel using ClipCursor. This is used in
* preference to SetCursorPos as it avoids the cursor jumping around as
* both the OS and SDL attempt to move it simultaneously. */
trap.left = cursor.x;
trap.top = cursor.y;
trap.right = cursor.x + 1;
trap.bottom = cursor.y + 1;
GetClientRect(SDL_Window, &window);
window.right -= window.left; window.left = 0;
window.bottom -= window.top; window.top = 0;
/* As we're assuming control over the cursor, we need to know when to
* relinquish control of it back to the operating system. This is when
* the cursor reaches the edge of the window. */
at_edge = (current_x == window.left) ||
(current_x == (window.right - 1)) ||
(current_y == window.top) ||
(current_y == (window.bottom - 1));
if ( at_edge ) {
ClipCursor(NULL);
} else {
ClipCursor(&trap);
}
} else {
/* When in relative mode, warp the OS's idea of where the cursor is to
* the center of the screen. This isn't really necessary as DirectInput
* reads from the hardware itself, but in case things go wrong, the
* cursor will be left in a sensible place. */
POINT center;
center.x = (SDL_VideoSurface->w/2);
center.y = (SDL_VideoSurface->h/2);
ClientToScreen(SDL_Window, &center);
SetCursorPos(center.x, center.y);
}
} else {
/* No window or mouse focus, control is lost */
mouse_lost = 1;
ClipCursor(NULL);
}
}
Apr 26, 2001
Apr 26, 2001
365
366
367
368
369
370
static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
{
int i;
Sint16 xrel, yrel;
Uint8 state;
Uint8 button;
Nov 9, 2002
Nov 9, 2002
371
DWORD timestamp = 0;
Apr 26, 2001
Apr 26, 2001
372
Sep 15, 2003
Sep 15, 2003
373
374
375
376
377
/* Sanity check. Mailing list reports this being NULL unexpectedly. */
if (SDL_PublicSurface == NULL) {
return;
}
Apr 26, 2001
Apr 26, 2001
378
/* If the mouse was lost, regain some sense of mouse state */
Apr 2, 2009
Apr 2, 2009
379
if ( mouse_lost && (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
Apr 26, 2001
Apr 26, 2001
380
381
382
383
384
385
386
POINT mouse_pos;
Uint8 old_state;
Uint8 new_state;
/* Set ourselves up with the current cursor position */
GetCursorPos(&mouse_pos);
ScreenToClient(SDL_Window, &mouse_pos);
Apr 2, 2009
Apr 2, 2009
387
post_mouse_motion( 0, (Sint16)mouse_pos.x, (Sint16)mouse_pos.y);
Apr 26, 2001
Apr 26, 2001
388
389
390
391
392
/* Check for mouse button changes */
old_state = SDL_GetMouseState(NULL, NULL);
new_state = 0;
{ /* Get the new DirectInput button state for the mouse */
Apr 2, 2009
Apr 2, 2009
393
394
395
#if DIRECTINPUT_VERSION >= 0x700
DIMOUSESTATE2 distate;
#else
Apr 26, 2001
Apr 26, 2001
396
DIMOUSESTATE distate;
Apr 2, 2009
Apr 2, 2009
397
#endif
Apr 26, 2001
Apr 26, 2001
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
HRESULT result;
result=IDirectInputDevice2_GetDeviceState(SDL_DIdev[1],
sizeof(distate), &distate);
if ( result != DI_OK ) {
/* Try again next time */
SetDIerror(
"IDirectInputDevice2::GetDeviceState", result);
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);
Apr 2, 2009
Apr 2, 2009
418
419
420
421
422
423
424
/* Map DI button numbers to SDL */
switch ( button ) {
case 2: button = SDL_BUTTON_RIGHT; break;
case 3: button = SDL_BUTTON_MIDDLE; break;
case 4: button = SDL_BUTTON_X1; break;
case 5: button = SDL_BUTTON_X2; break;
default: break;
Apr 26, 2001
Apr 26, 2001
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
}
if ( new_state & 0x01 ) {
/* Grab mouse so we get mouse-up */
if ( ++mouse_pressed > 0 ) {
SetCapture(SDL_Window);
}
state = SDL_PRESSED;
} else {
/* Release mouse after all mouse-ups */
if ( --mouse_pressed <= 0 ) {
ReleaseCapture();
mouse_pressed = 0;
}
state = SDL_RELEASED;
}
Sep 16, 2002
Sep 16, 2002
440
441
442
443
444
if ( mouse_buttons_swapped ) {
if ( button == 1 ) button = 3;
else
if ( button == 3 ) button = 1;
}
Apr 26, 2001
Apr 26, 2001
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
posted = SDL_PrivateMouseButton(state, button,
0, 0);
}
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:
Nov 9, 2002
Nov 9, 2002
461
462
if ( timestamp != ptrbuf[i].dwTimeStamp ) {
if ( xrel || yrel ) {
Apr 2, 2009
Apr 2, 2009
463
post_mouse_motion(1, xrel, yrel);
Nov 9, 2002
Nov 9, 2002
464
465
466
467
468
xrel = 0;
yrel = 0;
}
timestamp = ptrbuf[i].dwTimeStamp;
}
Apr 26, 2001
Apr 26, 2001
469
470
471
xrel += (Sint16)ptrbuf[i].dwData;
break;
case DIMOFS_Y:
Nov 9, 2002
Nov 9, 2002
472
473
if ( timestamp != ptrbuf[i].dwTimeStamp ) {
if ( xrel || yrel ) {
Apr 2, 2009
Apr 2, 2009
474
post_mouse_motion(1, xrel, yrel);
Nov 9, 2002
Nov 9, 2002
475
476
477
478
479
xrel = 0;
yrel = 0;
}
timestamp = ptrbuf[i].dwTimeStamp;
}
Apr 26, 2001
Apr 26, 2001
480
481
yrel += (Sint16)ptrbuf[i].dwData;
break;
Jun 16, 2001
Jun 16, 2001
482
483
case DIMOFS_Z:
if ( xrel || yrel ) {
Apr 2, 2009
Apr 2, 2009
484
post_mouse_motion(1, xrel, yrel);
Jun 16, 2001
Jun 16, 2001
485
486
487
xrel = 0;
yrel = 0;
}
Nov 9, 2002
Nov 9, 2002
488
timestamp = 0;
Jun 16, 2001
Jun 16, 2001
489
if((int)ptrbuf[i].dwData > 0)
Aug 20, 2002
Aug 20, 2002
490
button = SDL_BUTTON_WHEELUP;
Apr 8, 2002
Apr 8, 2002
491
else
Aug 20, 2002
Aug 20, 2002
492
493
button = SDL_BUTTON_WHEELDOWN;
posted = SDL_PrivateMouseButton(
Apr 8, 2002
Apr 8, 2002
494
495
496
SDL_PRESSED, button, 0, 0);
posted |= SDL_PrivateMouseButton(
SDL_RELEASED, button, 0, 0);
Jun 16, 2001
Jun 16, 2001
497
break;
Apr 26, 2001
Apr 26, 2001
498
499
500
501
case DIMOFS_BUTTON0:
case DIMOFS_BUTTON1:
case DIMOFS_BUTTON2:
case DIMOFS_BUTTON3:
Apr 2, 2009
Apr 2, 2009
502
503
504
505
506
507
#if DIRECTINPUT_VERSION >= 0x700
case DIMOFS_BUTTON4:
case DIMOFS_BUTTON5:
case DIMOFS_BUTTON6:
case DIMOFS_BUTTON7:
#endif
Apr 26, 2001
Apr 26, 2001
508
if ( xrel || yrel ) {
Apr 2, 2009
Apr 2, 2009
509
post_mouse_motion(1, xrel, yrel);
Apr 26, 2001
Apr 26, 2001
510
511
512
xrel = 0;
yrel = 0;
}
Nov 9, 2002
Nov 9, 2002
513
timestamp = 0;
Apr 26, 2001
Apr 26, 2001
514
button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
Apr 2, 2009
Apr 2, 2009
515
516
517
518
519
520
521
/* Map DI button numbers to SDL */
switch ( button ) {
case 2: button = SDL_BUTTON_RIGHT; break;
case 3: button = SDL_BUTTON_MIDDLE; break;
case 4: button = SDL_BUTTON_X1; break;
case 5: button = SDL_BUTTON_X2; break;
default: break;
Apr 26, 2001
Apr 26, 2001
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
}
if ( ptrbuf[i].dwData & 0x80 ) {
/* Grab mouse so we get mouse-up */
if ( ++mouse_pressed > 0 ) {
SetCapture(SDL_Window);
}
state = SDL_PRESSED;
} else {
/* Release mouse after all mouse-ups */
if ( --mouse_pressed <= 0 ) {
ReleaseCapture();
mouse_pressed = 0;
}
state = SDL_RELEASED;
}
Sep 16, 2002
Sep 16, 2002
537
538
539
540
541
if ( mouse_buttons_swapped ) {
if ( button == 1 ) button = 3;
else
if ( button == 3 ) button = 1;
}
Apr 26, 2001
Apr 26, 2001
542
543
544
545
546
547
posted = SDL_PrivateMouseButton(state, button,
0, 0);
break;
}
}
if ( xrel || yrel ) {
Apr 2, 2009
Apr 2, 2009
548
post_mouse_motion(1, xrel, yrel);
Apr 26, 2001
Apr 26, 2001
549
550
551
552
}
}
/* The main Win32 event handler */
Mar 1, 2006
Mar 1, 2006
553
LRESULT DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Apr 26, 2001
Apr 26, 2001
554
555
{
switch (msg) {
Aug 20, 2002
Aug 20, 2002
556
#ifdef WM_ACTIVATEAPP
Apr 26, 2001
Apr 26, 2001
557
558
559
560
561
case WM_ACTIVATEAPP: {
int i, active;
active = (wParam && (GetForegroundWindow() == hwnd));
if ( active ) {
Nov 15, 2009
Nov 15, 2009
562
563
564
for ( i=0; i<MAX_INPUTS; ++i ) {
if (SDL_DIdev[i] != NULL)
IDirectInputDevice2_Acquire(
Apr 26, 2001
Apr 26, 2001
565
566
567
SDL_DIdev[i]);
}
} else {
Nov 15, 2009
Nov 15, 2009
568
569
570
for ( i=0; i<MAX_INPUTS; ++i ) {
if (SDL_DIdev[i] != NULL)
IDirectInputDevice2_Unacquire(
Apr 26, 2001
Apr 26, 2001
571
572
573
574
575
576
SDL_DIdev[i]);
}
mouse_lost = 1;
}
}
break;
Aug 20, 2002
Aug 20, 2002
577
#endif /* WM_ACTIVATEAPP */
Apr 26, 2001
Apr 26, 2001
578
Aug 20, 2002
Aug 20, 2002
579
#ifdef WM_DISPLAYCHANGE
Apr 26, 2001
Apr 26, 2001
580
case WM_DISPLAYCHANGE: {
Mar 1, 2006
Mar 1, 2006
581
WPARAM BitsPerPixel;
Apr 26, 2001
Apr 26, 2001
582
583
584
585
586
587
588
589
590
WORD SizeX, SizeY;
/* Ack! The display changed size and/or depth! */
SizeX = LOWORD(lParam);
SizeY = HIWORD(lParam);
BitsPerPixel = wParam;
/* We cause this message when we go fullscreen */
}
break;
Aug 20, 2002
Aug 20, 2002
591
#endif /* WM_DISPLAYCHANGE */
Apr 26, 2001
Apr 26, 2001
592
593
594
/* The keyboard is handled via DirectInput */
case WM_SYSKEYUP:
Apr 13, 2009
Apr 13, 2009
595
case WM_SYSKEYDOWN:
Apr 26, 2001
Apr 26, 2001
596
597
598
599
600
601
case WM_KEYUP:
case WM_KEYDOWN: {
/* Ignore windows keyboard messages */;
}
return(0);
Aug 20, 2002
Aug 20, 2002
602
#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
Apr 26, 2001
Apr 26, 2001
603
604
605
606
607
608
609
610
611
612
613
614
/* 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);
}
Aug 20, 2002
Aug 20, 2002
615
616
617
/* Fall through to default processing */
#endif /* SC_SCREENSAVE || SC_MONITORPOWER */
Apr 26, 2001
Apr 26, 2001
618
619
620
621
622
623
624
625
626
627
628
629
default: {
/* Only post the event if we're watching for it */
if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
SDL_SysWMmsg wmmsg;
SDL_VERSION(&wmmsg.version);
wmmsg.hwnd = hwnd;
wmmsg.msg = msg;
wmmsg.wParam = wParam;
wmmsg.lParam = lParam;
posted = SDL_PrivateSysWMEvent(&wmmsg);
Aug 9, 2001
Aug 9, 2001
630
Sep 21, 2003
Sep 21, 2003
631
632
633
634
635
636
637
/* 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) {
return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam);
}
Apr 26, 2001
Apr 26, 2001
638
639
640
641
642
643
644
645
646
647
}
break;
}
return(DefWindowProc(hwnd, msg, wParam, lParam));
}
/* 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.
*/
Aug 20, 2002
Aug 20, 2002
648
static int DX5_CheckInput(_THIS, int timeout, BOOL processInput)
Apr 26, 2001
Apr 26, 2001
649
650
651
652
653
654
655
656
657
{
MSG msg;
int i;
HRESULT result;
DWORD event;
/* Check the normal windows queue (highest preference) */
posted = 0;
while ( ! posted &&
Oct 8, 2002
Oct 8, 2002
658
659
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
Oct 10, 2009
Oct 10, 2009
660
TranslateMessage(&msg);
Apr 26, 2001
Apr 26, 2001
661
662
663
664
665
666
667
668
669
670
671
DispatchMessage(&msg);
} else {
return(-1);
}
}
if ( posted ) {
return(1);
}
/* Pump the DirectInput flow */
if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
Sep 23, 2009
Sep 23, 2009
672
673
674
675
676
677
678
679
680
681
for ( i=0; i<MAX_INPUTS; ++i ) {
if ( SDL_DIdev[i] != NULL ) {
result = IDirectInputDevice2_Poll(SDL_DIdev[i]);
if ( (result == DIERR_INPUTLOST) ||
(result == DIERR_NOTACQUIRED) ) {
if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) {
mouse_lost = 1;
}
IDirectInputDevice2_Acquire(SDL_DIdev[i]);
IDirectInputDevice2_Poll(SDL_DIdev[i]);
Apr 26, 2001
Apr 26, 2001
682
683
684
685
686
687
688
689
690
691
}
}
}
}
/* Wait for messages and input events */
event = MsgWaitForMultipleObjects(SDL_DIndev, SDL_DIevt, FALSE,
timeout, QS_ALLEVENTS);
if ((event >= WAIT_OBJECT_0) && (event < (WAIT_OBJECT_0+SDL_DIndev))) {
DWORD numevents;
Feb 6, 2006
Feb 6, 2006
692
static DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
Apr 26, 2001
Apr 26, 2001
693
694
695
696
697
698
699
700
event -= WAIT_OBJECT_0;
numevents = INPUT_QSIZE;
result = IDirectInputDevice2_GetDeviceData(
SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA),
evtbuf, &numevents, 0);
if ( (result == DIERR_INPUTLOST) ||
(result == DIERR_NOTACQUIRED) ) {
Feb 7, 2006
Feb 7, 2006
701
if ( SDL_strcmp(inputs[event].name, "mouse") == 0 ) {
Apr 26, 2001
Apr 26, 2001
702
703
704
705
706
707
708
709
mouse_lost = 1;
}
IDirectInputDevice2_Acquire(SDL_DIdev[event]);
result = IDirectInputDevice2_GetDeviceData(
SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA),
evtbuf, &numevents, 0);
}
/* Handle the events */
Aug 20, 2002
Aug 20, 2002
710
if ( result == DI_OK && processInput ) {
Apr 26, 2001
Apr 26, 2001
711
712
713
714
715
716
717
718
/* 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? */
Oct 10, 2009
Oct 10, 2009
719
720
721
posted = 0;
while ( ! posted &&
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
Apr 26, 2001
Apr 26, 2001
722
if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
Oct 10, 2009
Oct 10, 2009
723
TranslateMessage(&msg);
Apr 26, 2001
Apr 26, 2001
724
725
726
727
DispatchMessage(&msg);
} else {
return(-1);
}
Oct 10, 2009
Oct 10, 2009
728
729
}
if ( posted ) {
Apr 26, 2001
Apr 26, 2001
730
731
732
733
734
735
return(1);
}
}
return(0);
}
Aug 20, 2002
Aug 20, 2002
736
737
738
739
740
741
/* Change cooperative level based on whether or not we are fullscreen */
void DX5_DInputReset(_THIS, int fullscreen)
{
DWORD level;
int i;
HRESULT result;
Nov 12, 2004
Nov 12, 2004
742
HWND topwnd;
Aug 20, 2002
Aug 20, 2002
743
744
745
746
747
748
749
750
751
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;
}
IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
Aug 11, 2005
Aug 11, 2005
752
topwnd = GetTopLevelParent(SDL_Window);
Aug 20, 2002
Aug 20, 2002
753
result = IDirectInputDevice2_SetCooperativeLevel(
Nov 12, 2004
Nov 12, 2004
754
SDL_DIdev[i], topwnd, level);
Aug 20, 2002
Aug 20, 2002
755
756
757
758
759
760
761
762
763
764
765
766
767
IDirectInputDevice2_Acquire(SDL_DIdev[i]);
if ( result != DI_OK ) {
SetDIerror(
"DirectInputDevice::SetCooperativeLevel", result);
}
}
}
mouse_lost = 1;
/* Flush pending input */
DX5_CheckInput(this, 0, FALSE);
}
Apr 26, 2001
Apr 26, 2001
768
769
770
void DX5_PumpEvents(_THIS)
{
/* Wait for messages and DirectInput */
Aug 20, 2002
Aug 20, 2002
771
while ( DX5_CheckInput(this, 0, TRUE) > 0 ) {
Apr 26, 2001
Apr 26, 2001
772
773
774
775
776
777
/* Loop and check again */;
}
}
void DX5_InitOSKeymap(_THIS)
{
Feb 13, 2002
Feb 13, 2002
778
779
#ifndef DIK_PAUSE
#define DIK_PAUSE 0xC5
Mar 31, 2002
Mar 31, 2002
780
781
782
#endif
#ifndef DIK_OEM_102
#define DIK_OEM_102 0x56 /* < > | on UK/Germany keyboards */
Feb 13, 2002
Feb 13, 2002
783
#endif
Apr 26, 2001
Apr 26, 2001
784
785
786
int i;
/* Map the DIK scancodes to SDL keysyms */
Feb 19, 2006
Feb 19, 2006
787
for ( i=0; i<SDL_arraysize(DIK_keymap); ++i )
Apr 26, 2001
Apr 26, 2001
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
833
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;
May 18, 2006
May 18, 2006
834
DIK_keymap[DIK_OEM_102] = SDLK_LESS;
Apr 26, 2001
Apr 26, 2001
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
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;
Mar 14, 2006
Mar 14, 2006
886
DIK_keymap[DIK_SYSRQ] = SDLK_PRINT;
Apr 26, 2001
Apr 26, 2001
887
DIK_keymap[DIK_RMENU] = SDLK_RALT;
Mar 1, 2002
Mar 1, 2002
888
DIK_keymap[DIK_PAUSE] = SDLK_PAUSE;
Apr 26, 2001
Apr 26, 2001
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
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;
}
static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed)
{
/* Set the keysym information */
keysym->scancode = (unsigned char)scancode;
keysym->sym = DIK_keymap[scancode];
keysym->mod = KMOD_NONE;
keysym->unicode = 0;
Jan 19, 2006
Jan 19, 2006
911
if ( pressed && SDL_TranslateUNICODE ) {
Apr 26, 2001
Apr 26, 2001
912
UINT vkey;
Aug 20, 2002
Aug 20, 2002
913
#ifndef NO_GETKEYBOARDSTATE
Jan 19, 2006
Jan 19, 2006
914
915
BYTE keystate[256];
Uint16 wchars[2];
Aug 20, 2002
Aug 20, 2002
916
#endif
Apr 26, 2001
Apr 26, 2001
917
918
vkey = MapVirtualKey(scancode, 1);
Aug 20, 2002
Aug 20, 2002
919
920
921
922
#ifdef NO_GETKEYBOARDSTATE
/* Uh oh, better hope the vkey is close enough.. */
keysym->unicode = vkey;
#else
Apr 26, 2001
Apr 26, 2001
923
GetKeyboardState(keystate);
Apr 13, 2009
Apr 13, 2009
924
925
926
927
928
929
930
/* Numlock isn't taken into account in ToUnicode,
* so we handle it as a special case here */
if ((keystate[VK_NUMLOCK] & 1) && vkey >= VK_NUMPAD0 && vkey <= VK_NUMPAD9)
{
keysym->unicode = vkey - VK_NUMPAD0 + '0';
}
else if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) > 0)
Jan 19, 2006
Jan 19, 2006
931
932
{
keysym->unicode = wchars[0];
Apr 26, 2001
Apr 26, 2001
933
}
Jan 19, 2006
Jan 19, 2006
934
#endif /* NO_GETKEYBOARDSTATE */
Apr 26, 2001
Apr 26, 2001
935
936
937
938
939
940
}
return(keysym);
}
int DX5_CreateWindow(_THIS)
{
Feb 7, 2006
Feb 7, 2006
941
char *windowid = SDL_getenv("SDL_WINDOWID");
Apr 26, 2001
Apr 26, 2001
942
943
944
945
946
947
948
949
950
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;
}
Jan 29, 2006
Jan 29, 2006
951
SDL_RegisterApp(NULL, 0, 0);
Jan 29, 2006
Jan 29, 2006
952
953
SDL_windowid = (windowid != NULL);
Apr 26, 2001
Apr 26, 2001
954
if ( SDL_windowid ) {
Mar 1, 2006
Mar 1, 2006
955
SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
Nov 15, 2004
Nov 15, 2004
956
957
958
959
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't get user specified window");
return(-1);
}
Aug 9, 2001
Aug 9, 2001
960
Aug 20, 2002
Aug 20, 2002
961
/* DJM: we want all event's for the user specified
Nov 15, 2004
Nov 15, 2004
962
window to be handled by SDL.
Aug 20, 2002
Aug 20, 2002
963
*/
Mar 6, 2006
Mar 6, 2006
964
965
userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage);
Apr 26, 2001
Apr 26, 2001
966
967
968
} else {
SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
Feb 16, 2004
Feb 16, 2004
969
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
Apr 26, 2001
Apr 26, 2001
970
971
972
973
974
975
976
977
978
979
980
981
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't create window");
return(-1);
}
ShowWindow(SDL_Window, SW_HIDE);
}
/* Initialize DirectInput */
if ( DX5_DInputInit(this) < 0 ) {
return(-1);
}
Mar 14, 2006
Mar 14, 2006
982
983
984
985
986
987
/* 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()!
*/
WIN_FlushMessageQueue();
Apr 26, 2001
Apr 26, 2001
988
989
990
991
992
993
994
995
996
997
/* Ready to roll */
return(0);
}
void DX5_DestroyWindow(_THIS)
{
/* Close down DirectInput */
DX5_DInputQuit(this);
/* Destroy our window */
Nov 15, 2004
Nov 15, 2004
998
if ( SDL_windowid ) {
Mar 6, 2006
Mar 6, 2006
999
SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)userWindowProc);
Nov 15, 2004
Nov 15, 2004
1000
} else {