[PATCH libinput v2 1/5] Add a config interface for click methods
Hans de Goede
hdegoede at redhat.com
Wed Jan 14 05:54:42 PST 2015
From: Peter Hutterer <peter.hutterer at who-t.net>
Two methods are provided:
* button area - used on most clickpads, a click with a touch within a given
area generates left/middle/right clicks
* clickfinger - used on apple touchpads, a click with 1/2/3 fingers on the
touchpad generates a left, right, middle click
Both methods already exist in the touchpad code, this is just the
configuration interface.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
---
src/libinput-private.h | 9 +++++
src/libinput.c | 50 ++++++++++++++++++++++++
src/libinput.h | 102 +++++++++++++++++++++++++++++++++++++++++++++++++
src/libinput.sym | 4 ++
4 files changed, 165 insertions(+)
diff --git a/src/libinput-private.h b/src/libinput-private.h
index 84a0d44..9c01740 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -146,6 +146,14 @@ struct libinput_device_config_scroll_method {
uint32_t (*get_default_button)(struct libinput_device *device);
};
+struct libinput_device_config_click_method {
+ uint32_t (*get_methods)(struct libinput_device *device);
+ enum libinput_config_status (*set_method)(struct libinput_device *device,
+ enum libinput_config_click_method method);
+ enum libinput_config_click_method (*get_method)(struct libinput_device *device);
+ enum libinput_config_click_method (*get_default_method)(struct libinput_device *device);
+};
+
struct libinput_device_config {
struct libinput_device_config_tap *tap;
struct libinput_device_config_calibration *calibration;
@@ -154,6 +162,7 @@ struct libinput_device_config {
struct libinput_device_config_natural_scroll *natural_scroll;
struct libinput_device_config_left_handed *left_handed;
struct libinput_device_config_scroll_method *scroll_method;
+ struct libinput_device_config_click_method *click_method;
};
struct libinput_device {
diff --git a/src/libinput.c b/src/libinput.c
index 426c306..766c95f 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1584,6 +1584,56 @@ libinput_device_config_buttons_get_default_left_handed(struct libinput_device *d
}
LIBINPUT_EXPORT uint32_t
+libinput_device_config_click_get_methods(struct libinput_device *device)
+{
+ if (device->config.click_method)
+ return device->config.click_method->get_methods(device);
+ else
+ return 0;
+}
+
+LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_click_set_method(struct libinput_device *device,
+ enum libinput_config_click_method method)
+{
+ if ((libinput_device_config_click_get_methods(device) & method) != method)
+ return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+
+ /* Check method is a single valid method */
+ switch (method) {
+ case LIBINPUT_CONFIG_CLICK_METHOD_NONE:
+ case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS:
+ case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER:
+ break;
+ default:
+ return LIBINPUT_CONFIG_STATUS_INVALID;
+ }
+
+ if (device->config.click_method)
+ return device->config.click_method->set_method(device, method);
+ else /* method must be _NONE to get here */
+ return LIBINPUT_CONFIG_STATUS_SUCCESS;
+}
+
+LIBINPUT_EXPORT enum libinput_config_click_method
+libinput_device_config_click_get_method(struct libinput_device *device)
+{
+ if (device->config.click_method)
+ return device->config.click_method->get_method(device);
+ else
+ return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
+}
+
+LIBINPUT_EXPORT enum libinput_config_click_method
+libinput_device_config_click_get_default_method(struct libinput_device *device)
+{
+ if (device->config.click_method)
+ return device->config.click_method->get_default_method(device);
+ else
+ return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
+}
+
+LIBINPUT_EXPORT uint32_t
libinput_device_config_scroll_get_methods(struct libinput_device *device)
{
if (device->config.scroll_method)
diff --git a/src/libinput.h b/src/libinput.h
index d0518cc..6556527 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -2154,6 +2154,108 @@ libinput_device_config_buttons_get_default_left_handed(struct libinput_device *d
/**
* @ingroup config
*
+ * The click method defines when to generate software-emulated
+ * buttons, usually on a device that does not have a specific physical
+ * button available.
+ */
+enum libinput_config_click_method {
+ /**
+ * Do not send software-emulated button events. This has no effect
+ * on physical button generations.
+ */
+ LIBINPUT_CONFIG_CLICK_METHOD_NONE = 0,
+ /**
+ * Use software-button areas (see @ref tpbuttons) to generate button
+ * events.
+ */
+ LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS = (1 << 0),
+ /**
+ * The number of fingers decides which button press to generate.
+ */
+ LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER = (1 << 1),
+};
+
+/**
+ * @ingroup config
+ *
+ * Check which button click methods a device supports. The button click
+ * method defines when to generate software-emulated buttons, usually on a
+ * device that does not have a specific physical button available.
+ *
+ * @param device The device to configure
+ *
+ * @return A bitmask of possible methods.
+ *
+ * @see libinput_device_config_click_get_methods
+ * @see libinput_device_config_click_set_method
+ * @see libinput_device_config_click_get_method
+ */
+uint32_t
+libinput_device_config_click_get_methods(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Set the button click method for this device. The button click
+ * method defines when to generate software-emulated buttons, usually on a
+ * device that does not have a specific physical button available.
+ *
+ * @note The selected click method may not take effect immediately. The
+ * device may require changing to a neutral state first before activating
+ * the new method.
+ *
+ * @param device The device to configure
+ * @param method The button click method
+ *
+ * @return A config status code
+ *
+ * @see libinput_device_config_click_get_methods
+ * @see libinput_device_config_click_get_method
+ * @see libinput_device_config_click_get_default_method
+ */
+enum libinput_config_status
+libinput_device_config_click_set_method(struct libinput_device *device,
+ enum libinput_config_click_method method);
+/**
+ * @ingroup config
+ *
+ * Get the button click method for this device. The button click
+ * method defines when to generate software-emulated buttons, usually on a
+ * device that does not have a specific physical button available.
+ *
+ * @param device The device to configure
+ *
+ * @return The current button click method for this device
+ *
+ * @see libinput_device_config_click_get_methods
+ * @see libinput_device_config_click_set_method
+ * @see libinput_device_config_click_get_default_method
+ */
+enum libinput_config_click_method
+libinput_device_config_click_get_method(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Get the default button click method for this device. The button click
+ * method defines when to generate software-emulated buttons, usually on a
+ * device that does not have a specific physical button available.
+ *
+ * @param device The device to configure
+ *
+ * @return The default button click method for this device
+ *
+ * @see libinput_device_config_click_get_methods
+ * @see libinput_device_config_click_set_method
+ * @see libinput_device_config_click_get_method
+ */
+enum libinput_config_click_method
+libinput_device_config_click_get_default_method(struct libinput_device *device);
+
+
+/**
+ * @ingroup config
+ *
* The scroll method of a device selects when to generate scroll axis events
* instead of pointer motion events.
*/
diff --git a/src/libinput.sym b/src/libinput.sym
index 826bfde..87341cc 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -15,6 +15,10 @@ global:
libinput_device_config_calibration_get_matrix;
libinput_device_config_calibration_has_matrix;
libinput_device_config_calibration_set_matrix;
+ libinput_device_config_click_get_default_method;
+ libinput_device_config_click_get_method;
+ libinput_device_config_click_get_methods;
+ libinput_device_config_click_set_method;
libinput_device_config_scroll_get_button;
libinput_device_config_scroll_get_default_button;
libinput_device_config_scroll_get_default_method;
--
2.1.0
More information about the wayland-devel
mailing list