Gamepad / Keyboard / Mouse (FreeBSD): break detection earlier

This commit is contained in:
李通洲
2025-03-27 14:40:33 +08:00
parent bdaf303da4
commit 4b6f2a9efa
3 changed files with 18 additions and 5 deletions
+6 -2
View File
@@ -20,8 +20,12 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
{
snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i);
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) continue;
if (fd < 0)
{
if (errno == ENOENT)
break; // No more devices
continue; // Device not found
}
report_desc_t repDesc = hid_get_report_desc(fd);
if (!repDesc) continue;
+6 -1
View File
@@ -47,7 +47,12 @@ static const char* detectByUsbhid(FFlist* devices)
{
snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i);
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) continue;
if (fd < 0)
{
if (errno == ENOENT)
break; // No more devices
continue; // Device not found
}
report_desc_t repDesc = hid_get_report_desc(fd);
if (!repDesc) continue;
+6 -2
View File
@@ -20,8 +20,12 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */)
{
snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i);
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) continue;
if (fd < 0)
{
if (errno == ENOENT)
break; // No more devices
continue; // Device not found
}
report_desc_t repDesc = hid_get_report_desc(fd);
if (!repDesc) continue;