mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 13:08:04 +02:00
Always check for INVALID configs first
Always check for invalid input first, then check if the input is supported by the actual device. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
06720852fc
commit
1fa07bbafb
1 changed files with 9 additions and 9 deletions
|
|
@ -1462,12 +1462,12 @@ LIBINPUT_EXPORT enum libinput_config_status
|
||||||
libinput_device_config_accel_set_speed(struct libinput_device *device,
|
libinput_device_config_accel_set_speed(struct libinput_device *device,
|
||||||
double speed)
|
double speed)
|
||||||
{
|
{
|
||||||
if (!libinput_device_config_accel_is_available(device))
|
|
||||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
||||||
|
|
||||||
if (speed < -1.0 || speed > 1.0)
|
if (speed < -1.0 || speed > 1.0)
|
||||||
return LIBINPUT_CONFIG_STATUS_INVALID;
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
||||||
|
|
||||||
|
if (!libinput_device_config_accel_is_available(device))
|
||||||
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||||
|
|
||||||
return device->config.accel->set_speed(device, speed);
|
return device->config.accel->set_speed(device, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1576,9 +1576,6 @@ LIBINPUT_EXPORT enum libinput_config_status
|
||||||
libinput_device_config_scroll_set_method(struct libinput_device *device,
|
libinput_device_config_scroll_set_method(struct libinput_device *device,
|
||||||
enum libinput_config_scroll_method method)
|
enum libinput_config_scroll_method method)
|
||||||
{
|
{
|
||||||
if ((libinput_device_config_scroll_get_methods(device) & method) != method)
|
|
||||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
||||||
|
|
||||||
/* Check method is a single valid method */
|
/* Check method is a single valid method */
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
|
case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
|
||||||
|
|
@ -1590,6 +1587,9 @@ libinput_device_config_scroll_set_method(struct libinput_device *device,
|
||||||
return LIBINPUT_CONFIG_STATUS_INVALID;
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((libinput_device_config_scroll_get_methods(device) & method) != method)
|
||||||
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||||
|
|
||||||
if (device->config.scroll_method)
|
if (device->config.scroll_method)
|
||||||
return device->config.scroll_method->set_method(device, method);
|
return device->config.scroll_method->set_method(device, method);
|
||||||
else /* method must be _NO_SCROLL to get here */
|
else /* method must be _NO_SCROLL to get here */
|
||||||
|
|
@ -1618,13 +1618,13 @@ LIBINPUT_EXPORT enum libinput_config_status
|
||||||
libinput_device_config_scroll_set_button(struct libinput_device *device,
|
libinput_device_config_scroll_set_button(struct libinput_device *device,
|
||||||
uint32_t button)
|
uint32_t button)
|
||||||
{
|
{
|
||||||
|
if (button && !libinput_device_has_button(device, button))
|
||||||
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
||||||
|
|
||||||
if ((libinput_device_config_scroll_get_methods(device) &
|
if ((libinput_device_config_scroll_get_methods(device) &
|
||||||
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0)
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0)
|
||||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||||
|
|
||||||
if (button && !libinput_device_has_button(device, button))
|
|
||||||
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
||||||
|
|
||||||
return device->config.scroll_method->set_button(device, button);
|
return device->config.scroll_method->set_button(device, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue