hidapi: Allow disabling libusb support at runtime

This commit is contained in:
Ethan Lee 2022-05-30 16:17:04 -04:00 committed by Sam Lantinga
parent c87b0142fe
commit 964e979d06

View File

@ -1037,6 +1037,11 @@ int SDL_hid_init(void)
#endif #endif
#ifdef SDL_LIBUSB_DYNAMIC #ifdef SDL_LIBUSB_DYNAMIC
if (SDL_getenv("SDL_HIDAPI_DISABLE_LIBUSB") != NULL) {
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"libusb disabled by SDL_HIDAPI_DISABLE_LIBUSB");
libusb_ctx.libhandle = NULL;
} else {
++attempts; ++attempts;
libusb_ctx.libhandle = SDL_LoadObject(SDL_LIBUSB_DYNAMIC); libusb_ctx.libhandle = SDL_LoadObject(SDL_LIBUSB_DYNAMIC);
if (libusb_ctx.libhandle != NULL) { if (libusb_ctx.libhandle != NULL) {
@ -1087,6 +1092,7 @@ int SDL_hid_init(void)
++success; ++success;
} }
} }
}
#endif /* SDL_LIBUSB_DYNAMIC */ #endif /* SDL_LIBUSB_DYNAMIC */
#if HAVE_PLATFORM_BACKEND #if HAVE_PLATFORM_BACKEND