evdev: Use helper for separating buttons from keys
[platform/upstream/libinput.git] / src / libinput.c
index 44f4f23..90b6a13 100644 (file)
@@ -1052,7 +1052,6 @@ touch_notify_frame(struct libinput_device *device,
                          &touch_event->base);
 }
 
-
 static void
 libinput_post_event(struct libinput *libinput,
                    struct libinput_event *event)
@@ -1162,6 +1161,24 @@ libinput_device_get_sysname(struct libinput_device *device)
 }
 
 LIBINPUT_EXPORT const char *
+libinput_device_get_name(struct libinput_device *device)
+{
+       return evdev_device_get_name((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT unsigned int
+libinput_device_get_id_product(struct libinput_device *device)
+{
+       return evdev_device_get_id_product((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT unsigned int
+libinput_device_get_id_vendor(struct libinput_device *device)
+{
+       return evdev_device_get_id_vendor((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT const char *
 libinput_device_get_output_name(struct libinput_device *device)
 {
        return evdev_device_get_output((struct evdev_device *) device);
@@ -1237,3 +1254,62 @@ libinput_event_touch_get_base_event(struct libinput_event_touch *event)
 {
        return &event->base;
 }
+
+LIBINPUT_EXPORT const char *
+libinput_config_status_to_str(enum libinput_config_status status)
+{
+       const char *str = NULL;
+
+       switch(status) {
+       case LIBINPUT_CONFIG_STATUS_SUCCESS:
+               str = "Success";
+               break;
+       case LIBINPUT_CONFIG_STATUS_UNSUPPORTED:
+               str = "Unsupported configuration option";
+               break;
+       case LIBINPUT_CONFIG_STATUS_INVALID:
+               str = "Invalid argument range";
+               break;
+       }
+
+       return str;
+}
+
+LIBINPUT_EXPORT int
+libinput_device_config_tap_get_finger_count(struct libinput_device *device)
+{
+       return device->config.tap ? device->config.tap->count(device) : 0;
+}
+
+LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_tap_set_enabled(struct libinput_device *device,
+                                      enum libinput_config_tap_state enable)
+{
+       if (enable != LIBINPUT_CONFIG_TAP_ENABLED &&
+           enable != LIBINPUT_CONFIG_TAP_DISABLED)
+               return LIBINPUT_CONFIG_STATUS_INVALID;
+
+       if (enable &&
+           libinput_device_config_tap_get_finger_count(device) == 0)
+               return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+
+       return device->config.tap->set_enabled(device, enable);
+}
+
+LIBINPUT_EXPORT enum libinput_config_tap_state
+libinput_device_config_tap_get_enabled(struct libinput_device *device)
+{
+       if (libinput_device_config_tap_get_finger_count(device) == 0)
+               return LIBINPUT_CONFIG_TAP_DISABLED;
+
+       return device->config.tap->get_enabled(device);
+}
+
+LIBINPUT_EXPORT enum libinput_config_tap_state
+libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
+{
+       if (libinput_device_config_tap_get_finger_count(device) == 0)
+               return LIBINPUT_CONFIG_TAP_DISABLED;
+
+       return device->config.tap->get_default(device);
+}