|
@@ -485,6 +485,7 @@ static int device_class(struct udev_device *dev)
|
|
|
{
|
|
{
|
|
|
const char *subsystem;
|
|
const char *subsystem;
|
|
|
const char *val = NULL;
|
|
const char *val = NULL;
|
|
|
|
|
+ const char *attr = NULL;
|
|
|
int devclass = 0;
|
|
int devclass = 0;
|
|
|
|
|
|
|
|
subsystem = _this->syms.udev_device_get_subsystem(dev);
|
|
subsystem = _this->syms.udev_device_get_subsystem(dev);
|
|
@@ -496,8 +497,18 @@ static int device_class(struct udev_device *dev)
|
|
|
devclass = SDL_UDEV_DEVICE_SOUND;
|
|
devclass = SDL_UDEV_DEVICE_SOUND;
|
|
|
} else if (SDL_strcmp(subsystem, "video4linux") == 0) {
|
|
} else if (SDL_strcmp(subsystem, "video4linux") == 0) {
|
|
|
val = _this->syms.udev_device_get_property_value(dev, "ID_V4L_CAPABILITIES");
|
|
val = _this->syms.udev_device_get_property_value(dev, "ID_V4L_CAPABILITIES");
|
|
|
- if (val && SDL_strcasestr(val, "capture")) {
|
|
|
|
|
- devclass = SDL_UDEV_DEVICE_VIDEO_CAPTURE;
|
|
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ if (SDL_strcasestr(val, "capture")) {
|
|
|
|
|
+ devclass = SDL_UDEV_DEVICE_VIDEO_CAPTURE;
|
|
|
|
|
+ }
|
|
|
|
|
+ // v4l2loopback may report output caps before reporting capture caps
|
|
|
|
|
+ // and ID_V4L_CAPABILITIES is never updated
|
|
|
|
|
+ else if (SDL_strcasestr(val, "video_output")) {
|
|
|
|
|
+ attr = _this->syms.udev_device_get_sysattr_value(dev, "state");
|
|
|
|
|
+ if (attr && SDL_strcmp(attr, "capture") == 0) {
|
|
|
|
|
+ devclass = SDL_UDEV_DEVICE_VIDEO_CAPTURE;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else if (SDL_strcmp(subsystem, "input") == 0) {
|
|
} else if (SDL_strcmp(subsystem, "input") == 0) {
|
|
|
// udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c
|
|
// udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c
|