src/joystick/darwin/SDL_sysjoystick.c
changeset 9375 bc00287b414f
parent 9370 795d4866e4db
child 9380 07b7c1005a23
equal deleted inserted replaced
9374:b577c4753421 9375:bc00287b414f
   558 /* Function to cause any queued joystick insertions to be processed
   558 /* Function to cause any queued joystick insertions to be processed
   559  */
   559  */
   560 void
   560 void
   561 SDL_SYS_JoystickDetect()
   561 SDL_SYS_JoystickDetect()
   562 {
   562 {
   563     while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) {
       
   564         /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */
       
   565     }
       
   566 
       
   567     if (s_bDeviceAdded || s_bDeviceRemoved) {
   563     if (s_bDeviceAdded || s_bDeviceRemoved) {
   568         recDevice *device = gpDeviceList;
   564         recDevice *device = gpDeviceList;
   569         s_bDeviceAdded = SDL_FALSE;
   565         s_bDeviceAdded = SDL_FALSE;
   570         s_bDeviceRemoved = SDL_FALSE;
   566         s_bDeviceRemoved = SDL_FALSE;
   571         int device_index = 0;
   567         int device_index = 0;
   611                 device = device->pNext;
   607                 device = device->pNext;
   612                 device_index++;
   608                 device_index++;
   613             }
   609             }
   614         }
   610         }
   615     }
   611     }
       
   612 
       
   613 	// run this after the checks above so we don't set device->removed and delete the device before
       
   614 	// SDL_SYS_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device
       
   615 	while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) {
       
   616 		/* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */
       
   617 	}
   616 }
   618 }
   617 
   619 
   618 /* Function to get the device-dependent name of a joystick */
   620 /* Function to get the device-dependent name of a joystick */
   619 const char *
   621 const char *
   620 SDL_SYS_JoystickNameForDeviceIndex(int device_index)
   622 SDL_SYS_JoystickNameForDeviceIndex(int device_index)