summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-04-07 09:44:46 -0400
committerMike Blumenkrantz <zmike@samsung.com>2014-04-07 09:44:46 -0400
commit5e4865eb74c9062bf8c39db8a0d5901011936c49 (patch)
tree05c0c16ce1646146371906e0703349e92221a418
init
-rw-r--r--li.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/li.c b/li.c
new file mode 100644
index 0000000..cf5ce2a
--- /dev/null
+++ b/li.c
@@ -0,0 +1,79 @@
1#include <Ecore.h>
2#include <libudev.h>
3#include <libinput.h>
4#include <fcntl.h>
5
6static struct libinput *li;
7
8static Eina_Bool
9fdh_func(void *d EINA_UNUSED, Ecore_Fd_Handler *fdh)
10{
11 struct libinput_event *event;
12
13 libinput_dispatch(li);
14 while ((event = libinput_get_event(li)))
15 {
16 switch (libinput_event_get_type(event))
17 {
18#define EVENT(X) \
19case X: \
20 fprintf(stderr, "EVENT: %s\n", #X); \
21 break
22 EVENT(LIBINPUT_EVENT_DEVICE_ADDED);
23 EVENT(LIBINPUT_EVENT_DEVICE_REMOVED);
24 EVENT(LIBINPUT_EVENT_KEYBOARD_KEY);
25 EVENT(LIBINPUT_EVENT_POINTER_MOTION);
26 EVENT(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
27 EVENT(LIBINPUT_EVENT_POINTER_BUTTON);
28 EVENT(LIBINPUT_EVENT_POINTER_AXIS);
29 EVENT(LIBINPUT_EVENT_TOUCH_DOWN);
30 EVENT(LIBINPUT_EVENT_TOUCH_UP);
31 EVENT(LIBINPUT_EVENT_TOUCH_MOTION);
32 EVENT(LIBINPUT_EVENT_TOUCH_CANCEL);
33 EVENT(LIBINPUT_EVENT_TOUCH_FRAME);
34 }
35 libinput_event_destroy(event);
36 libinput_dispatch(li);
37 }
38 return ECORE_CALLBACK_RENEW;
39}
40
41static int
42open_restricted(const char *path, int flags, void *userdata)
43{
44 Ecore_Fd_Handler *fdh;
45 int fd;
46
47 fd = open(path, flags | O_NONBLOCK);
48 if (fd < 0) return -1;
49 fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, fdh_func, NULL, NULL, NULL);
50 eina_hash_add(userdata, &fd, fdh);
51 return fd;
52}
53
54static void
55close_restricted(int fd, void *userdata)
56{
57 eina_hash_del_by_key(userdata, &fd);
58 close(fd);
59}
60
61const struct libinput_interface interface =
62{
63 .open_restricted = open_restricted,
64 .close_restricted = close_restricted,
65};
66
67int
68main(void)
69{
70 Eina_Hash *fds;
71 struct udev *udev;
72
73 ecore_init();
74 udev = udev_new();
75 fds = eina_hash_int32_new((Eina_Free_Cb)ecore_main_fd_handler_del);
76 li = libinput_udev_create_for_seat(&interface, fds, udev, "seat0");
77 ecore_main_loop_begin();
78 return 0;
79}