From ebc84e82acbec68013815bbc88b90173f0d53438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Bouchaud=20=28yoz=29?= Date: Thu, 31 Jan 2019 08:39:41 -0500 Subject: [PATCH] elput: Add API to allow settings tap-to-click on pointer device Summary: Add a way to configure pointer device with tap-to-click features. @feature Reviewers: ManMower, devilhorns Reviewed By: devilhorns Subscribers: devilhorns, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7843 --- src/lib/elput/Elput.h | 14 ++++++++++++++ src/lib/elput/elput_input.c | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h index e38adf577d..a651ccfc84 100644 --- a/src/lib/elput/Elput.h +++ b/src/lib/elput/Elput.h @@ -374,6 +374,20 @@ EAPI void elput_input_pointer_max_set(Elput_Manager *manager, int maxw, int maxh */ EAPI Eina_Bool elput_input_pointer_rotation_set(Elput_Manager *manager, int rotation); +/** + * Set tap-to-click status + * + * @param manager + * @param status + * + * @return EINA_TRUE on success, EINA_FALSE otherwise + * + * @ingroup Elput_Input_Group + * @since 1.22 + */ +EAPI void elput_input_touch_tap_to_click_enabled_set(Elput_Manager *manager, const char *seat, Eina_Bool enabled); + + /** * Calibrate input devices for given screen size * diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c index ca0e130002..392b157b1b 100644 --- a/src/lib/elput/elput_input.c +++ b/src/lib/elput/elput_input.c @@ -847,6 +847,44 @@ elput_input_pointer_accel_speed_set(Elput_Manager *manager, const char *seat, do } } +EAPI void +elput_input_touch_tap_to_click_enabled_set(Elput_Manager *manager, const char *seat, Eina_Bool enabled) +{ + Elput_Seat *eseat; + Elput_Device *edev; + Eina_List *l, *ll; + enum libinput_config_tap_state state; + + EINA_SAFETY_ON_NULL_RETURN(manager); + + state = enabled ? LIBINPUT_CONFIG_TAP_ENABLED : LIBINPUT_CONFIG_TAP_DISABLED; + + /* if no seat name is passed in, just use default seat name */ + if (!seat) seat = "seat0"; + + EINA_LIST_FOREACH(manager->input.seats, l, eseat) + { + if ((eseat->name) && (strcmp(eseat->name, seat))) + continue; + + EINA_LIST_FOREACH(eseat->devices, ll, edev) + { + if (!libinput_device_has_capability(edev->device, + LIBINPUT_DEVICE_CAP_POINTER)) + continue; + + if (libinput_device_config_tap_set_enabled(edev->device, state) + != LIBINPUT_CONFIG_STATUS_SUCCESS) + { + WRN("Failed to %s tap-to-click on device: %s", + enabled ? "enable" : "disable", + libinput_device_get_name(edev->device)); + continue; + } + } + } +} + EAPI Elput_Seat * elput_device_seat_get(const Elput_Device *dev) {