Port evdev code to be used as a shared library
[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
28 struct libinput_device {
29         const struct libinput_device_interface *device_interface;
30         void *device_interface_data;
31
32         const struct libinput_keyboard_listener *keyboard_listener;
33         void *keyboard_listener_data;
34
35         const struct libinput_pointer_listener *pointer_listener;
36         void *pointer_listener_data;
37
38         const struct libinput_touch_listener *touch_listener;
39         void *touch_listener_data;
40 };
41
42 void
43 keyboard_notify_key(struct libinput_device *device,
44                     uint32_t time,
45                     uint32_t key,
46                     enum libinput_keyboard_key_state state);
47
48 void
49 pointer_notify_motion(struct libinput_device *device,
50                       uint32_t time,
51                       li_fixed_t dx,
52                       li_fixed_t dy);
53
54 void
55 pointer_notify_motion_absolute(struct libinput_device *device,
56                                uint32_t time,
57                                li_fixed_t x,
58                                li_fixed_t y);
59
60 void
61 pointer_notify_button(struct libinput_device *device,
62                       uint32_t time,
63                       int32_t button,
64                       enum libinput_pointer_button_state state);
65
66 void
67 pointer_notify_axis(struct libinput_device *device,
68                     uint32_t time,
69                     enum libinput_pointer_axis axis,
70                     li_fixed_t value);
71
72 void
73 touch_notify_touch(struct libinput_device *device,
74                    uint32_t time,
75                    int32_t slot,
76                    li_fixed_t x,
77                    li_fixed_t y,
78                    enum libinput_touch_type touch_type);
79
80 static inline li_fixed_t li_fixed_from_int(int i)
81 {
82         return i * 256;
83 }
84
85 static inline li_fixed_t
86 li_fixed_from_double(double d)
87 {
88         union {
89                 double d;
90                 int64_t i;
91         } u;
92
93         u.d = d + (3LL << (51 - 8));
94
95         return u.i;
96 }
97
98 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
99
100 #define LIBINPUT_EXPORT __attribute__ ((visibility("default")))
101
102 #endif /* LIBINPUT_PRIVATE_H */