Skip to content

Commit

Permalink
Potentially fixed bug #774
Browse files Browse the repository at this point in the history
There's a mismatch between ndev and MAX_INPUTS
  • Loading branch information
slouken committed Sep 23, 2009
1 parent 88a822f commit 12a0cbb
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/video/windx5/SDL_dx5events.c
Expand Up @@ -43,7 +43,7 @@
#endif

/* The keyboard and mouse device input */
#define MAX_INPUTS 16 /* Maximum of 16-1 input devices */
#define MAX_INPUTS 2
#define INPUT_QSIZE 512 /* Buffer up to 512 input messages */

static LPDIRECTINPUT dinput = NULL;
Expand Down Expand Up @@ -264,6 +264,8 @@ static void DX5_DInputQuit(_THIS)
SDL_DIdev[i] = NULL;
}
}
SDL_DIndev = 0;

/* Release DirectInput */
IDirectInput_Release(dinput);
dinput = NULL;
Expand Down Expand Up @@ -664,15 +666,17 @@ static int DX5_CheckInput(_THIS, int timeout, BOOL processInput)

/* Pump the DirectInput flow */
if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
for ( i=0; i<SDL_DIndev; ++i ) {
result = IDirectInputDevice2_Poll(SDL_DIdev[i]);
if ( (result == DIERR_INPUTLOST) ||
(result == DIERR_NOTACQUIRED) ) {
if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) {
mouse_lost = 1;
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]);
}
IDirectInputDevice2_Acquire(SDL_DIdev[i]);
IDirectInputDevice2_Poll(SDL_DIdev[i]);
}
}
}
Expand Down

0 comments on commit 12a0cbb

Please sign in to comment.