tools: add --set-scroll-button as option
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 21 Apr 2015 08:24:39 +0000 (18:24 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 21 Apr 2015 21:22:42 +0000 (07:22 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
tools/Makefile.am
tools/shared.c
tools/shared.h

index b8cc218bbb4ed63e1c1aa1e0a613e1547f7f1bb9..707e952d35890fcf2e38c533c75b4f91264acd67 100644 (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)
index 15ba8bc5c8a479e1d7ebb95ca52f0cc89cc09045..9ccd5dda1c8821f908399322cc7d264831665369 100644 (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,
index 7b0378827808822acb99b4dedb0ea6f939727e0b..a1aec462cd9feb2235fddbb025d7962b5e53a5bd 100644 (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;
 };