You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
linux: respect order of device list when enumerating camera feeds
This commit is contained in:
@@ -61,23 +61,23 @@ void CameraLinux::_update_devices() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DIR *devices = opendir("/dev");
|
struct dirent **devices;
|
||||||
|
int count = scandir("/dev", &devices, nullptr, alphasort);
|
||||||
|
|
||||||
if (devices) {
|
if (count != -1) {
|
||||||
struct dirent *device;
|
for (int i = 0; i < count; i++) {
|
||||||
|
struct dirent *device = devices[i];
|
||||||
while ((device = readdir(devices)) != nullptr) {
|
if (strncmp(device->d_name, "video", 5) == 0) {
|
||||||
if (strncmp(device->d_name, "video", 5) != 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String device_name = String("/dev/") + String(device->d_name);
|
String device_name = String("/dev/") + String(device->d_name);
|
||||||
if (!_has_device(device_name)) {
|
if (!_has_device(device_name)) {
|
||||||
_add_device(device_name);
|
_add_device(device_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(devices);
|
free(devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(1000000);
|
usleep(1000000);
|
||||||
|
|||||||
Reference in New Issue
Block a user