/* If there is an existing add event in the queue, it needs to be modified to have the right value for which, because the number of controllers in the system is now one less.  */
static void UpdateEventsForDeviceRemoval()
/* If there is an existing add event in the queue, it needs to be modified to have the right value for which, because the number of controllers in the system is now one less.  */
static void UpdateEventsForDeviceRemoval()
{
    int i, num_events;
    SDL_Event *events;
    SDL_bool isstack;
    num_events = SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED);
    if (num_events <= 0) {
        return;
    }
    events = SDL_small_alloc(SDL_Event, num_events, &isstack);
    if (!events) {
        return;
    }
    num_events = SDL_PeepEvents(events, num_events, SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED);
    for (i = 0; i < num_events; ++i) {
        --events[i].jdevice.which;
    }
    SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0);
    SDL_small_free(events, isstack);
}