Split up the touch event into the different touch types
[platform/upstream/libinput.git] / src / libinput-private.h
1 /*
2  * Copyright © 2013 Jonas Ådahl
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of the copyright holders not be used in
9  * advertising or publicity pertaining to distribution of the software
10  * without specific, written prior permission.  The copyright holders make
11  * no representations about the suitability of this software for any
12  * purpose.  It is provided "as is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22
23 #ifndef LIBINPUT_PRIVATE_H
24 #define LIBINPUT_PRIVATE_H
25
26 #include "libinput.h"
27 #include "libinput-util.h"
28
29 struct libinput_interface_backend {
30         int (*resume)(struct libinput *libinput);
31         void (*suspend)(struct libinput *libinput);
32         void (*destroy)(struct libinput *libinput);
33 };
34
35 struct libinput {
36         int epoll_fd;
37         struct list source_destroy_list;
38
39         struct list seat_list;
40
41         struct libinput_event **events;
42         size_t events_count;
43         size_t events_len;
44         size_t events_in;
45         size_t events_out;
46
47         const struct libinput_interface *interface;
48         const struct libinput_interface_backend *interface_backend;
49         void *user_data;
50 };
51
52 typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat);
53
54 struct libinput_seat {
55         struct libinput *libinput;
56         struct list link;
57         struct list devices_list;
58         void *user_data;
59         int refcount;
60         uint32_t slot_map;
61         char *physical_name;
62         char *logical_name;
63         libinput_seat_destroy_func destroy;
64 };
65
66 struct libinput_device {
67         struct libinput_seat *seat;
68         struct list link;
69         void *user_data;
70         int terminated;
71         int refcount;
72 };
73
74 typedef void (*libinput_source_dispatch_t)(void *data);
75
76 struct libinput_source;
77
78 #define log_debug(...) log_msg(LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
79 #define log_info(...) log_msg(LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
80 #define log_error(...) log_msg(LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
81
82 void
83 log_msg(enum libinput_log_priority priority, const char *format, ...);
84
85 int
86 libinput_init(struct libinput *libinput,
87               const struct libinput_interface *interface,
88               const struct libinput_interface_backend *interface_backend,
89               void *user_data);
90
91 struct libinput_source *
92 libinput_add_fd(struct libinput *libinput,
93                 int fd,
94                 libinput_source_dispatch_t dispatch,
95                 void *data);
96
97 void
98 libinput_remove_source(struct libinput *libinput,
99                        struct libinput_source *source);
100
101 int
102 open_restricted(struct libinput *libinput,
103                 const char *path, int flags);
104
105 void
106 close_restricted(struct libinput *libinput, int fd);
107
108 void
109 libinput_seat_init(struct libinput_seat *seat,
110                    struct libinput *libinput,
111                    const char *physical_name,
112                    const char *logical_name,
113                    libinput_seat_destroy_func destroy);
114
115 void
116 libinput_device_init(struct libinput_device *device,
117                      struct libinput_seat *seat);
118
119 void
120 notify_added_device(struct libinput_device *device);
121
122 void
123 notify_removed_device(struct libinput_device *device);
124
125 void
126 keyboard_notify_key(struct libinput_device *device,
127                     uint32_t time,
128                     uint32_t key,
129                     enum libinput_keyboard_key_state state);
130
131 void
132 pointer_notify_motion(struct libinput_device *device,
133                       uint32_t time,
134                       li_fixed_t dx,
135                       li_fixed_t dy);
136
137 void
138 pointer_notify_motion_absolute(struct libinput_device *device,
139                                uint32_t time,
140                                li_fixed_t x,
141                                li_fixed_t y);
142
143 void
144 pointer_notify_button(struct libinput_device *device,
145                       uint32_t time,
146                       int32_t button,
147                       enum libinput_pointer_button_state state);
148
149 void
150 pointer_notify_axis(struct libinput_device *device,
151                     uint32_t time,
152                     enum libinput_pointer_axis axis,
153                     li_fixed_t value);
154
155 void
156 touch_notify_touch_down(struct libinput_device *device,
157                         uint32_t time,
158                         int32_t slot,
159                         int32_t seat_slot,
160                         li_fixed_t x,
161                         li_fixed_t y);
162
163 void
164 touch_notify_touch_motion(struct libinput_device *device,
165                           uint32_t time,
166                           int32_t slot,
167                           int32_t seat_slot,
168                           li_fixed_t x,
169                           li_fixed_t y);
170
171 void
172 touch_notify_touch_up(struct libinput_device *device,
173                       uint32_t time,
174                       int32_t slot,
175                       int32_t seat_slot);
176
177 void
178 touch_notify_frame(struct libinput_device *device,
179                    uint32_t time);
180 #endif /* LIBINPUT_PRIVATE_H */