summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-04-01 13:04:25 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-04-13 14:16:17 -0400
commitf832d2019cc96d750a17f9df3aec3feff78dc5a3 (patch)
treeb04ab779de26adff0529f11f43354f2607f2f6ee
parentb5422700c05a102d418faa60f93287b7abcf44db (diff)
elput: Add API function to initialize and shutdown input devices
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r--src/Makefile_Elput.am1
-rw-r--r--src/lib/elput/Elput.h31
-rw-r--r--src/lib/elput/elput_input.c87
-rw-r--r--src/lib/elput/elput_private.h13
4 files changed, 131 insertions, 1 deletions
diff --git a/src/Makefile_Elput.am b/src/Makefile_Elput.am
index 3e1ed58861..c79763e298 100644
--- a/src/Makefile_Elput.am
+++ b/src/Makefile_Elput.am
@@ -9,6 +9,7 @@ dist_installed_elputmainheaders_DATA = \
9 lib/elput/Elput.h 9 lib/elput/Elput.h
10 10
11lib_elput_libelput_la_SOURCES = \ 11lib_elput_libelput_la_SOURCES = \
12lib/elput/elput_input.c \
12lib/elput/elput_logind.c \ 13lib/elput/elput_logind.c \
13lib/elput/elput_manager.c \ 14lib/elput/elput_manager.c \
14lib/elput/elput.c \ 15lib/elput/elput.c \
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
index 44a861ce29..234597ff33 100644
--- a/src/lib/elput/Elput.h
+++ b/src/lib/elput/Elput.h
@@ -39,6 +39,7 @@ typedef struct _Elput_Manager Elput_Manager;
39 * 39 *
40 * @li @ref Elput_Init_Group 40 * @li @ref Elput_Init_Group
41 * @li @ref Elput_Manager_Group 41 * @li @ref Elput_Manager_Group
42 * @li @ref Elput_Input_Group
42 * 43 *
43 */ 44 */
44 45
@@ -75,7 +76,6 @@ EAPI int elput_shutdown(void);
75 * 76 *
76 * Functions that deal with connecting, disconnecting, opening, closing 77 * Functions that deal with connecting, disconnecting, opening, closing
77 * of input devices. 78 * of input devices.
78 *
79 */ 79 */
80 80
81/** 81/**
@@ -127,6 +127,35 @@ EAPI int elput_manager_open(Elput_Manager *manager, const char *path, int flags)
127 */ 127 */
128EAPI void elput_manager_close(Elput_Manager *manager, int fd); 128EAPI void elput_manager_close(Elput_Manager *manager, int fd);
129 129
130/**
131 * @defgroup Elput_Input_Group Elput input functions
132 *
133 * Functions that deal with setup of inputs
134 */
135
136/**
137 * Initialize input
138 *
139 * @param manager
140 * @param seat
141 *
142 * @return EINA_TRUE on success, EINA_FALSE on failure
143 *
144 * @ingroup Elput_Input_Group
145 * @since 1.18
146 */
147EAPI Eina_Bool elput_input_init(Elput_Manager *manager, const char *seat);
148
149/**
150 * Shutdown input
151 *
152 * @param manager
153 *
154 * @ingroup Elput_Input_Group
155 * @since 1.18
156 */
157EAPI void elput_input_shutdown(Elput_Manager *manager);
158
130# endif 159# endif
131 160
132# undef EAPI 161# undef EAPI
diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c
new file mode 100644
index 0000000000..a2a4ccbd5e
--- /dev/null
+++ b/src/lib/elput/elput_input.c
@@ -0,0 +1,87 @@
1#include "elput_private.h"
2
3static int
4_cb_open_restricted(const char *path, int flags, void *data)
5{
6 Elput_Manager *em;
7
8 em = data;
9 return elput_manager_open(em, path, flags);
10}
11
12static void
13_cb_close_restricted(int fd, void *data)
14{
15 Elput_Manager *em;
16
17 em = data;
18 elput_manager_close(em, fd);
19}
20
21const struct libinput_interface _input_interface =
22{
23 _cb_open_restricted,
24 _cb_close_restricted,
25};
26
27static void
28_process_event(struct libinput_event *event)
29{
30 /* TODO */
31}
32
33static void
34_process_events(Elput_Input *ei)
35{
36 struct libinput_event *event;
37
38 while ((event = libinput_get_event(ei->lib)))
39 {
40 _process_event(event);
41 libinput_event_destroy(event);
42 }
43}
44
45EAPI Eina_Bool
46elput_input_init(Elput_Manager *manager, const char *seat)
47{
48 EINA_SAFETY_ON_NULL_RETURN_VAL(manager, EINA_FALSE);
49
50 memset(&manager->input, 0, sizeof(Elput_Input));
51
52 manager->input.lib =
53 libinput_udev_create_context(&_input_interface, manager, eeze_udev_get());
54 if (!manager->input.lib)
55 {
56 ERR("libinput could not create udev context");
57 goto udev_err;
58 }
59
60 if (libinput_udev_assign_seat(manager->input.lib, seat) != 0)
61 {
62 ERR("libinput could not assign udev seat");
63 goto seat_err;
64 }
65
66 _process_events(&manager->input);
67
68 /* TODO */
69
70 return EINA_TRUE;
71
72seat_err:
73 libinput_unref(manager->input.lib);
74udev_err:
75 return EINA_FALSE;
76}
77
78EAPI void
79elput_input_shutdown(Elput_Manager *manager)
80{
81 EINA_SAFETY_ON_NULL_RETURN(manager);
82 EINA_SAFETY_ON_NULL_RETURN(&manager->input);
83
84 /* TODO */
85
86 libinput_unref(manager->input.lib);
87}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index c500a559c1..6d88943921 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -64,6 +64,17 @@ typedef struct _Elput_Interface
64 void (*close)(Elput_Manager *manager, int fd); 64 void (*close)(Elput_Manager *manager, int fd);
65} Elput_Interface; 65} Elput_Interface;
66 66
67typedef struct _Elput_Input
68{
69 struct libinput *lib;
70
71 Ecore_Fd_Handler *hdlr;
72
73 Eina_List *seats;
74
75 Eina_Bool suspended : 1;
76} Elput_Input;
77
67struct _Elput_Manager 78struct _Elput_Manager
68{ 79{
69 Elput_Interface *interface; 80 Elput_Interface *interface;
@@ -80,6 +91,8 @@ struct _Elput_Manager
80 Eldbus_Connection *conn; 91 Eldbus_Connection *conn;
81 } dbus; 92 } dbus;
82 93
94 Elput_Input input;
95
83 Eina_Bool sync : 1; 96 Eina_Bool sync : 1;
84}; 97};
85 98