Package: consolation Version: 0.0.7-1 Hi, thank you so much for writing this! I was struggling with gpm for a while because of /dev/input/mice not sending buttons properly for trackpads.
For me middle button is just annoyingly difficult to press on t440p, and I wanted to use the "right" button (top right area) as paste button. I added a quick patch/hack (attached), that adds --set-paste-button option, that allows me to use the right button. again, thank you for writing this! PS: I am new to the debian community, and I apologize if this is not the right way to send a patch.
commit a1479d8a87e99ffaff22587969b63cd1f48bfae8 Author: borislav nikolov <j...@sofialondonmoskva.com> Date: Thu Mar 19 14:23:33 2020 +0100 add --set-paste-button diff --git a/src/Makefile.in b/src/Makefile.in index 88337c7..a8129ba 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/src/action.c b/src/action.c index 1df6070..9ff7bba 100644 --- a/src/action.c +++ b/src/action.c @@ -108,27 +108,17 @@ release_left_button(void) } void -press_middle_button(void) +press_paste_button(int b) { if (mouse_reporting != MOUSE_REPORTING_OFF) { - button = BUTTON_MIDDLE; + button = b; report_pointer((int)xx,(int)yy,button); } else paste(); } -void -release_middle_button(void) -{ - if (mouse_reporting == MOUSE_REPORTING_X11) - { - button = BUTTON_RELEASED; - report_pointer((int)xx,(int)yy,button); - } -} - void press_right_button(void) { @@ -145,7 +135,7 @@ press_right_button(void) } void -release_right_button(void) +release_button(void) { if (mouse_reporting == MOUSE_REPORTING_X11) { @@ -154,6 +144,7 @@ release_right_button(void) } } + void vertical_axis(double v) { diff --git a/src/consolation.h b/src/consolation.h index 5290d65..a70b3b9 100644 --- a/src/consolation.h +++ b/src/consolation.h @@ -56,11 +56,10 @@ void set_lut(const char *word_chars); void set_pointer(double x, double y); void move_pointer(double x, double y); void press_left_button(void); -void release_left_button(void); -void press_middle_button(void); -void release_middle_button(void); void press_right_button(void); -void release_right_button(void); +void release_left_button(void); +void release_button(void); +void press_paste_button(int b); void vertical_axis(double v); /* input.c */ diff --git a/src/input.c b/src/input.c index 5bed228..bf74ae0 100644 --- a/src/input.c +++ b/src/input.c @@ -82,6 +82,14 @@ handle_pointer_button_event(struct libinput_event *ev) int button; button = libinput_event_pointer_get_button(p); state = libinput_event_pointer_get_button_state(p); + if (button == options.paste_button) { + if (state==LIBINPUT_BUTTON_STATE_PRESSED) + press_paste_button(button); + else + release_button(); + return; + } + switch(button) { case BTN_LEFT: @@ -90,17 +98,11 @@ handle_pointer_button_event(struct libinput_event *ev) else release_left_button(); break; - case BTN_MIDDLE: - if (state==LIBINPUT_BUTTON_STATE_PRESSED) - press_middle_button(); - else - release_middle_button(); - break; case BTN_RIGHT: if (state==LIBINPUT_BUTTON_STATE_PRESSED) press_right_button(); else - release_right_button(); + release_button(); break; } } @@ -245,6 +247,7 @@ usage(void) "--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-paste-button=BTN_MIDDLE ... use this button code to paste\n" "--set-profile=[adaptive|flat].... set pointer acceleration profile\n" "--set-speed=<value>.... set pointer acceleration speed (allowed range [-1, 1]) \n" "--set-tap-map=[lrm|lmr] ... set button mapping for tapping\n" diff --git a/src/shared.c b/src/shared.c index 2c08956..606861c 100644 --- a/src/shared.c +++ b/src/shared.c @@ -79,6 +79,7 @@ tools_init_options(struct tools_options *options) options->click_method = -1; options->scroll_method = -1; options->scroll_button = -1; + options->paste_button = BTN_MIDDLE; options->speed = 0.0; options->profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; } @@ -194,6 +195,20 @@ tools_parse_option(int option, return 1; } break; + case OPT_PASTE_BUTTON: + if (!optarg) { + return 1; + } + options->paste_button = + libevdev_event_code_from_name(EV_KEY, + optarg); + if (options->paste_button == -1) { + fprintf(stderr, + "Invalid button %s\n", + optarg); + return 1; + } + break; case OPT_SPEED: if (!optarg) return 1; @@ -391,7 +406,6 @@ tools_device_apply_config(struct libinput_device *device, 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, options->speed); diff --git a/src/shared.h b/src/shared.h index 074ba7e..b1e6ff6 100644 --- a/src/shared.h +++ b/src/shared.h @@ -50,6 +50,7 @@ enum configuration_options { OPT_CLICK_METHOD, OPT_SCROLL_METHOD, OPT_SCROLL_BUTTON, + OPT_PASTE_BUTTON, OPT_SPEED, OPT_PROFILE, OPT_DISABLE_SENDEVENTS, @@ -75,6 +76,7 @@ enum configuration_options { { "set-click-method", required_argument, 0, OPT_CLICK_METHOD }, \ { "set-scroll-method", required_argument, 0, OPT_SCROLL_METHOD }, \ { "set-scroll-button", required_argument, 0, OPT_SCROLL_BUTTON }, \ + { "set-paste-button", required_argument, 0, OPT_PASTE_BUTTON }, \ { "set-profile", required_argument, 0, OPT_PROFILE }, \ { "set-tap-map", required_argument, 0, OPT_TAP_MAP }, \ { "set-speed", required_argument, 0, OPT_SPEED }, \ @@ -98,6 +100,7 @@ struct tools_options { enum libinput_config_scroll_method scroll_method; enum libinput_config_tap_button_map tap_map; int scroll_button; + int paste_button; double speed; int dwt; enum libinput_config_accel_profile profile;