diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index 21631e9a0..1cc5993ba 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -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; diff --git a/src/detection/keyboard/keyboard_bsd.c b/src/detection/keyboard/keyboard_bsd.c index 3d9fb66f5..727e91b02 100644 --- a/src/detection/keyboard/keyboard_bsd.c +++ b/src/detection/keyboard/keyboard_bsd.c @@ -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; diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index 5052475bf..3a1f2eb69 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -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;