diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-11-25 12:22:19 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-11-26 00:34:08 +0000 |
commit | 490131ff61c3973c678c128e2c8664274cefe021 (patch) | |
tree | 3d683a2b817d1caa35fc33068d2e1987083857c5 /tools/libinput-debug-events.c | |
parent | 765f7917bb448e2448cfffe6661986019284eb24 (diff) | |
download | libinput-490131ff61c3973c678c128e2c8664274cefe021.tar.gz |
tools: make debug-events accept multiple device nodes
For interaction between devices it's necessary to look at more than one device
at a time.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-debug-events.c')
-rw-r--r-- | tools/libinput-debug-events.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c index 069ef3c3..33b850f3 100644 --- a/tools/libinput-debug-events.c +++ b/tools/libinput-debug-events.c @@ -38,6 +38,8 @@ #include <libinput.h> #include <libevdev/libevdev.h> +#include "util-strings.h" +#include "util-macros.h" #include "shared.h" static uint32_t start_time; @@ -924,7 +926,7 @@ mainloop(struct libinput *li) 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 @@ -932,7 +934,8 @@ main(int argc, char **argv) { 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; @@ -981,12 +984,25 @@ main(int argc, char **argv) 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; @@ -1005,14 +1021,18 @@ main(int argc, char **argv) } 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)); @@ -1025,10 +1045,13 @@ main(int argc, char **argv) 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); |