]> diplodocus.org Git - xorg-xinput/commitdiff
Add a warning when the user specifies an ambiguous device name
authorPhilip Langdale <philipl@fido2.homeip.net>
Thu, 10 Jan 2008 02:17:43 +0000 (18:17 -0800)
committerPhilip Langdale <philipl@fido2.homeip.net>
Thu, 10 Jan 2008 02:17:43 +0000 (18:17 -0800)
suggesting that they use the device id instead.

src/xinput.c

index f74dee5aa1017e12be864779a9e078f76bce127d..68d41361bbf1175a4646105d3b391e72d6a7ac3b 100644 (file)
@@ -108,6 +108,7 @@ find_device_info(Display    *display,
                 Bool           only_extended)
 {
     XDeviceInfo        *devices;
+    XDeviceInfo *found = NULL;
     int                loop;
     int                num_devices;
     int                len = strlen(name);
@@ -131,10 +132,17 @@ find_device_info(Display  *display,
        if ((!only_extended || (devices[loop].use >= IsXExtensionDevice)) &&
            ((!is_id && strcmp(devices[loop].name, name) == 0) ||
             (is_id && devices[loop].id == id))) {
-           return &devices[loop];
+           if (found) {
+               fprintf(stderr,
+                       "Warning: There are multiple devices named \"%s\".\n"
+                       "To ensure the correct one is selected, please use "
+                       "the device ID instead.\n\n", name);
+           } else {
+               found = &devices[loop];
+           }
        }
     }
-    return NULL;
+    return found;
 }
 
 static void