Fixed bug 4391 - hid_enumerate() sometimes causes game to freeze for a few seconds

Daniel Gibson

Even though my game (dhewm3) doesn't use SDL_INIT_JOYSTICK, SDL_PumpEvent() calls SDL_JoystickUpdate() which ends up calling hid_enumerate() every three seconds, and sometimes on my Win7 box hid_enumerate() takes about 5 seconds, which causes the whole game to freeze for that time.
This commit is contained in:
Sam Lantinga
2018-11-19 21:17:00 -08:00
parent d3fa42b8c4
commit b73703b9c6
4 changed files with 23 additions and 0 deletions

View File

@@ -348,6 +348,12 @@ SDL_WasInit(Uint32 flags)
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
Uint32 initialized = 0;
/* Fast path for checking one flag */
if (SDL_HasExactlyOneBitSet32(flags)) {
int subsystem_index = SDL_MostSignificantBitIndex32(flags);
return SDL_SubsystemRefCount[subsystem_index] ? flags : 0;
}
if (!flags) {
flags = SDL_INIT_EVERYTHING;
}