mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 19:38:14 +00:00
Fixed DualSense controllers not being picked up by the HIDAPI driver
The hidraw device may take additional time to get the correct permissions for us to open it. In my tests on Steam Deck hardware, this ranges between 5-8ms.
This commit is contained in:
@@ -1096,7 +1096,17 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);
|
const int MAX_ATTEMPTS = 10;
|
||||||
|
int attempt;
|
||||||
|
for (attempt = 1; attempt <= MAX_ATTEMPTS; ++attempt) {
|
||||||
|
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);
|
||||||
|
if (dev->device_handle < 0 && errno == EACCES) {
|
||||||
|
/* udev might be setting up permissions, wait a bit and try again */
|
||||||
|
usleep(1 * 1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->device_handle >= 0) {
|
if (dev->device_handle >= 0) {
|
||||||
int res, desc_size = 0;
|
int res, desc_size = 0;
|
||||||
|
Reference in New Issue
Block a user