}
static enum libinput_config_status
-tp_tap_config_set_enabled(struct libinput_device *device, int enabled)
+tp_tap_config_set_enabled(struct libinput_device *device,
+ enum libinput_config_tap_state enabled)
{
struct evdev_dispatch *dispatch;
struct tp_dispatch *tp;
dispatch = ((struct evdev_device *) device)->dispatch;
tp = container_of(dispatch, tp, base);
- tp->tap.enabled = enabled;
+ tp->tap.enabled = (enabled == LIBINPUT_CONFIG_TAP_ENABLED);
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
-static int
+static enum libinput_config_tap_state
tp_tap_config_is_enabled(struct libinput_device *device)
{
struct evdev_dispatch *dispatch;
dispatch = ((struct evdev_device *) device)->dispatch;
tp = container_of(dispatch, tp, base);
- return tp->tap.enabled;
+ return tp->tap.enabled ? LIBINPUT_CONFIG_TAP_ENABLED :
+ LIBINPUT_CONFIG_TAP_DISABLED;
}
-static int
+static enum libinput_config_tap_state
tp_tap_config_get_default(struct libinput_device *device)
{
/**
* usually know where to enable it, or at least you can search for
* it.
*/
- return false;
+ return LIBINPUT_CONFIG_TAP_DISABLED;
}
int
/**
* @ingroup config
+ */
+enum libinput_config_tap_state {
+ LIBINPUT_CONFIG_TAP_DISABLED, /**< Tapping is to be disabled, or is
+ currently disabled */
+ LIBINPUT_CONFIG_TAP_ENABLED, /**< Tapping is to be enabled, or is
+ currently enabled */
+};
+
+/**
+ * @ingroup config
*
* Check if the device supports tap-to-click. See
* libinput_device_config_tap_set_enabled() for more information.
* libinput_device_config_tap_get_finger_count().
*
* @param device The device to configure
- * @param enable Non-zero to enable, zero to disable
+ * @param enable @ref LIBINPUT_CONFIG_TAP_ENABLED to enable tapping or @ref
+ * LIBINPUT_CONFIG_TAP_DISABLED to disable tapping
*
* @return A config status code. Disabling tapping on a device that does not
* support tapping always succeeds.
*/
enum libinput_config_status
libinput_device_config_tap_set_enabled(struct libinput_device *device,
- int enable);
+ enum libinput_config_tap_state enable);
/**
* @ingroup config
*
* @param device The device to configure
*
- * @return 1 if enabled, 0 otherwise.
+ * @return @ref LIBINPUT_CONFIG_TAP_ENABLED if tapping is currently enabled,
+ * or @ref LIBINPUT_CONFIG_TAP_DISABLED is currently disabled
*
* @see libinput_device_config_tap_get_finger_count
* @see libinput_device_config_tap_set_enabled
* @see libinput_device_config_tap_get_default_enabled
*/
-int
+enum libinput_config_tap_state
libinput_device_config_tap_get_enabled(struct libinput_device *device);
/**
* Return the default setting for whether tapping is enabled on this device.
*
* @param device The device to configure
- * @return 1 if tapping is enabled by default, or 0 otherwise
+ * @return @ref LIBINPUT_CONFIG_TAP_ENABLED if tapping is enabled by default,
+ * or @ref LIBINPUT_CONFIG_TAP_DISABLED is disabled by default
*
* @see libinput_device_config_tap_get_finger_count
* @see libinput_device_config_tap_set_enabled
* @see libinput_device_config_tap_get_enabled
*/
-int
+enum libinput_config_tap_state
libinput_device_config_tap_get_default_enabled(struct libinput_device *device);
#ifdef __cplusplus
struct libinput *li = dev->libinput;
struct libinput_event *event;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(li);
struct libinput *li = dev->libinput;
struct libinput_event *event;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(li);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct libinput *li = dev->libinput;
struct libinput_event *event;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(dev->libinput);
struct libinput_event *event;
int i;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
for (i = 0; i < 3; i++) {
litest_drain_events(li);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(li);
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
- libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
+ libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED);
litest_drain_events(li);
struct litest_device *dev = litest_current_device();
ck_assert_int_ge(libinput_device_config_tap_get_finger_count(dev->libinput_device), 1);
- ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0);
+ ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device),
+ LIBINPUT_CONFIG_TAP_DISABLED);
}
END_TEST
struct litest_device *dev = litest_current_device();
ck_assert_int_eq(libinput_device_config_tap_get_finger_count(dev->libinput_device), 0);
- ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0);
- ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, 1),
+ ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device),
+ LIBINPUT_CONFIG_TAP_DISABLED);
+ ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device,
+ LIBINPUT_CONFIG_TAP_ENABLED),
LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
}
END_TEST
{
struct litest_device *dev = litest_current_device();
- ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device), 0);
+ ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device),
+ LIBINPUT_CONFIG_TAP_DISABLED);
+}
+END_TEST
+
+START_TEST(touchpad_tap_invalid)
+{
+ struct litest_device *dev = litest_current_device();
+
+ ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, 2),
+ LIBINPUT_CONFIG_STATUS_INVALID);
+ ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, -1),
+ LIBINPUT_CONFIG_STATUS_INVALID);
}
END_TEST
litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_click, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:tap", touchpad_tap_default, LITEST_TOUCHPAD, LITEST_ANY);
+ litest_add("touchpad:tap", touchpad_tap_invalid, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:tap", touchpad_tap_is_available, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:tap", touchpad_tap_is_not_available, LITEST_ANY, LITEST_TOUCHPAD);