mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Don't call hid_enumerate() if the HIDAPI drivers are all disabled
This commit is contained in:
parent
aaffbb2ef6
commit
dc714389f0
@ -96,6 +96,7 @@ static SDL_HIDAPI_DeviceDriver *SDL_HIDAPI_drivers[] = {
|
|||||||
&SDL_HIDAPI_DriverXboxOne,
|
&SDL_HIDAPI_DriverXboxOne,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
static int SDL_HIDAPI_numdrivers = 0;
|
||||||
static SDL_HIDAPI_Device *SDL_HIDAPI_devices;
|
static SDL_HIDAPI_Device *SDL_HIDAPI_devices;
|
||||||
static int SDL_HIDAPI_numjoysticks = 0;
|
static int SDL_HIDAPI_numjoysticks = 0;
|
||||||
|
|
||||||
@ -656,6 +657,14 @@ SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldVal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_HIDAPI_numdrivers = 0;
|
||||||
|
for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) {
|
||||||
|
SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i];
|
||||||
|
if (driver->enabled) {
|
||||||
|
++SDL_HIDAPI_numdrivers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Update device list if driver availability changes */
|
/* Update device list if driver availability changes */
|
||||||
while (device) {
|
while (device) {
|
||||||
if (device->driver) {
|
if (device->driver) {
|
||||||
@ -869,17 +878,19 @@ HIDAPI_UpdateDeviceList(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Enumerate the devices */
|
/* Enumerate the devices */
|
||||||
devs = hid_enumerate(0, 0);
|
if (SDL_HIDAPI_numdrivers > 0) {
|
||||||
if (devs) {
|
devs = hid_enumerate(0, 0);
|
||||||
for (info = devs; info; info = info->next) {
|
if (devs) {
|
||||||
device = HIDAPI_GetJoystickByInfo(info->path, info->vendor_id, info->product_id);
|
for (info = devs; info; info = info->next) {
|
||||||
if (device) {
|
device = HIDAPI_GetJoystickByInfo(info->path, info->vendor_id, info->product_id);
|
||||||
device->seen = SDL_TRUE;
|
if (device) {
|
||||||
} else {
|
device->seen = SDL_TRUE;
|
||||||
HIDAPI_AddDevice(info);
|
} else {
|
||||||
|
HIDAPI_AddDevice(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
hid_free_enumeration(devs);
|
||||||
}
|
}
|
||||||
hid_free_enumeration(devs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove any devices that weren't seen */
|
/* Remove any devices that weren't seen */
|
||||||
|
Loading…
Reference in New Issue
Block a user