mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 11:19:14 +02:00
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>
This commit is contained in:
parent
4dce0648f6
commit
cba92f9762
3 changed files with 123 additions and 0 deletions
|
|
@ -125,12 +125,20 @@ struct libinput_device_config_natural_scroll {
|
||||||
int (*get_default_enabled)(struct libinput_device *device);
|
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 {
|
||||||
struct libinput_device_config_tap *tap;
|
struct libinput_device_config_tap *tap;
|
||||||
struct libinput_device_config_calibration *calibration;
|
struct libinput_device_config_calibration *calibration;
|
||||||
struct libinput_device_config_send_events *sendevents;
|
struct libinput_device_config_send_events *sendevents;
|
||||||
struct libinput_device_config_accel *accel;
|
struct libinput_device_config_accel *accel;
|
||||||
struct libinput_device_config_natural_scroll *natural_scroll;
|
struct libinput_device_config_natural_scroll *natural_scroll;
|
||||||
|
struct libinput_device_config_left_handed *left_handed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libinput_device {
|
struct libinput_device {
|
||||||
|
|
|
||||||
|
|
@ -1464,3 +1464,40 @@ libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput
|
||||||
|
|
||||||
return device->config.natural_scroll->get_default_enabled(device);
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1929,6 +1929,84 @@ libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device
|
||||||
int
|
int
|
||||||
libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue