#include <libinput.h>
#include <libevdev/libevdev.h>
+#include "util-strings.h"
+#include "util-macros.h"
#include "shared.h"
static uint32_t start_time;
static void
usage(void) {
- printf("Usage: libinput debug-events [options] [--udev <seat>|--device /dev/input/event0]\n");
+ printf("Usage: libinput debug-events [options] [--udev <seat>|--device /dev/input/event0 ...]\n");
}
int
{
struct libinput *li;
enum tools_backend backend = BACKEND_NONE;
- const char *seat_or_device = "seat0";
+ char *seat_or_devices[64] = {NULL};
+ size_t ndevices = 0;
bool grab = false;
bool verbose = false;
struct sigaction act;
be_quiet = true;
break;
case OPT_DEVICE:
+ if (backend == BACKEND_UDEV ||
+ ndevices >= ARRAY_LENGTH(seat_or_devices)) {
+ usage();
+ return EXIT_INVALID_USAGE;
+
+ }
backend = BACKEND_DEVICE;
- seat_or_device = optarg;
+ seat_or_devices[ndevices++] = safe_strdup(optarg);
break;
case OPT_UDEV:
+ if (backend == BACKEND_DEVICE ||
+ ndevices >= ARRAY_LENGTH(seat_or_devices)) {
+ usage();
+ return EXIT_INVALID_USAGE;
+
+ }
backend = BACKEND_UDEV;
- seat_or_device = optarg;
+ seat_or_devices[0] = safe_strdup(optarg);
+ ndevices = 1;
break;
case OPT_GRAB:
grab = true;
}
if (optind < argc) {
- if (optind < argc - 1 || backend != BACKEND_NONE) {
+ if (backend == BACKEND_UDEV) {
usage();
return EXIT_INVALID_USAGE;
}
backend = BACKEND_DEVICE;
- seat_or_device = argv[optind];
+ do {
+ seat_or_devices[ndevices++] = safe_strdup(argv[optind]);
+ } while(++optind < argc);
} else if (backend == BACKEND_NONE) {
backend = BACKEND_UDEV;
+ seat_or_devices[0] = safe_strdup("seat0");
+ ndevices = 1;
}
memset(&act, 0, sizeof(act));
return EXIT_FAILURE;
}
- li = tools_open_backend(backend, seat_or_device, verbose, &grab);
+ li = tools_open_backend(backend, seat_or_devices, verbose, &grab);
if (!li)
return EXIT_FAILURE;
+ while (ndevices-- > 0)
+ free(seat_or_devices[ndevices]);
+
mainloop(li);
libinput_unref(li);
.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
+.B libinput debug\-events \fI[options]\fB [\-\-device] \fI/dev/input/event0\fB [\fI/dev/input/event1\fB...]
.SH DESCRIPTION
.PP
The
.SH OPTIONS
.TP 8
.B \-\-device \fI/dev/input/event0\fR
-Use the given device with the path backend. The \fB\-\-device\fR argument may be
+Use the given device(s) with the path backend. The \fB\-\-device\fR argument may be
omitted.
.TP 8
.B \-\-grab
struct tools_options options;
struct libinput *li;
enum tools_backend backend = BACKEND_NONE;
- const char *seat_or_device = "seat0";
+ char *seat_or_device[2] = {"seat0", NULL};
bool verbose = false;
if (!gtk_init_check(&argc, &argv))
break;
case OPT_DEVICE:
backend = BACKEND_DEVICE;
- seat_or_device = optarg;
+ seat_or_device[0] = optarg;
break;
case OPT_UDEV:
backend = BACKEND_UDEV;
- seat_or_device = optarg;
+ seat_or_device[0] = optarg;
break;
case OPT_GRAB:
w.grab = true;
return EXIT_INVALID_USAGE;
}
backend = BACKEND_DEVICE;
- seat_or_device = argv[optind];
+ seat_or_device[0] = argv[optind];
} else if (backend == BACKEND_NONE) {
backend = BACKEND_UDEV;
}
struct context ctx;
struct libinput *li;
enum tools_backend backend = BACKEND_NONE;
- const char *seat_or_device = "seat0";
+ char *seat_or_device[2] = {"seat0", NULL};
struct sigaction act;
bool grab = false;
break;
case OPT_DEVICE:
backend = BACKEND_DEVICE;
- seat_or_device = optarg;
+ seat_or_device[0] = optarg;
break;
case OPT_UDEV:
backend = BACKEND_UDEV;
- seat_or_device = optarg;
+ seat_or_device[0] = optarg;
break;
}
return EXIT_INVALID_USAGE;
}
backend = BACKEND_DEVICE;
- seat_or_device = argv[optind];
+ seat_or_device[0] = argv[optind];
} else if (backend == BACKEND_NONE) {
backend = BACKEND_UDEV;
}
struct libinput *li;
struct libinput_event *ev;
bool grab = false;
+ char *seat[2] = {"seat0", NULL};
/* This is kept for backwards-compatibility with the old
libinput-list-devices */
}
}
- li = tools_open_backend(BACKEND_UDEV, "seat0", false, &grab);
+ li = tools_open_backend(BACKEND_UDEV, seat, false, &grab);
if (!li)
return 1;
}
static struct libinput *
-tools_open_device(const char *path, bool verbose, bool *grab)
+tools_open_device(char **paths, bool verbose, bool *grab)
{
struct libinput_device *device;
struct libinput *li;
+ char **p = paths;
li = libinput_path_create_context(&interface, grab);
if (!li) {
- fprintf(stderr, "Failed to initialize context from %s\n", path);
+ fprintf(stderr, "Failed to initialize path context\n");
return NULL;
}
libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
}
- device = libinput_path_add_device(li, path);
- if (!device) {
- fprintf(stderr, "Failed to initialize device %s\n", path);
- libinput_unref(li);
- li = NULL;
+ while (*p) {
+ device = libinput_path_add_device(li, *p);
+ if (!device) {
+ fprintf(stderr, "Failed to initialize device %s\n", *p);
+ libinput_unref(li);
+ li = NULL;
+ break;
+ }
+ p++;
}
return li;
struct libinput *
tools_open_backend(enum tools_backend which,
- const char *seat_or_device,
+ char **seat_or_device,
bool verbose,
bool *grab)
{
switch (which) {
case BACKEND_UDEV:
- li = tools_open_udev(seat_or_device, verbose, grab);
+ li = tools_open_udev(seat_or_device[0], verbose, grab);
break;
case BACKEND_DEVICE:
li = tools_open_device(seat_or_device, verbose, grab);
const char *optarg,
struct tools_options *options);
struct libinput* tools_open_backend(enum tools_backend which,
- const char *seat_or_device,
+ char **seat_or_devices,
bool verbose,
bool *grab);
void tools_device_apply_config(struct libinput_device *device,
self.run_command_unrecognized_option(['--foo'])
self.run_command_unrecognized_option(['--version'])
+ def test_multiple_devices(self):
+ self.run_command_success(['--device', '/dev/input/event0', '/dev/input/event1'])
+ # same event path multiple times? meh, your problem
+ self.run_command_success(['--device', '/dev/input/event0', '/dev/input/event0'])
+ self.run_command_success(['/dev/input/event0', '/dev/input/event1'])
+
class TestDebugGUI(TestToolWithOptions, TestLibinputTool):
subtool = 'debug-gui'