summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-09-22 16:48:41 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-09-23 15:45:46 +1000
commitcba92f9762a377120867061fe42d656d1295bc44 (patch)
treeb5d04e1ae591135a3c161b67ba3434b847485356
parent4dce0648f668d416d88a3835c29667cd4fdb5850 (diff)
Add configuration option for left-handed behavior
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/libinput-private.h8
-rw-r--r--src/libinput.c37
-rw-r--r--src/libinput.h78
3 files changed, 123 insertions, 0 deletions
diff --git a/src/libinput-private.h b/src/libinput-private.h
index e71e685d..5a975d91 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -125,12 +125,20 @@ struct libinput_device_config_natural_scroll {
int (*get_default_enabled)(struct libinput_device *device);
};
+struct libinput_device_config_left_handed {
+ int (*has)(struct libinput_device *device);
+ enum libinput_config_status (*set)(struct libinput_device *device, int left_handed);
+ int (*get)(struct libinput_device *device);
+ int (*get_default)(struct libinput_device *device);
+};
+
struct libinput_device_config {
struct libinput_device_config_tap *tap;
struct libinput_device_config_calibration *calibration;
struct libinput_device_config_send_events *sendevents;
struct libinput_device_config_accel *accel;
struct libinput_device_config_natural_scroll *natural_scroll;
+ struct libinput_device_config_left_handed *left_handed;
};
struct libinput_device {
diff --git a/src/libinput.c b/src/libinput.c
index 6ac0d826..5780a92d 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1464,3 +1464,40 @@ libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput
return device->config.natural_scroll->get_default_enabled(device);
}
+
+LIBINPUT_EXPORT int
+libinput_device_config_buttons_has_left_handed(struct libinput_device *device)
+{
+ if (!device->config.left_handed)
+ return 0;
+
+ return device->config.left_handed->has(device);
+}
+
+LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
+ int left_handed)
+{
+ if (!libinput_device_config_buttons_has_left_handed(device))
+ return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+
+ return device->config.left_handed->set(device, left_handed);
+}
+
+LIBINPUT_EXPORT int
+libinput_device_config_buttons_get_left_handed(struct libinput_device *device)
+{
+ if (!libinput_device_config_buttons_has_left_handed(device))
+ return 0;
+
+ return device->config.left_handed->get(device);
+}
+
+LIBINPUT_EXPORT int
+libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device)
+{
+ if (!libinput_device_config_buttons_has_left_handed(device))
+ return 0;
+
+ return device->config.left_handed->get_default(device);
+}
diff --git a/src/libinput.h b/src/libinput.h
index cae10f40..9cc6f526 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1929,6 +1929,84 @@ libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device
int
libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device);
+/**
+ * @ingroup config
+ *
+ * Check if a device has a button configuration that supports left-handed
+ * usage.
+ *
+ * @param device The device to configure
+ * @return Non-zero if the device can be set to left-handed, or zero
+ * otherwise
+ *
+ * @see libinput_device_config_buttons_set_left_handed
+ * @see libinput_device_config_buttons_get_left_handed
+ * @see libinput_device_config_buttons_get_default_left_handed
+ */
+int
+libinput_device_config_buttons_has_left_handed(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Set the left-handed configuration of the device. A device in left-handed
+ * mode sends a left button event instead of the right button and vice
+ * versa.
+ *
+ * The exact button behavior is device-dependent. On a mouse and most
+ * pointing devices, left and right buttons are swapped but the middle
+ * button is unmodified. On a touchpad, physical buttons (if present) are
+ * swapped. On a clickpad, the top and bottom software-emulated buttons are
+ * swapped where present, the main area of the touchpad remains a left
+ * button. Tapping and clickfinger behavior is not affected by this setting.
+ *
+ * Changing the left-handed configuration of a device may not take effect
+ * until all buttons have been logically released.
+ *
+ * @param device The device to configure
+ * @param left_handed Zero to disable, non-zero to enable left-handed mode
+ * @return A configuration status code
+ *
+ * @see libinput_device_config_buttons_has_left_handed
+ * @see libinput_device_config_buttons_get_left_handed
+ * @see libinput_device_config_buttons_get_default_left_handed
+ */
+enum libinput_config_status
+libinput_device_config_buttons_set_left_handed(struct libinput_device *device,
+ int left_handed);
+
+/**
+ * @ingroup config
+ *
+ * Get the current left-handed configuration of the device.
+ *
+ * @param device The device to configure
+ * @return Zero if the device is in right-handed mode, non-zero if the
+ * device is in left-handed mode
+ *
+ * @see libinput_device_config_buttons_has_left_handed
+ * @see libinput_device_config_buttons_set_left_handed
+ * @see libinput_device_config_buttons_get_default_left_handed
+ */
+int
+libinput_device_config_buttons_get_left_handed(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Get the default left-handed configuration of the device.
+ *
+ * @param device The device to configure
+ * @return Zero if the device is in right-handed mode by default, or non-zero if the
+ * device is in left-handed mode by default
+ *
+ * @see libinput_device_config_buttons_has_left_handed
+ * @see libinput_device_config_buttons_set_left_handed
+ * @see libinput_device_config_buttons_get_left_handed
+ */
+int
+libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device);
+
#ifdef __cplusplus
}
#endif