comparison src/video/windx5/SDL_dx5events.c @ 4237:0adda8ff43ef SDL-1.2

Potentially fixed bug #774 There's a mismatch between ndev and MAX_INPUTS
author Sam Lantinga <slouken@libsdl.org>
date Wed, 23 Sep 2009 06:57:12 +0000
parents caaa3cbf7b13
children 6cc2b35ac610
comparison
equal deleted inserted replaced
4236:1fc8c8a5ff00 4237:0adda8ff43ef
41 #ifdef _WIN32_WCE 41 #ifdef _WIN32_WCE
42 #define NO_GETKEYBOARDSTATE 42 #define NO_GETKEYBOARDSTATE
43 #endif 43 #endif
44 44
45 /* The keyboard and mouse device input */ 45 /* The keyboard and mouse device input */
46 #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */ 46 #define MAX_INPUTS 2
47 #define INPUT_QSIZE 512 /* Buffer up to 512 input messages */ 47 #define INPUT_QSIZE 512 /* Buffer up to 512 input messages */
48 48
49 static LPDIRECTINPUT dinput = NULL; 49 static LPDIRECTINPUT dinput = NULL;
50 static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS]; 50 static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
51 static HANDLE SDL_DIevt[MAX_INPUTS]; 51 static HANDLE SDL_DIevt[MAX_INPUTS];
262 } 262 }
263 IDirectInputDevice2_Release(SDL_DIdev[i]); 263 IDirectInputDevice2_Release(SDL_DIdev[i]);
264 SDL_DIdev[i] = NULL; 264 SDL_DIdev[i] = NULL;
265 } 265 }
266 } 266 }
267 SDL_DIndev = 0;
268
267 /* Release DirectInput */ 269 /* Release DirectInput */
268 IDirectInput_Release(dinput); 270 IDirectInput_Release(dinput);
269 dinput = NULL; 271 dinput = NULL;
270 } 272 }
271 } 273 }
662 return(1); 664 return(1);
663 } 665 }
664 666
665 /* Pump the DirectInput flow */ 667 /* Pump the DirectInput flow */
666 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { 668 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
667 for ( i=0; i<SDL_DIndev; ++i ) { 669 for ( i=0; i<MAX_INPUTS; ++i ) {
668 result = IDirectInputDevice2_Poll(SDL_DIdev[i]); 670 if ( SDL_DIdev[i] != NULL ) {
669 if ( (result == DIERR_INPUTLOST) || 671 result = IDirectInputDevice2_Poll(SDL_DIdev[i]);
670 (result == DIERR_NOTACQUIRED) ) { 672 if ( (result == DIERR_INPUTLOST) ||
671 if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) { 673 (result == DIERR_NOTACQUIRED) ) {
672 mouse_lost = 1; 674 if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) {
673 } 675 mouse_lost = 1;
674 IDirectInputDevice2_Acquire(SDL_DIdev[i]); 676 }
675 IDirectInputDevice2_Poll(SDL_DIdev[i]); 677 IDirectInputDevice2_Acquire(SDL_DIdev[i]);
678 IDirectInputDevice2_Poll(SDL_DIdev[i]);
679 }
676 } 680 }
677 } 681 }
678 } 682 }
679 683
680 /* Wait for messages and input events */ 684 /* Wait for messages and input events */