mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-03 13:50:13 +01:00
tools: let debug-events take a device path
This is the most common use-case other than "all from udev", so let's just parse a device path correctly without requiring --device. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
5cd27b070e
commit
4e469291b1
6 changed files with 35 additions and 11 deletions
|
|
@ -904,7 +904,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
struct libinput *li;
|
||||
struct timespec tp;
|
||||
enum tools_backend backend = BACKEND_UDEV;
|
||||
enum tools_backend backend = BACKEND_NONE;
|
||||
const char *seat_or_device = "seat0";
|
||||
bool grab = false;
|
||||
bool verbose = false;
|
||||
|
|
@ -981,8 +981,14 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (optind < argc) {
|
||||
usage();
|
||||
return EXIT_INVALID_USAGE;
|
||||
if (optind < argc - 1 || backend != BACKEND_NONE) {
|
||||
usage();
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
backend = BACKEND_DEVICE;
|
||||
seat_or_device = argv[optind];
|
||||
} else if (backend == BACKEND_NONE) {
|
||||
backend = BACKEND_UDEV;
|
||||
}
|
||||
|
||||
memset(&act, 0, sizeof(act));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@
|
|||
.SH NAME
|
||||
libinput\-debug\-events \- debug helper for libinput
|
||||
.SH SYNOPSIS
|
||||
.B libinput debug\-events [\-\-help] [\-\-show\-keycodes] [\-\-udev \fI<seat>\fB|\-\-device \fI/dev/input/event0\fB] \fI[configuration options]\fB
|
||||
.B libinput debug\-events \fI[options]\fB
|
||||
.PP
|
||||
.B libinput debug\-events \fI[options]\fB \-\-udev \fI<seat>\fB
|
||||
.PP
|
||||
.B libinput debug\-events \fI[options]\fB [\-\-device] \fI/dev/input/event0\fB
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The
|
||||
|
|
@ -17,7 +21,8 @@ This tool usually needs to be run as root to have access to the
|
|||
.SH OPTIONS
|
||||
.TP 8
|
||||
.B \-\-device \fI/dev/input/event0\fR
|
||||
Use the given device with the path backend
|
||||
Use the given device with the path backend. The \fB\-\-device\fR argument may be
|
||||
omitted.
|
||||
.TP 8
|
||||
.B \-\-grab
|
||||
Exclusively grab all opened devices. This will prevent events from being
|
||||
|
|
|
|||
|
|
@ -916,7 +916,7 @@ sockets_init(struct libinput *li)
|
|||
|
||||
static void
|
||||
usage(void) {
|
||||
printf("Usage: libinput debug-gui [options] [--udev <seat>|--device /dev/input/event0]\n");
|
||||
printf("Usage: libinput debug-gui [options] [--udev <seat>|[--device] /dev/input/event0]\n");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -933,7 +933,7 @@ main(int argc, char **argv)
|
|||
struct window w = {0};
|
||||
struct tools_options options;
|
||||
struct libinput *li;
|
||||
enum tools_backend backend = BACKEND_UDEV;
|
||||
enum tools_backend backend = BACKEND_NONE;
|
||||
const char *seat_or_device = "seat0";
|
||||
bool verbose = false;
|
||||
|
||||
|
|
@ -999,8 +999,14 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (optind < argc) {
|
||||
usage();
|
||||
return EXIT_INVALID_USAGE;
|
||||
if (optind < argc - 1 || backend != BACKEND_NONE) {
|
||||
usage();
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
backend = BACKEND_DEVICE;
|
||||
seat_or_device = argv[optind];
|
||||
} else if (backend == BACKEND_NONE) {
|
||||
backend = BACKEND_UDEV;
|
||||
}
|
||||
|
||||
li = tools_open_backend(backend, seat_or_device, verbose, &w.grab);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@
|
|||
.SH NAME
|
||||
libinput\-debug\-gui \- visual debug helper for libinput
|
||||
.SH SYNOPSIS
|
||||
.B libinput debug\-gui [\-\-help] [\-\-udev \fI<seat>\fB|\-\-device \fI/dev/input/event0\fB] \fI[configuration options]\fB
|
||||
.B libinput debug\-gui \fI[options]\fB
|
||||
.PP
|
||||
.B libinput debug\-gui \fI[options]\fB \-\-udev \fI<seat>\fB
|
||||
.PP
|
||||
.B libinput debug\-gui \fI[options]\fB [\-\-device] \fI/dev/input/event0\fB
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The
|
||||
|
|
@ -21,7 +25,8 @@ This tool usually needs to be run as root to have access to the
|
|||
.SH OPTIONS
|
||||
.TP 8
|
||||
.B \-\-device \fI/dev/input/event0\fR
|
||||
Use the given device with the path backend.
|
||||
Use the given device with the path backend. The \fB\-\-device\fR argument may be
|
||||
omitted.
|
||||
.TP 8
|
||||
.B \-\-grab
|
||||
Exclusively grab all opened devices. This will prevent events from being
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ enum configuration_options {
|
|||
{ "set-speed", required_argument, 0, OPT_SPEED }
|
||||
|
||||
enum tools_backend {
|
||||
BACKEND_NONE,
|
||||
BACKEND_DEVICE,
|
||||
BACKEND_UDEV
|
||||
};
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ class TestToolWithOptions(object):
|
|||
self.run_command_missing_arg(['--device'])
|
||||
self.run_command_success(['--device', '/dev/input/event0'])
|
||||
self.run_command_success(['--device', '/dev/input/event1'])
|
||||
self.run_command_success(['/dev/input/event0'])
|
||||
|
||||
def test_options_pattern(self):
|
||||
for option in self.options['pattern']:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue