[PATCH libinput 1.5/5] tools: add --set-scroll-button as option
Peter Hutterer
peter.hutterer at who-t.net
Tue Apr 21 01:30:50 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Sorry, should've been part of 1/5, I only just noticed that enabling
button scrolling isn't overly useful without setting the button too.
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 b8cc218..707e952 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 15ba8bc..9ccd5dd 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -30,6 +30,8 @@
#include <string.h>
#include <libudev.h>
+#include <libevdev/libevdev.h>
+
#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=<value>.... 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 7b03788..a1aec46 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;
};
--
2.3.5
More information about the wayland-devel
mailing list