comparison src/video/windx5/SDL_dx5events.c @ 536:bf7f477fb2b2

Fixed potential dropped events under DirectInput
author Sam Lantinga <slouken@libsdl.org>
date Sat, 09 Nov 2002 05:47:24 +0000
parents c210010f50f4
children 42ed44b2c8b6
comparison
equal deleted inserted replaced
535:917cc5c56176 536:bf7f477fb2b2
47 #define NO_GETKEYBOARDSTATE 47 #define NO_GETKEYBOARDSTATE
48 #endif 48 #endif
49 49
50 /* The keyboard and mouse device input */ 50 /* The keyboard and mouse device input */
51 #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */ 51 #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */
52 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ 52 #define INPUT_QSIZE 512 /* Buffer up to 512 input messages */
53 53
54 static LPDIRECTINPUT dinput = NULL; 54 static LPDIRECTINPUT dinput = NULL;
55 static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS]; 55 static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
56 static HANDLE SDL_DIevt[MAX_INPUTS]; 56 static HANDLE SDL_DIevt[MAX_INPUTS];
57 static void (*SDL_DIfun[MAX_INPUTS])(const int, DIDEVICEOBJECTDATA *); 57 static void (*SDL_DIfun[MAX_INPUTS])(const int, DIDEVICEOBJECTDATA *);
273 { 273 {
274 int i; 274 int i;
275 Sint16 xrel, yrel; 275 Sint16 xrel, yrel;
276 Uint8 state; 276 Uint8 state;
277 Uint8 button; 277 Uint8 button;
278 DWORD timestamp = 0;
278 279
279 /* If we are in windowed mode, Windows is taking care of the mouse */ 280 /* If we are in windowed mode, Windows is taking care of the mouse */
280 if ( (SDL_PublicSurface->flags & SDL_OPENGL) || 281 if ( (SDL_PublicSurface->flags & SDL_OPENGL) ||
281 !(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { 282 !(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
282 return; 283 return;
361 xrel = 0; 362 xrel = 0;
362 yrel = 0; 363 yrel = 0;
363 for ( i=0; i<(int)numevents; ++i ) { 364 for ( i=0; i<(int)numevents; ++i ) {
364 switch (ptrbuf[i].dwOfs) { 365 switch (ptrbuf[i].dwOfs) {
365 case DIMOFS_X: 366 case DIMOFS_X:
367 if ( timestamp != ptrbuf[i].dwTimeStamp ) {
368 if ( xrel || yrel ) {
369 posted = SDL_PrivateMouseMotion(
370 0, 1, xrel, yrel);
371 xrel = 0;
372 yrel = 0;
373 }
374 timestamp = ptrbuf[i].dwTimeStamp;
375 }
366 xrel += (Sint16)ptrbuf[i].dwData; 376 xrel += (Sint16)ptrbuf[i].dwData;
367 break; 377 break;
368 case DIMOFS_Y: 378 case DIMOFS_Y:
379 if ( timestamp != ptrbuf[i].dwTimeStamp ) {
380 if ( xrel || yrel ) {
381 posted = SDL_PrivateMouseMotion(
382 0, 1, xrel, yrel);
383 xrel = 0;
384 yrel = 0;
385 }
386 timestamp = ptrbuf[i].dwTimeStamp;
387 }
369 yrel += (Sint16)ptrbuf[i].dwData; 388 yrel += (Sint16)ptrbuf[i].dwData;
370 break; 389 break;
371 case DIMOFS_Z: 390 case DIMOFS_Z:
372 if ( xrel || yrel ) { 391 if ( xrel || yrel ) {
373 posted = SDL_PrivateMouseMotion( 392 posted = SDL_PrivateMouseMotion(
374 0, 1, xrel, yrel); 393 0, 1, xrel, yrel);
375 xrel = 0; 394 xrel = 0;
376 yrel = 0; 395 yrel = 0;
377 } 396 }
397 timestamp = 0;
378 if((int)ptrbuf[i].dwData > 0) 398 if((int)ptrbuf[i].dwData > 0)
379 button = SDL_BUTTON_WHEELUP; 399 button = SDL_BUTTON_WHEELUP;
380 else 400 else
381 button = SDL_BUTTON_WHEELDOWN; 401 button = SDL_BUTTON_WHEELDOWN;
382 posted = SDL_PrivateMouseButton( 402 posted = SDL_PrivateMouseButton(
392 posted = SDL_PrivateMouseMotion( 412 posted = SDL_PrivateMouseMotion(
393 0, 1, xrel, yrel); 413 0, 1, xrel, yrel);
394 xrel = 0; 414 xrel = 0;
395 yrel = 0; 415 yrel = 0;
396 } 416 }
417 timestamp = 0;
397 button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1; 418 button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
398 /* Button #2 on two button mice is button 3 419 /* Button #2 on two button mice is button 3
399 (the middle button is button 2) 420 (the middle button is button 2)
400 */ 421 */
401 if ( button == 2 ) { 422 if ( button == 2 ) {