From fb53e08f967268174a33a5a7772bf313659199e6 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 21 Apr 2015 18:24:39 +1000 Subject: [PATCH] tools: add --set-scroll-button as option Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- tools/Makefile.am | 2 ++ tools/shared.c | 24 ++++++++++++++++++++++++ tools/shared.h | 1 + 3 files changed, 27 insertions(+) diff --git a/tools/Makefile.am b/tools/Makefile.am index b8cc218b..707e952d 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -9,6 +9,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \ libshared_la_SOURCES = \ shared.c \ shared.h +libshared_la_CFLAGS = $(LIBEVDEV_CFLAGS) +libshared_la_LIBADD = $(LIBEVDEV_LIBS) event_debug_SOURCES = event-debug.c event_debug_LDADD = ../src/libinput.la libshared.la $(LIBUDEV_LIBS) diff --git a/tools/shared.c b/tools/shared.c index 15ba8bc5..9ccd5dda 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -30,6 +30,8 @@ #include #include +#include + #include "shared.h" enum options { @@ -47,6 +49,7 @@ enum options { OPT_MIDDLEBUTTON_DISABLE, OPT_CLICK_METHOD, OPT_SCROLL_METHOD, + OPT_SCROLL_BUTTON, OPT_SPEED, }; @@ -78,6 +81,7 @@ tools_usage() "--disable-middlebutton.... enable/disable middle button emulation\n" "--set-click-method=[none|clickfinger|buttonareas] .... set the desired click method\n" "--set-scroll-method=[none|twofinger|edge|button] ... set the desired scroll method\n" + "--set-scroll-button=BTN_MIDDLE ... set the button to the given button code\n" "--set-speed=.... set pointer acceleration speed\n" "\n" "These options apply to all applicable devices, if a feature\n" @@ -99,6 +103,7 @@ tools_init_options(struct tools_options *options) options->middlebutton = -1; options->click_method = -1; options->scroll_method = -1; + options->scroll_button = -1; options->backend = BACKEND_UDEV; options->seat = "seat0"; options->speed = 0.0; @@ -125,6 +130,7 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) { "disable-middlebutton", 0, 0, OPT_MIDDLEBUTTON_DISABLE }, { "set-click-method", 1, 0, OPT_CLICK_METHOD }, { "set-scroll-method", 1, 0, OPT_SCROLL_METHOD }, + { "set-scroll-button", 1, 0, OPT_SCROLL_BUTTON }, { "speed", 1, 0, OPT_SPEED }, { 0, 0, 0, 0} }; @@ -219,6 +225,21 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) return 1; } break; + case OPT_SCROLL_BUTTON: + if (!optarg) { + tools_usage(); + return 1; + } + options->scroll_button = + libevdev_event_code_from_name(EV_KEY, + optarg); + if (options->scroll_button == -1) { + fprintf(stderr, + "Invalid button %s\n", + optarg); + return 1; + } + break; case OPT_SPEED: if (!optarg) { tools_usage(); @@ -346,6 +367,9 @@ tools_device_apply_config(struct libinput_device *device, if (options->scroll_method != -1) libinput_device_config_scroll_set_method(device, options->scroll_method); + if (options->scroll_button != -1) + libinput_device_config_scroll_set_button(device, + options->scroll_button); if (libinput_device_config_accel_is_available(device)) libinput_device_config_accel_set_speed(device, diff --git a/tools/shared.h b/tools/shared.h index 7b037882..a1aec462 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -42,6 +42,7 @@ struct tools_options { int middlebutton; enum libinput_config_click_method click_method; enum libinput_config_scroll_method scroll_method; + int scroll_button; double speed; };