Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device monitor return non-usb midi devices #532

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 10 additions & 12 deletions matron/src/device/device_monitor.c
Expand Up @@ -150,9 +150,7 @@ int dev_monitor_scan(void) {
dev = udev_device_new_from_syspath(udev, path);

if (dev != NULL) {
if (udev_device_get_parent_with_subsystem_devtype(dev, "usb", NULL)) {
handle_device(dev);
}
handle_device(dev);
udev_device_unref(dev);
}
}
Expand Down Expand Up @@ -245,14 +243,10 @@ device_t check_dev_type(struct udev_device *dev) {
const char *node = udev_device_get_devnode(dev);

if (node) {
// for now, just get USB devices.
// eventually we might want to use this same system for GPIO, &c...
if (udev_device_get_parent_with_subsystem_devtype(dev, "usb", NULL)) {
for (int i = 0; i < DEV_TYPE_COUNT; i++) {
if (fnmatch(w[i].node_pattern, node, 0) == 0) {
t = i;
break;
}
for (int i = 0; i < DEV_TYPE_COUNT; i++) {
if (fnmatch(w[i].node_pattern, node, 0) == 0) {
t = i;
break;
}
}
}
Expand Down Expand Up @@ -290,14 +284,18 @@ const char* get_alsa_midi_node(struct udev_device *dev) {
// try to get product name from udev_device or its parents
const char* get_device_name(struct udev_device *dev) {
char *current_name = NULL;
char *current_id = NULL;
struct udev_device *current_dev = dev;

while (current_name == NULL) {
current_name = (char *) udev_device_get_sysattr_value(current_dev, "product");
if(!current_id) current_id = (char *) udev_device_get_sysattr_value(current_dev, "id");
current_dev = udev_device_get_parent(current_dev);

if (current_dev == NULL) {
break;
// fallback to id if no product name found
if(current_id) return strdup(current_id);
return NULL;
}
}

Expand Down