Add seat wide slot to touch events
[platform/upstream/libinput.git] / src / evdev.h
1 /*
2  * Copyright © 2011, 2012 Intel Corporation
3  * Copyright © 2013 Jonas Ådahl
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of the copyright holders not be used in
10  * advertising or publicity pertaining to distribution of the software
11  * without specific, written prior permission.  The copyright holders make
12  * no representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied warranty.
14  *
15  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  */
23
24 #ifndef EVDEV_H
25 #define EVDEV_H
26
27 #include "config.h"
28
29 #include <linux/input.h>
30 #include <libevdev/libevdev.h>
31
32 #include "libinput-private.h"
33
34 #define MAX_SLOTS 16
35
36 enum evdev_event_type {
37         EVDEV_NONE,
38         EVDEV_ABSOLUTE_TOUCH_DOWN,
39         EVDEV_ABSOLUTE_MOTION,
40         EVDEV_ABSOLUTE_TOUCH_UP,
41         EVDEV_ABSOLUTE_MT_DOWN,
42         EVDEV_ABSOLUTE_MT_MOTION,
43         EVDEV_ABSOLUTE_MT_UP,
44         EVDEV_RELATIVE_MOTION,
45 };
46
47 enum evdev_device_seat_capability {
48         EVDEV_DEVICE_POINTER = (1 << 0),
49         EVDEV_DEVICE_KEYBOARD = (1 << 1),
50         EVDEV_DEVICE_TOUCH = (1 << 2)
51 };
52
53 struct evdev_device {
54         struct libinput_device base;
55
56         struct libinput_source *source;
57
58         struct evdev_dispatch *dispatch;
59         struct libevdev *evdev;
60         char *output_name;
61         char *devnode;
62         char *sysname;
63         const char *devname;
64         int fd;
65         struct {
66                 int min_x, max_x, min_y, max_y;
67                 int32_t x, y;
68
69                 int32_t seat_slot;
70
71                 int apply_calibration;
72                 float calibration[6];
73         } abs;
74
75         struct {
76                 int slot;
77                 struct {
78                         int32_t seat_slot;
79                         int32_t x, y;
80                 } slots[MAX_SLOTS];
81         } mt;
82         struct mtdev *mtdev;
83
84         struct {
85                 li_fixed_t dx, dy;
86         } rel;
87
88         enum evdev_event_type pending_event;
89         enum evdev_device_seat_capability seat_caps;
90
91         int is_mt;
92 };
93
94 #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
95
96 struct evdev_dispatch;
97
98 struct evdev_dispatch_interface {
99         /* Process an evdev input event. */
100         void (*process)(struct evdev_dispatch *dispatch,
101                         struct evdev_device *device,
102                         struct input_event *event,
103                         uint32_t time);
104
105         /* Destroy an event dispatch handler and free all its resources. */
106         void (*destroy)(struct evdev_dispatch *dispatch);
107 };
108
109 struct evdev_dispatch {
110         struct evdev_dispatch_interface *interface;
111 };
112
113 struct evdev_device *
114 evdev_device_create(struct libinput_seat *seat,
115                     const char *devnode,
116                     const char *sysname);
117
118 struct evdev_dispatch *
119 evdev_touchpad_create(struct evdev_device *device);
120
121 void
122 evdev_device_proces_event(struct libinput_event *event);
123
124 void
125 evdev_device_led_update(struct evdev_device *device, enum libinput_led leds);
126
127 int
128 evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size);
129
130 const char *
131 evdev_device_get_output(struct evdev_device *device);
132
133 const char *
134 evdev_device_get_sysname(struct evdev_device *device);
135
136 void
137 evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
138
139 int
140 evdev_device_has_capability(struct evdev_device *device,
141                             enum libinput_device_capability capability);
142
143 li_fixed_t
144 evdev_device_transform_x(struct evdev_device *device,
145                          li_fixed_t x,
146                          uint32_t width);
147
148 li_fixed_t
149 evdev_device_transform_y(struct evdev_device *device,
150                          li_fixed_t y,
151                          uint32_t height);
152
153 void
154 evdev_device_remove(struct evdev_device *device);
155
156 void
157 evdev_device_destroy(struct evdev_device *device);
158
159 #endif /* EVDEV_H */