Only exposes two knobs - speed and precision which have historically been the only two knobs exposed anyway on most UIs. We could go for something fancier but really, I think this will be enough.
The only open question is whether speed will be enough for high-dpi devices. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- src/libinput-private.h | 12 ++++++++ src/libinput.c | 53 +++++++++++++++++++++++++++++++++ src/libinput.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) diff --git a/src/libinput-private.h b/src/libinput-private.h index 0d2a1b1..85113bd 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -93,10 +93,22 @@ struct libinput_device_config_rotation { void (*reset)(struct libinput_device *device); }; +struct libinput_device_config_accel { + int (*available)(struct libinput_device *device); + enum libinput_config_status (*set_speed)(struct libinput_device *device, + unsigned int speed); + enum libinput_config_status (*set_precision)(struct libinput_device *device, + unsigned int precision); + int (*get_speed)(struct libinput_device *device); + int (*get_precision)(struct libinput_device *device); + void (*reset)(struct libinput_device *device); +}; + struct libinput_device_config { struct libinput_device_config_tap *tap; struct libinput_device_config_scroll *scroll; struct libinput_device_config_rotation *rotation; + struct libinput_device_config_accel *accel; }; struct libinput_device { diff --git a/src/libinput.c b/src/libinput.c index 2572f5b..5a068f1 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1283,3 +1283,56 @@ libinput_device_config_rotation_reset(struct libinput_device *device) if (libinput_device_config_rotation_get_increment(device) != 0) device->config.rotation->reset(device); } + + +LIBINPUT_EXPORT int +libinput_device_config_accel_is_available(struct libinput_device *device) +{ + return device->config.accel ? + device->config.accel->available(device) : 0; +} + +LIBINPUT_EXPORT enum libinput_config_status +libinput_device_config_accel_set_speed(struct libinput_device *device, + unsigned int speed) +{ + if (!libinput_device_config_accel_is_available(device)) + return LIBINPUT_CONFIG_STATUS_UNSUPPORTED; + + return device->config.accel->set_speed(device, speed); +} + +LIBINPUT_EXPORT enum libinput_config_status +libinput_device_config_accel_set_precision(struct libinput_device *device, + unsigned int precision) +{ + if (!libinput_device_config_accel_is_available(device)) + return LIBINPUT_CONFIG_STATUS_UNSUPPORTED; + + return device->config.accel->set_precision(device, precision); +} + +LIBINPUT_EXPORT unsigned int +libinput_device_config_accel_get_speed(struct libinput_device *device) +{ + if (!libinput_device_config_accel_is_available(device)) + return 0; + + return device->config.accel->get_speed(device); +} + +LIBINPUT_EXPORT unsigned int +libinput_device_config_accel_get_precision(struct libinput_device *device) +{ + if (!libinput_device_config_accel_is_available(device)) + return 0; + + return device->config.accel->get_precision(device); +} + +LIBINPUT_EXPORT void +libinput_device_config_accel_reset(struct libinput_device *device) +{ + if (device->config.accel) + device->config.accel->reset(device); +} diff --git a/src/libinput.h b/src/libinput.h index 328d050..1b6207c 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -1577,6 +1577,86 @@ libinput_device_config_rotation_get(struct libinput_device *device); void libinput_device_config_rotation_reset(struct libinput_device *device); +/** + * @ingroup config + * + * Check if a device uses libinput-internal pointer-acceleration. + * + * @param device The device to configure + * + * @return 0 if the device is not accelerated, nonzero if it is accelerated + */ +int +libinput_device_config_accel_is_available(struct libinput_device *device); + +/** + * @ingroup config + * + * Set the speed of this pointer device, where 0% is the minimum pointer + * acceleration to be applied (none or slowed down, depending on the device) + * and 100% is the maximum amount of acceleration to be applied. + * + * @param device The device to configure + * @param speed The abstract speed identifier, ranged 0% to 100%. + * + * @return A config status code + */ +enum libinput_config_status +libinput_device_config_accel_set_speed(struct libinput_device *device, + unsigned int speed); + +/** + * @ingroup config + * + * Set the precision or sensibility of this pointer device. This affects the + * movement of the pointer when moving relatively slowly towards a target. + * The range is an abstract range, 0% is the minimum pointer precision and + * 100% is the maximum precision). + * + * @param device The device to configure + * @param precision The abstract precision identifier, range 0% to 100%. + * + * @return A config status code + */ +enum libinput_config_status +libinput_device_config_accel_set_precision(struct libinput_device *device, + unsigned int precision); + +/** + * @ingroup config + * + * Get the current speed setting for this pointer device. + * + * @param device The device to configure + * + * @return The current speed, range 0% to 100%. + */ +unsigned int +libinput_device_config_accel_get_speed(struct libinput_device *device); + +/** + * @ingroup config + * + * Get the current precision setting for this pointer device. + * + * @param device The device to configure + * + * @return The current precision, range 0% to 100%. + */ +unsigned int +libinput_device_config_accel_get_precision(struct libinput_device *device); + +/** + * @ingroup config + * + * Reset the acceleration to the device's default setting. If the device + * does not support acceleration, this function does nothing. + * + * @param device The device to configure + */ +void +libinput_device_config_accel_reset(struct libinput_device *device); + #ifdef __cplusplus } #endif -- 1.9.0 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel