mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 15:50:29 +01:00
Add configurable button map to tappings
The previously hardcoded button map for tapping is 1/2/3 to LRM. But the middle button is a common feature on the desktop (used for paste, most prominently) and three-finger tapping is almost impossible to do reliably on some touchpads (e.g. the T440 has a recognition rate of ~1 in 5). Left and right buttons have a prominent physical position (either softbuttons or physical buttons) so make the tap order configurable. Those that require middle buttons reliably can use the [software] buttons for left/right and 2-finger tap for a middle button. https://bugs.freedesktop.org/show_bug.cgi?id=96962 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
a1863b6db8
commit
59fac8e902
7 changed files with 173 additions and 0 deletions
|
|
@ -934,6 +934,25 @@ tp_tap_config_get_default(struct libinput_device *device)
|
|||
return tp_tap_default(evdev);
|
||||
}
|
||||
|
||||
static enum libinput_config_status
|
||||
tp_tap_config_set_map(struct libinput_device *device,
|
||||
enum libinput_config_tap_button_map map)
|
||||
{
|
||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static enum libinput_config_tap_button_map
|
||||
tp_tap_config_get_map(struct libinput_device *device)
|
||||
{
|
||||
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
}
|
||||
|
||||
static enum libinput_config_tap_button_map
|
||||
tp_tap_config_get_default_map(struct libinput_device *device)
|
||||
{
|
||||
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
}
|
||||
|
||||
static enum libinput_config_status
|
||||
tp_tap_config_set_drag_enabled(struct libinput_device *device,
|
||||
enum libinput_config_drag_state enabled)
|
||||
|
|
@ -1017,6 +1036,9 @@ tp_init_tap(struct tp_dispatch *tp)
|
|||
tp->tap.config.set_enabled = tp_tap_config_set_enabled;
|
||||
tp->tap.config.get_enabled = tp_tap_config_is_enabled;
|
||||
tp->tap.config.get_default = tp_tap_config_get_default;
|
||||
tp->tap.config.set_map = tp_tap_config_set_map;
|
||||
tp->tap.config.get_map = tp_tap_config_get_map;
|
||||
tp->tap.config.get_default_map = tp_tap_config_get_default_map;
|
||||
tp->tap.config.set_drag_enabled = tp_tap_config_set_drag_enabled;
|
||||
tp->tap.config.get_drag_enabled = tp_tap_config_get_drag_enabled;
|
||||
tp->tap.config.get_default_drag_enabled = tp_tap_config_get_default_drag_enabled;
|
||||
|
|
|
|||
|
|
@ -164,6 +164,11 @@ struct libinput_device_config_tap {
|
|||
enum libinput_config_tap_state (*get_enabled)(struct libinput_device *device);
|
||||
enum libinput_config_tap_state (*get_default)(struct libinput_device *device);
|
||||
|
||||
enum libinput_config_status (*set_map)(struct libinput_device *device,
|
||||
enum libinput_config_tap_button_map map);
|
||||
enum libinput_config_tap_button_map (*get_map)(struct libinput_device *device);
|
||||
enum libinput_config_tap_button_map (*get_default_map)(struct libinput_device *device);
|
||||
|
||||
enum libinput_config_status (*set_drag_enabled)(struct libinput_device *device,
|
||||
enum libinput_config_drag_state);
|
||||
enum libinput_config_drag_state (*get_drag_enabled)(struct libinput_device *device);
|
||||
|
|
|
|||
|
|
@ -3351,6 +3351,42 @@ libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
|
|||
return device->config.tap->get_default(device);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_status
|
||||
libinput_device_config_tap_set_button_map(struct libinput_device *device,
|
||||
enum libinput_config_tap_button_map map)
|
||||
{
|
||||
switch (map) {
|
||||
case LIBINPUT_CONFIG_TAP_MAP_LRM:
|
||||
case LIBINPUT_CONFIG_TAP_MAP_LMR:
|
||||
break;
|
||||
default:
|
||||
return LIBINPUT_CONFIG_STATUS_INVALID;
|
||||
}
|
||||
|
||||
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||
|
||||
return device->config.tap->set_map(device, map);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_tap_button_map
|
||||
libinput_device_config_tap_get_button_map(struct libinput_device *device)
|
||||
{
|
||||
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
||||
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
|
||||
return device->config.tap->get_map(device);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_tap_button_map
|
||||
libinput_device_config_tap_get_default_button_map(struct libinput_device *device)
|
||||
{
|
||||
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
||||
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
|
||||
return device->config.tap->get_default_map(device);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_status
|
||||
libinput_device_config_tap_set_drag_enabled(struct libinput_device *device,
|
||||
enum libinput_config_drag_state enable)
|
||||
|
|
|
|||
|
|
@ -3771,6 +3771,88 @@ libinput_device_config_tap_get_enabled(struct libinput_device *device);
|
|||
enum libinput_config_tap_state
|
||||
libinput_device_config_tap_get_default_enabled(struct libinput_device *device);
|
||||
|
||||
/**
|
||||
* @ingroup config
|
||||
*/
|
||||
enum libinput_config_tap_button_map {
|
||||
/** 1/2/3 finger tap maps to left/right/middle */
|
||||
LIBINPUT_CONFIG_TAP_MAP_LRM,
|
||||
/** 1/2/3 finger tap maps to left/middle/right*/
|
||||
LIBINPUT_CONFIG_TAP_MAP_LMR,
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup config
|
||||
*
|
||||
* Set the finger number to button number mapping for tap-to-click. The
|
||||
* default mapping on most devices is to have a 1, 2 and 3 finger tap to map
|
||||
* to the left, right and middle button, respectively.
|
||||
* A device may permit changing the button mapping but disallow specific
|
||||
* maps. In this case @ref LIBINPUT_CONFIG_STATUS_UNSUPPORTED is returned,
|
||||
* the caller is expected to handle this case correctly.
|
||||
*
|
||||
* Changing the button mapping may not take effect immediately,
|
||||
* the device may wait until it is in a neutral state before applying any
|
||||
* changes.
|
||||
*
|
||||
* The mapping may be changed when tap-to-click is disabled. The new mapping
|
||||
* takes effect when tap-to-click is enabled in the future.
|
||||
*
|
||||
* @note It is an application bug to call this function for devices where
|
||||
* libinput_device_config_tap_get_finger_count() returns 0.
|
||||
*
|
||||
* @param device The device to configure
|
||||
* @param map The new finger-to-button number mapping
|
||||
* @return A config status code. Changing the order on a device that does not
|
||||
* support tapping always fails with @ref LIBINPUT_CONFIG_STATUS_UNSUPPORTED.
|
||||
*
|
||||
* @see libinput_device_config_tap_get_button_map
|
||||
* @see libinput_device_config_tap_get_default_button_map
|
||||
*/
|
||||
enum libinput_config_status
|
||||
libinput_device_config_tap_set_button_map(struct libinput_device *device,
|
||||
enum libinput_config_tap_button_map map);
|
||||
|
||||
/**
|
||||
* @ingroup config
|
||||
*
|
||||
* Get the finger number to button number mapping for tap-to-click.
|
||||
*
|
||||
* The return value for a device that does not support tapping is always
|
||||
* @ref LIBINPUT_CONFIG_TAP_MAP_LRM.
|
||||
*
|
||||
* @note It is an application bug to call this function for devices where
|
||||
* libinput_device_config_tap_get_finger_count() returns 0.
|
||||
*
|
||||
* @param device The device to configure
|
||||
* @return The current finger-to-button number mapping
|
||||
*
|
||||
* @see libinput_device_config_tap_set_button_map
|
||||
* @see libinput_device_config_tap_get_default_button_map
|
||||
*/
|
||||
enum libinput_config_tap_button_map
|
||||
libinput_device_config_tap_get_button_map(struct libinput_device *device);
|
||||
|
||||
/**
|
||||
* @ingroup config
|
||||
*
|
||||
* Get the default finger number to button number mapping for tap-to-click.
|
||||
*
|
||||
* The return value for a device that does not support tapping is always
|
||||
* @ref LIBINPUT_CONFIG_TAP_MAP_LRM.
|
||||
*
|
||||
* @note It is an application bug to call this function for devices where
|
||||
* libinput_device_config_tap_get_finger_count() returns 0.
|
||||
*
|
||||
* @param device The device to configure
|
||||
* @return The current finger-to-button number mapping
|
||||
*
|
||||
* @see libinput_device_config_tap_set_button_map
|
||||
* @see libinput_device_config_tap_get_default_button_map
|
||||
*/
|
||||
enum libinput_config_tap_button_map
|
||||
libinput_device_config_tap_get_default_button_map(struct libinput_device *device);
|
||||
|
||||
/**
|
||||
* @ingroup config
|
||||
*
|
||||
|
|
|
|||
|
|
@ -274,3 +274,9 @@ LIBINPUT_1.4 {
|
|||
libinput_tablet_pad_mode_group_set_user_data;
|
||||
libinput_tablet_pad_mode_group_unref;
|
||||
} LIBINPUT_1.3;
|
||||
|
||||
LIBINPUT_1.5 {
|
||||
libinput_device_config_tap_get_button_map;
|
||||
libinput_device_config_tap_get_default_button_map;
|
||||
libinput_device_config_tap_set_button_map;
|
||||
} LIBINPUT_1.4;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ enum options {
|
|||
OPT_VERBOSE,
|
||||
OPT_TAP_ENABLE,
|
||||
OPT_TAP_DISABLE,
|
||||
OPT_TAP_MAP,
|
||||
OPT_DRAG_ENABLE,
|
||||
OPT_DRAG_DISABLE,
|
||||
OPT_DRAG_LOCK_ENABLE,
|
||||
|
|
@ -101,6 +102,7 @@ tools_usage()
|
|||
"--set-scroll-button=BTN_MIDDLE ... set the button to the given button code\n"
|
||||
"--set-profile=[adaptive|flat].... set pointer acceleration profile\n"
|
||||
"--set-speed=<value>.... set pointer acceleration speed\n"
|
||||
"--set-tap-map=[lrm|lmr] ... set button mapping for tapping\n"
|
||||
"\n"
|
||||
"These options apply to all applicable devices, if a feature\n"
|
||||
"is not explicitly specified it is left at each device's default.\n"
|
||||
|
|
@ -121,6 +123,7 @@ tools_init_context(struct tools_context *context)
|
|||
|
||||
memset(options, 0, sizeof(*options));
|
||||
options->tapping = -1;
|
||||
options->tap_map = -1;
|
||||
options->drag = -1;
|
||||
options->drag_lock = -1;
|
||||
options->natural_scroll = -1;
|
||||
|
|
@ -168,6 +171,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
|
|||
{ "set-scroll-method", 1, 0, OPT_SCROLL_METHOD },
|
||||
{ "set-scroll-button", 1, 0, OPT_SCROLL_BUTTON },
|
||||
{ "set-profile", 1, 0, OPT_PROFILE },
|
||||
{ "set-tap-map", 1, 0, OPT_TAP_MAP },
|
||||
{ "speed", 1, 0, OPT_SPEED },
|
||||
{ 0, 0, 0, 0}
|
||||
};
|
||||
|
|
@ -206,6 +210,20 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
|
|||
case OPT_TAP_DISABLE:
|
||||
options->tapping = 0;
|
||||
break;
|
||||
case OPT_TAP_MAP:
|
||||
if (!optarg) {
|
||||
tools_usage();
|
||||
return 1;
|
||||
}
|
||||
if (streq(optarg, "lrm")) {
|
||||
options->tap_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
} else if (streq(optarg, "lmr")) {
|
||||
options->tap_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
|
||||
} else {
|
||||
tools_usage();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case OPT_DRAG_ENABLE:
|
||||
options->drag = 1;
|
||||
break;
|
||||
|
|
@ -451,6 +469,9 @@ tools_device_apply_config(struct libinput_device *device,
|
|||
{
|
||||
if (options->tapping != -1)
|
||||
libinput_device_config_tap_set_enabled(device, options->tapping);
|
||||
if (options->tap_map != -1)
|
||||
libinput_device_config_tap_set_button_map(device,
|
||||
options->tap_map);
|
||||
if (options->drag != -1)
|
||||
libinput_device_config_tap_set_drag_enabled(device,
|
||||
options->drag);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ struct tools_options {
|
|||
int middlebutton;
|
||||
enum libinput_config_click_method click_method;
|
||||
enum libinput_config_scroll_method scroll_method;
|
||||
enum libinput_config_tap_button_map tap_map;
|
||||
int scroll_button;
|
||||
double speed;
|
||||
int dwt;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue