From 4ac52b4f1b178f1dcf54485d8fd63dfcfebf1577 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sun, 9 Mar 2025 17:55:49 +1000 Subject: [PATCH] tools: support sendevents mode in debug-events Disabling sendevents was already supported via an fnmatch() and --disable-sendevents but to test things like disabling on an external mouse, let's expose this option too. Part-of: --- tools/libinput-debug-events.man | 5 +++++ tools/shared.c | 15 +++++++++++++++ tools/shared.h | 3 +++ 3 files changed, 23 insertions(+) diff --git a/tools/libinput-debug-events.man b/tools/libinput-debug-events.man index 100e39a5..19b77a61 100644 --- a/tools/libinput-debug-events.man +++ b/tools/libinput-debug-events.man @@ -132,6 +132,11 @@ Set the button to the given button code .B \-\-set\-scroll\-method=[none|twofinger|edge|button] Set the desired scroll method .TP 8 +.B \-\-set\-sendevents=[disabled|enabled|disabled-on-external-mouse] +Set the given sendevents mode. This option overrides +\fB\-\-disable-sendevents="pattern"\fR for any devices it matches +via the \fB\-\-apply-to="pattern"\fR option. +.TP 8 .B \-\-set\-speed= Set pointer acceleration speed. The allowed range is [-1, 1]. This only applies to the flat or adaptive profile. diff --git a/tools/shared.c b/tools/shared.c index 13306f9d..e5a4dfe7 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -137,6 +137,7 @@ tools_init_options(struct tools_options *options) options->area.y1 = 0.0; options->area.x2 = 1.0; options->area.y2 = 1.0; + options->sendevents = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; } int @@ -311,6 +312,18 @@ tools_parse_option(int option, "%s", optarg); break; + case OPT_SENDEVENTS: + if (streq(optarg, "disabled")) + options->sendevents = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; + else if (streq(optarg, "enabled")) + options->sendevents = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; + else if (streq(optarg, "disabled-on-external-mouse")) + options->sendevents = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; + else { + fprintf(stderr, "Invalid sendevents mode: %s\n", optarg); + return 1; + } + break; case OPT_APPLY_TO: if (!optarg) return 1; @@ -573,6 +586,8 @@ tools_device_apply_config(struct libinput_device *device, fnmatch(options->match, name, 0) == FNM_NOMATCH) return; + libinput_device_config_send_events_set_mode(device, options->sendevents); + if (options->tapping != -1) libinput_device_config_tap_set_enabled(device, options->tapping); if (options->tap_map != (enum libinput_config_tap_button_map)-1) diff --git a/tools/shared.h b/tools/shared.h index d7090bc7..35e2808f 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -70,6 +70,7 @@ enum configuration_options { OPT_CALIBRATION, OPT_AREA, OPT_3FG_DRAG, + OPT_SENDEVENTS, }; #define CONFIGURATION_OPTIONS \ @@ -100,6 +101,7 @@ enum configuration_options { { "set-profile", required_argument, 0, OPT_PROFILE }, \ { "set-tap-map", required_argument, 0, OPT_TAP_MAP }, \ { "set-speed", required_argument, 0, OPT_SPEED },\ + { "set-sendevents", required_argument, 0, OPT_SENDEVENTS },\ { "apply-to", required_argument, 0, OPT_APPLY_TO },\ { "set-custom-points", required_argument, 0, OPT_CUSTOM_POINTS },\ { "set-custom-step", required_argument, 0, OPT_CUSTOM_STEP },\ @@ -144,6 +146,7 @@ struct tools_options { float calibration[6]; struct libinput_config_area_rectangle area; enum libinput_config_3fg_drag_state drag_3fg; + enum libinput_config_send_events_mode sendevents; }; void tools_init_options(struct tools_options *options);