evdev: Move generic scroll code from evdev-mt-touchpad.c to evdev.c
[platform/upstream/libinput.git] / src / evdev.h
index 0ab9572..311dddc 100644 (file)
 
 #include "config.h"
 
-#include <linux/input.h>
+#include "linux/input.h"
 #include <libevdev/libevdev.h>
 
 #include "libinput-private.h"
 
-#define MAX_SLOTS 16
-
 enum evdev_event_type {
        EVDEV_NONE,
        EVDEV_ABSOLUTE_TOUCH_DOWN,
@@ -50,6 +48,16 @@ enum evdev_device_seat_capability {
        EVDEV_DEVICE_TOUCH = (1 << 2)
 };
 
+enum evdev_device_tags {
+       EVDEV_TAG_EXTERNAL_MOUSE = (1 << 0),
+       EVDEV_TAG_INTERNAL_TOUCHPAD = (1 << 1),
+};
+
+struct mt_slot {
+       int32_t seat_slot;
+       int32_t x, y;
+};
+
 struct evdev_device {
        struct libinput_device base;
 
@@ -60,35 +68,54 @@ struct evdev_device {
        char *output_name;
        char *devnode;
        char *sysname;
+       char *syspath;
        const char *devname;
        int fd;
        struct {
-               int min_x, max_x, min_y, max_y;
-               int32_t x, y;
+               const struct input_absinfo *absinfo_x, *absinfo_y;
+               int fake_resolution;
 
+               int32_t x, y;
                int32_t seat_slot;
 
                int apply_calibration;
-               float calibration[6];
+               struct matrix calibration;
+               struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */
+               struct matrix usermatrix; /* as supplied by the caller */
        } abs;
 
        struct {
                int slot;
-               struct {
-                       int32_t seat_slot;
-                       int32_t x, y;
-               } slots[MAX_SLOTS];
+               struct mt_slot *slots;
+               size_t slots_len;
        } mt;
        struct mtdev *mtdev;
 
        struct {
-               li_fixed_t dx, dy;
+               int dx, dy;
        } rel;
 
+       struct {
+               double threshold;
+               uint32_t direction;
+       } scroll;
+
        enum evdev_event_type pending_event;
        enum evdev_device_seat_capability seat_caps;
+       enum evdev_device_tags tags;
 
        int is_mt;
+
+       struct {
+               struct motion_filter *filter;
+       } pointer;
+
+       /* Bitmask of pressed keys used to ignore initial release events from
+        * the kernel. */
+       unsigned long hw_key_mask[NLONGS(KEY_CNT)];
+       /* Key counter used for multiplexing button events internally in
+        * libinput. */
+       uint8_t key_count[KEY_CNT];
 };
 
 #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
@@ -100,20 +127,39 @@ struct evdev_dispatch_interface {
        void (*process)(struct evdev_dispatch *dispatch,
                        struct evdev_device *device,
                        struct input_event *event,
-                       uint32_t time);
+                       uint64_t time);
 
        /* Destroy an event dispatch handler and free all its resources. */
        void (*destroy)(struct evdev_dispatch *dispatch);
+
+       /* A new device was added */
+       void (*device_added)(struct evdev_device *device,
+                            struct evdev_device *added_device);
+
+       /* A device was removed */
+       void (*device_removed)(struct evdev_device *device,
+                              struct evdev_device *removed_device);
+
+       /* Tag device with one of EVDEV_TAG */
+       void (*tag_device)(struct evdev_device *device,
+                          struct udev_device *udev_device);
 };
 
 struct evdev_dispatch {
        struct evdev_dispatch_interface *interface;
+       struct libinput_device_config_calibration calibration;
+
+       struct {
+               struct libinput_device_config_send_events config;
+               enum libinput_config_send_events_mode current_mode;
+       } sendevents;
 };
 
 struct evdev_device *
 evdev_device_create(struct libinput_seat *seat,
                    const char *devnode,
-                   const char *sysname);
+                   const char *sysname,
+                   const char *syspath);
 
 struct evdev_dispatch *
 evdev_touchpad_create(struct evdev_device *device);
@@ -136,22 +182,67 @@ evdev_device_get_output(struct evdev_device *device);
 const char *
 evdev_device_get_sysname(struct evdev_device *device);
 
+const char *
+evdev_device_get_name(struct evdev_device *device);
+
+unsigned int
+evdev_device_get_id_product(struct evdev_device *device);
+
+unsigned int
+evdev_device_get_id_vendor(struct evdev_device *device);
+
+void
+evdev_device_set_default_calibration(struct evdev_device *device,
+                                    const float calibration[6]);
 void
-evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
+evdev_device_calibrate(struct evdev_device *device,
+                      const float calibration[6]);
 
 int
 evdev_device_has_capability(struct evdev_device *device,
                            enum libinput_device_capability capability);
 
-li_fixed_t
+int
+evdev_device_get_size(struct evdev_device *device,
+                     double *w,
+                     double *h);
+
+double
 evdev_device_transform_x(struct evdev_device *device,
-                        li_fixed_t x,
+                        double x,
                         uint32_t width);
 
-li_fixed_t
+double
 evdev_device_transform_y(struct evdev_device *device,
-                        li_fixed_t y,
+                        double y,
                         uint32_t height);
+int
+evdev_device_suspend(struct evdev_device *device);
+
+int
+evdev_device_resume(struct evdev_device *device);
+
+void
+evdev_keyboard_notify_key(struct evdev_device *device,
+                         uint32_t time,
+                         int key,
+                         enum libinput_key_state state);
+
+void
+evdev_pointer_notify_button(struct evdev_device *device,
+                           uint32_t time,
+                           int button,
+                           enum libinput_button_state state);
+
+void
+evdev_post_scroll(struct evdev_device *device,
+                 uint64_t time,
+                 double dx,
+                 double dy);
+
+
+void
+evdev_stop_scroll(struct evdev_device *device, uint64_t time);
 
 void
 evdev_device_remove(struct evdev_device *device);
@@ -159,4 +250,11 @@ evdev_device_remove(struct evdev_device *device);
 void
 evdev_device_destroy(struct evdev_device *device);
 
+static inline double
+evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
+{
+       double value = v - absinfo->minimum;
+       return value/absinfo->resolution;
+}
+
 #endif /* EVDEV_H */