Skip to content

Commit

Permalink
Fixed crash on Windows if haptic isn't initialized when controllers a…
Browse files Browse the repository at this point in the history
…re added.
  • Loading branch information
icculus committed Feb 7, 2014
1 parent 5697974 commit 7033e59
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/haptic/windows/SDL_syshaptic.c
Expand Up @@ -221,6 +221,10 @@ DirectInputHaptic_MaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance)
DIDEVCAPS capabilities;
SDL_hapticlist_item *item = NULL;

if (dinput == NULL) {
return -1; /* not initialized. We'll pick these up on enumeration if we init later. */
}

/* Make sure we don't already have it */
for (item = SDL_hapticlist; item; item = item->next) {
if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
Expand Down Expand Up @@ -286,6 +290,10 @@ DirectInputHaptic_MaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;

if (dinput == NULL) {
return -1; /* not initialized, ignore this. */
}

for (item = SDL_hapticlist; item != NULL; item = item->next) {
if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
/* found it, remove it. */
Expand Down

0 comments on commit 7033e59

Please sign in to comment.