Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- src/libinput-private.h | 8 ++++++ src/libinput.c | 37 ++++++++++++++++++++++++ src/libinput.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+)
diff --git a/src/libinput-private.h b/src/libinput-private.h index e71e685..5a975d9 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 6ac0d82..5780a92 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 cae10f4..9cc6f52 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 -- 1.9.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel