Potentially fixed bug #774 SDL-1.2
authorSam Lantinga
Wed, 23 Sep 2009 06:57:12 +0000
branchSDL-1.2
changeset 42370adda8ff43ef
parent 4236 1fc8c8a5ff00
child 4238 cbe5222d051a
Potentially fixed bug #774
There's a mismatch between ndev and MAX_INPUTS
src/video/windx5/SDL_dx5events.c
     1.1 --- a/src/video/windx5/SDL_dx5events.c	Wed Sep 23 06:56:28 2009 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5events.c	Wed Sep 23 06:57:12 2009 +0000
     1.3 @@ -43,7 +43,7 @@
     1.4  #endif
     1.5  
     1.6  /* The keyboard and mouse device input */
     1.7 -#define MAX_INPUTS	16		/* Maximum of 16-1 input devices */
     1.8 +#define MAX_INPUTS	2
     1.9  #define INPUT_QSIZE	512		/* Buffer up to 512 input messages */
    1.10  
    1.11  static LPDIRECTINPUT dinput = NULL;
    1.12 @@ -264,6 +264,8 @@
    1.13  				SDL_DIdev[i] = NULL;
    1.14  			}
    1.15  		}
    1.16 +		SDL_DIndev = 0;
    1.17 +
    1.18  		/* Release DirectInput */
    1.19  		IDirectInput_Release(dinput);
    1.20  		dinput = NULL;
    1.21 @@ -664,15 +666,17 @@
    1.22  
    1.23  	/* Pump the DirectInput flow */
    1.24  	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
    1.25 -		for ( i=0; i<SDL_DIndev; ++i ) {
    1.26 -			result = IDirectInputDevice2_Poll(SDL_DIdev[i]);
    1.27 -			if ( (result == DIERR_INPUTLOST) ||
    1.28 -					(result == DIERR_NOTACQUIRED) ) {
    1.29 -				if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) {
    1.30 -					mouse_lost = 1;
    1.31 +		for ( i=0; i<MAX_INPUTS; ++i ) {
    1.32 +			if ( SDL_DIdev[i] != NULL ) {
    1.33 +				result = IDirectInputDevice2_Poll(SDL_DIdev[i]);
    1.34 +				if ( (result == DIERR_INPUTLOST) ||
    1.35 +						(result == DIERR_NOTACQUIRED) ) {
    1.36 +					if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) {
    1.37 +						mouse_lost = 1;
    1.38 +					}
    1.39 +					IDirectInputDevice2_Acquire(SDL_DIdev[i]);
    1.40 +					IDirectInputDevice2_Poll(SDL_DIdev[i]);
    1.41  				}
    1.42 -				IDirectInputDevice2_Acquire(SDL_DIdev[i]);
    1.43 -				IDirectInputDevice2_Poll(SDL_DIdev[i]);
    1.44  			}
    1.45  		}
    1.46  	}