diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index 217d3994..b02fa71d 100644 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -24,6 +24,7 @@ #include "config.h" #include +#include #include #include #include @@ -431,26 +432,51 @@ main(int argc, char **argv) struct libinput *li; struct libinput_event *ev; bool grab = false; - const char *seat[2] = {"seat0", NULL}; - /* This is kept for backwards-compatibility with the old - libinput-list-devices */ - if (argc > 1) { - if (streq(argv[1], "--help")) { + while (1) { + int c; + int option_index = 0; + enum { + OPT_HELP = 1, + OPT_VERBOSE, + }; + static struct option opts[] = { + CONFIGURATION_OPTIONS, + { "help", no_argument, 0, 'h' }, + { "verbose", no_argument, 0, OPT_VERBOSE }, + { 0, 0, 0, 0} + }; + c = getopt_long(argc, argv, "h", opts, &option_index); + if (c == -1) + break; + + switch(c) { + case '?': + return EXIT_INVALID_USAGE; + case 'h': + case OPT_HELP: usage(); - return 0; + return EXIT_SUCCESS; + default: + return EXIT_INVALID_USAGE; } - if (streq(argv[1], "--version")) { - printf("%s\n", LIBINPUT_VERSION); - return 0; - } - - usage(); - return EXIT_INVALID_USAGE; } - - li = tools_open_backend(BACKEND_UDEV, seat, false, &grab); + if (optind < argc) { + const char *devices[32] = {NULL}; + size_t ndevices = 0; + do { + if (ndevices >= ARRAY_LENGTH(devices) - 1) { + usage(); + return EXIT_INVALID_USAGE; + } + devices[ndevices++] = argv[optind]; + } while (++optind < argc); + li = tools_open_backend(BACKEND_DEVICE, devices, false, &grab); + } else { + const char *seat[2] = {"seat0", NULL}; + li = tools_open_backend(BACKEND_UDEV, seat, false, &grab); + } if (!li) return 1; diff --git a/tools/libinput-list-devices.man b/tools/libinput-list-devices.man index 7f18622c..f600017c 100644 --- a/tools/libinput-list-devices.man +++ b/tools/libinput-list-devices.man @@ -4,23 +4,31 @@ libinput\-list\-devices \- list local devices as recognized by libinput and default values of their configuration .SH SYNOPSIS .B libinput list\-devices [\-\-help] +.PP +.B libinput list\-devices \fI/dev/input/event0\fB [\fI/dev/input/event1\fB...] .SH DESCRIPTION .PP The .B "libinput list\-devices" -tool creates a libinput context on the default seat "seat0" and lists all +tool creates a libinput context on the default seat "seat0" and lists devices recognized by libinput. Each device shows available configurations the respective default configuration setting. .PP For options that allow more settings than "enabled/disabled", all available ones are listed. The default setting is prefixed by an asterisk (*). .PP +If one or more event node paths are given, only those devices are listed. +By default all devices recognized by libinput are listed. +.PP This tool usually needs to be run as root to have access to the /dev/input/eventX nodes. .SH OPTIONS .TP 8 .B \-\-help Print help +.TP 8 +.B \-\-verbose +Use verbose output .SH NOTES .PP Some specific feature may still be available on a device even when