mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-28 07:20:06 +01:00
tools/debug-events: print all available options
They're still without explanation but better than just printing "[options]" without even pointing to the man page. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1162>
This commit is contained in:
parent
79dc0261e2
commit
9f98e6d573
3 changed files with 37 additions and 11 deletions
|
|
@ -179,8 +179,11 @@ mainloop(struct libinput *li)
|
|||
}
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(struct option *opts) {
|
||||
printf("Usage: libinput debug-events [options] [--udev <seat>|--device /dev/input/event0 ...]\n");
|
||||
|
||||
if (opts)
|
||||
tools_print_usage_option_list(opts);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -232,7 +235,7 @@ main(int argc, char **argv)
|
|||
exit(EXIT_INVALID_USAGE);
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
usage(opts);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case OPT_SHOW_KEYCODES:
|
||||
|
|
@ -244,7 +247,7 @@ main(int argc, char **argv)
|
|||
case OPT_DEVICE:
|
||||
if (backend == BACKEND_UDEV ||
|
||||
ndevices >= ARRAY_LENGTH(seat_or_devices)) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
|
||||
}
|
||||
|
|
@ -254,7 +257,7 @@ main(int argc, char **argv)
|
|||
case OPT_UDEV:
|
||||
if (backend == BACKEND_DEVICE ||
|
||||
ndevices >= ARRAY_LENGTH(seat_or_devices)) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
|
||||
}
|
||||
|
|
@ -274,7 +277,7 @@ main(int argc, char **argv)
|
|||
break;
|
||||
default:
|
||||
if (tools_parse_option(c, optarg, &options) != 0) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -284,13 +287,13 @@ main(int argc, char **argv)
|
|||
|
||||
if (optind < argc) {
|
||||
if (backend == BACKEND_UDEV) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
backend = BACKEND_DEVICE;
|
||||
do {
|
||||
if (ndevices >= ARRAY_LENGTH(seat_or_devices)) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
seat_or_devices[ndevices++] = argv[optind];
|
||||
|
|
|
|||
|
|
@ -1883,8 +1883,11 @@ sockets_init(struct libinput *li)
|
|||
}
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(struct option *opts) {
|
||||
printf("Usage: libinput debug-gui [options] [--udev <seat>|[--device] /dev/input/event0]\n");
|
||||
|
||||
if (opts)
|
||||
tools_print_usage_option_list(opts);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -1948,7 +1951,7 @@ main(int argc, char **argv)
|
|||
exit(EXIT_INVALID_USAGE);
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
usage(opts);
|
||||
exit(0);
|
||||
break;
|
||||
case OPT_DEVICE:
|
||||
|
|
@ -1967,7 +1970,7 @@ main(int argc, char **argv)
|
|||
break;
|
||||
default:
|
||||
if (tools_parse_option(c, optarg, &options) != 0) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -1977,7 +1980,7 @@ main(int argc, char **argv)
|
|||
|
||||
if (optind < argc) {
|
||||
if (optind < argc - 1 || backend != BACKEND_NONE) {
|
||||
usage();
|
||||
usage(NULL);
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
backend = BACKEND_DEVICE;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
#include <quirks.h>
|
||||
#include <libinput.h>
|
||||
|
||||
#include "util-strings.h"
|
||||
|
||||
#define EXIT_INVALID_USAGE 2
|
||||
|
||||
extern uint32_t log_serial;
|
||||
|
|
@ -111,6 +113,24 @@ enum configuration_options {
|
|||
{ "set-calibration", required_argument, 0, OPT_CALIBRATION }, \
|
||||
{ "set-area", required_argument, 0, OPT_AREA }
|
||||
|
||||
static inline void
|
||||
tools_print_usage_option_list(struct option *opts)
|
||||
{
|
||||
printf("Options:\n");
|
||||
|
||||
struct option *o = opts;
|
||||
while (o && o->name) {
|
||||
if (strstartswith(o->name, "enable-") &&
|
||||
strstartswith((o+1)->name, "disable-")) {
|
||||
printf(" --%s/--%s\n", o->name, (o+1)->name);
|
||||
o++;
|
||||
} else {
|
||||
printf(" --%s\n", o->name);
|
||||
}
|
||||
o++;
|
||||
}
|
||||
}
|
||||
|
||||
enum tools_backend {
|
||||
BACKEND_NONE,
|
||||
BACKEND_DEVICE,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue