From 6d012b2a5dc243f88eaf7d75f796300855a676dc Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 9 Aug 2022 16:54:11 -0700
Subject: [PATCH] Better fix for rescanning devices after read failure
---
src/joystick/hidapi/SDL_hidapijoystick.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 10cdedd6ee8..8907adb0aa5 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -555,6 +555,9 @@ HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID
}
}
}
+
+ /* Rescan the device list in case device state has changed */
+ SDL_HIDAPI_change_count = 0;
}
static int
@@ -1003,10 +1006,7 @@ HIDAPI_UpdateDevices(void)
if (device->driver) {
if (SDL_TryLockMutex(device->dev_lock) == 0) {
device->updating = SDL_TRUE;
- if (!device->driver->UpdateDevice(device)) {
- /* Try re-enumerating the device if it fails */
- SDL_HIDAPI_change_count = 0;
- }
+ device->driver->UpdateDevice(device);
device->updating = SDL_FALSE;
SDL_UnlockMutex(device->dev_lock);
}