mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-12 23:50:27 +01:00
tools/list-devices: allow listing some devices only
$ libinput list-devices /dev/input/envent0 Now does what one would expect. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1140>
This commit is contained in:
parent
3cf6c91fff
commit
dbe8f7fede
2 changed files with 50 additions and 16 deletions
|
|
@ -24,6 +24,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue