src/haptic/windows/SDL_syshaptic.c
changeset 8185 c2996dc8ef6b
parent 8183 f8404b0e00ac
child 8247 fd220c4df418
equal deleted inserted replaced
8184:2afb90ff0199 8185:c2996dc8ef6b
   219     LPDIRECTINPUTDEVICE8 device;
   219     LPDIRECTINPUTDEVICE8 device;
   220     const DWORD needflags = DIDC_ATTACHED | DIDC_FORCEFEEDBACK;
   220     const DWORD needflags = DIDC_ATTACHED | DIDC_FORCEFEEDBACK;
   221     DIDEVCAPS capabilities;
   221     DIDEVCAPS capabilities;
   222     SDL_hapticlist_item *item = NULL;
   222     SDL_hapticlist_item *item = NULL;
   223 
   223 
       
   224     if (dinput == NULL) {
       
   225         return -1;  /* not initialized. We'll pick these up on enumeration if we init later. */
       
   226     }
       
   227 
   224     /* Make sure we don't already have it */
   228     /* Make sure we don't already have it */
   225     for (item = SDL_hapticlist; item; item = item->next) {
   229     for (item = SDL_hapticlist; item; item = item->next) {
   226         if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
   230         if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
   227             return -1;  /* Already added */
   231             return -1;  /* Already added */
   228         }
   232         }
   283 int
   287 int
   284 DirectInputHaptic_MaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance)
   288 DirectInputHaptic_MaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance)
   285 {
   289 {
   286     SDL_hapticlist_item *item;
   290     SDL_hapticlist_item *item;
   287     SDL_hapticlist_item *prev = NULL;
   291     SDL_hapticlist_item *prev = NULL;
       
   292 
       
   293     if (dinput == NULL) {
       
   294         return -1;  /* not initialized, ignore this. */
       
   295     }
   288 
   296 
   289     for (item = SDL_hapticlist; item != NULL; item = item->next) {
   297     for (item = SDL_hapticlist; item != NULL; item = item->next) {
   290         if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
   298         if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
   291             /* found it, remove it. */
   299             /* found it, remove it. */
   292             const int retval = item->haptic ? item->haptic->index : -1;
   300             const int retval = item->haptic ? item->haptic->index : -1;