mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 01:10:25 +01:00
Add a config interface for click methods
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@who-t.net>
This commit is contained in:
parent
aee7ba8360
commit
c8ec33e72a
4 changed files with 165 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1635,6 +1635,56 @@ libinput_device_config_left_handed_get_default(struct libinput_device *device)
|
|||
return device->config.left_handed->get_default(device);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
102
src/libinput.h
102
src/libinput.h
|
|
@ -2176,6 +2176,108 @@ libinput_device_config_left_handed_get(struct libinput_device *device);
|
|||
int
|
||||
libinput_device_config_left_handed_get_default(struct libinput_device *device);
|
||||
|
||||
/**
|
||||
* @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 clickfinger) 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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue