tools: add --set-scroll-button as option

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2015-04-21 18:24:39 +10:00
parent 9ccd6c0cd2
commit fb53e08f96
3 changed files with 27 additions and 0 deletions

View file

@ -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)

View file

@ -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,

View file

@ -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;
};