From: Philip Langdale Date: Thu, 10 Jan 2008 02:17:43 +0000 (-0800) Subject: Add a warning when the user specifies an ambiguous device name X-Git-Url: https://diplodocus.org/git/xorg-xinput/commitdiff_plain/ff7a63770ab9ce7336c7a9a70b0ae86de4b35bf3?ds=sidebyside;hp=--cc Add a warning when the user specifies an ambiguous device name suggesting that they use the device id instead. --- ff7a63770ab9ce7336c7a9a70b0ae86de4b35bf3 diff --git a/src/xinput.c b/src/xinput.c index f74dee5..68d4136 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -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