Fixed disabling the Xbox 360 wireless HIDAPI driver

This commit is contained in:
Sam Lantinga 2020-01-26 10:32:39 -08:00
parent ce7c51a9cc
commit adb53d0b1f
1 changed files with 3 additions and 5 deletions

View File

@ -504,7 +504,7 @@ static void SDLCALL
SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{ {
int i; int i;
SDL_HIDAPI_Device *device = SDL_HIDAPI_devices; SDL_HIDAPI_Device *device;
SDL_bool enabled = SDL_GetStringBoolean(hint, SDL_TRUE); SDL_bool enabled = SDL_GetStringBoolean(hint, SDL_TRUE);
if (SDL_strcmp(name, SDL_HINT_JOYSTICK_HIDAPI) == 0) { if (SDL_strcmp(name, SDL_HINT_JOYSTICK_HIDAPI) == 0) {
@ -517,7 +517,6 @@ SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldVal
SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i]; SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i];
if (SDL_strcmp(name, driver->hint) == 0) { if (SDL_strcmp(name, driver->hint) == 0) {
driver->enabled = enabled; driver->enabled = enabled;
break;
} }
} }
} }
@ -533,12 +532,11 @@ SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldVal
/* Update device list if driver availability changes */ /* Update device list if driver availability changes */
SDL_LockJoysticks(); SDL_LockJoysticks();
while (device) { for (device = SDL_HIDAPI_devices; device; device = device->next) {
if (device->driver && !device->driver->enabled) { if (device->driver && !device->driver->enabled) {
HIDAPI_CleanupDeviceDriver(device); HIDAPI_CleanupDeviceDriver(device);
} }
HIDAPI_SetupDeviceDriver(device); HIDAPI_SetupDeviceDriver(device);
device = device->next;
} }
SDL_UnlockJoysticks(); SDL_UnlockJoysticks();
@ -741,7 +739,7 @@ HIDAPI_AddDevice(struct hid_device_info *info)
HIDAPI_SetupDeviceDriver(device); HIDAPI_SetupDeviceDriver(device);
#ifdef DEBUG_HIDAPI #ifdef DEBUG_HIDAPI
SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s\n", device->name, device->vendor_id, device->product_id, device->version, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->hint : "NONE"); SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->hint : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED");
#endif #endif
} }