mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 08:18:02 +02: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 "config.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -431,26 +432,51 @@ main(int argc, char **argv)
|
||||||
struct libinput *li;
|
struct libinput *li;
|
||||||
struct libinput_event *ev;
|
struct libinput_event *ev;
|
||||||
bool grab = false;
|
bool grab = false;
|
||||||
const char *seat[2] = {"seat0", NULL};
|
|
||||||
|
|
||||||
/* This is kept for backwards-compatibility with the old
|
while (1) {
|
||||||
libinput-list-devices */
|
int c;
|
||||||
if (argc > 1) {
|
int option_index = 0;
|
||||||
if (streq(argv[1], "--help")) {
|
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();
|
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;
|
|
||||||
}
|
}
|
||||||
|
if (optind < argc) {
|
||||||
li = tools_open_backend(BACKEND_UDEV, seat, false, &grab);
|
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)
|
if (!li)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,31 @@ libinput\-list\-devices \- list local devices as recognized by libinput and
|
||||||
default values of their configuration
|
default values of their configuration
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B libinput list\-devices [\-\-help]
|
.B libinput list\-devices [\-\-help]
|
||||||
|
.PP
|
||||||
|
.B libinput list\-devices \fI/dev/input/event0\fB [\fI/dev/input/event1\fB...]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.B "libinput list\-devices"
|
.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
|
devices recognized by libinput. Each device shows available configurations
|
||||||
the respective default configuration setting.
|
the respective default configuration setting.
|
||||||
.PP
|
.PP
|
||||||
For options that allow more settings than "enabled/disabled", all available ones
|
For options that allow more settings than "enabled/disabled", all available ones
|
||||||
are listed. The default setting is prefixed by an asterisk (*).
|
are listed. The default setting is prefixed by an asterisk (*).
|
||||||
.PP
|
.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
|
This tool usually needs to be run as root to have access to the
|
||||||
/dev/input/eventX nodes.
|
/dev/input/eventX nodes.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-\-help
|
.B \-\-help
|
||||||
Print help
|
Print help
|
||||||
|
.TP 8
|
||||||
|
.B \-\-verbose
|
||||||
|
Use verbose output
|
||||||
.SH NOTES
|
.SH NOTES
|
||||||
.PP
|
.PP
|
||||||
Some specific feature may still be available on a device even when
|
Some specific feature may still be available on a device even when
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue