e_devicemgr: make an internal header
[platform/upstream/enlightenment.git] / src / bin / e_devicemgr_private.h
1 #ifdef HAVE_CYNARA
2 #include <cynara-session.h>
3 #include <cynara-client.h>
4 #include <cynara-creds-socket.h>
5 #include <sys/smack.h>
6 #endif
7 #include <tizen-extension-server-protocol.h>
8 #include <linux/uinput.h>
9
10 #ifdef TRACE_INPUT_BEGIN
11 #undef TRACE_INPUT_BEGIN
12 #endif
13 #ifdef TRACE_INPUT_END
14 #undef TRACE_INPUT_END
15 #endif
16
17 #ifdef ENABLE_TTRACE
18 #include <ttrace.h>
19
20 #define TRACE_INPUT_BEGIN(NAME) traceBegin(TTRACE_TAG_INPUT, "INPUT:DEVMGR:"#NAME)
21 #define TRACE_INPUT_END() traceEnd(TTRACE_TAG_INPUT)
22 #else
23 #define TRACE_INPUT_BEGIN(NAME)
24 #define TRACE_INPUT_END()
25 #endif
26
27 #define DMERR(msg, ARG...) ERR("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
28 #define DMWRN(msg, ARG...) WRN("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
29 #define DMINF(msg, ARG...) INF("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
30 #define DMDBG(msg, ARG...) DBG("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
31
32 #ifdef HAVE_CYNARA
33 #include <cynara-session.h>
34 #include <cynara-client.h>
35 #include <cynara-creds-socket.h>
36 #endif
37
38 #define INPUT_GENERATOR_DEVICE "Input Generator"
39 #define DETENT_DEVICE_NAME "tizen_detent"
40 #define INPUTGEN_MAX_BTN 16
41
42 typedef struct _E_Devicemgr_Input_Device_Mgr_Data E_Devicemgr_Input_Device_Mgr_Data;
43 typedef struct _E_Devicemgr_Input_Device_User_Data E_Devicemgr_Input_Device_User_Data;
44 typedef struct _E_Devicemgr_Coords E_Devicemgr_Coords;
45 typedef struct _E_Devicemgr_Inputgen_Touch_Axis E_Devicemgr_Inputgen_Touch_Axis;
46 typedef struct _E_Devicemgr_Inputgen_Client_Data E_Devicemgr_Inputgen_Client_Data;
47 typedef struct _E_Devicemgr_Inputgen_Client_Global_Data E_Devicemgr_Inputgen_Client_Global_Data;
48 typedef struct _E_Devicemgr_Inputgen_Device_Data E_Devicemgr_Inputgen_Device_Data;
49 typedef struct _E_Devicemgr_Inputgen_Resource_Data E_Devicemgr_Inputgen_Resource_Data;
50
51 struct _E_Devicemgr_Input_Device_Mgr_Data
52 {
53     struct wl_resource *resource;
54     Eina_Bool is_first_resource : 1;
55     Eina_List *user_data_list;
56 };
57
58 struct _E_Devicemgr_Input_Device_User_Data
59 {
60    E_Devicemgr_Input_Device *dev;
61    struct wl_resource *dev_res;
62    struct wl_resource *dev_mgr_res;
63    struct wl_resource *seat_res;
64    E_Devicemgr_Input_Device_Mgr_Data *mgr_data;
65 };
66
67 struct _E_Devicemgr_Coords
68 {
69    int x, y;
70 };
71
72 struct _E_Devicemgr_Inputgen_Client_Data
73 {
74    struct wl_client *client;
75    int ref;
76 };
77
78 struct _E_Devicemgr_Inputgen_Client_Global_Data
79 {
80    struct wl_client *client;
81    unsigned int clas;
82 };
83
84 struct _E_Devicemgr_Inputgen_Touch_Axis
85 {
86    double radius_x;
87    double radius_y;
88    double pressure;
89    double angle;
90    double palm;
91 };
92
93 struct _E_Devicemgr_Inputgen_Device_Data
94 {
95    int uinp_fd;
96    char *identifier;
97    char name[UINPUT_MAX_NAME_SIZE];
98    Ecore_Device_Class clas;
99    struct
100      {
101         unsigned int pressed;
102         E_Devicemgr_Coords *coords;
103         E_Devicemgr_Inputgen_Touch_Axis *axis;
104         E_Devicemgr_Inputgen_Touch_Axis axis_tmp;
105      } touch;
106    struct
107      {
108         unsigned int pressed;
109         E_Devicemgr_Coords coords;
110      } mouse;
111    struct
112      {
113         Eina_List *pressed;
114      } key;
115
116    Eina_List *clients;
117 };
118
119 struct _E_Devicemgr_Inputgen_Resource_Data
120 {
121    struct wl_resource *resource;
122    char name[UINPUT_MAX_NAME_SIZE];
123    Ecore_Timer *sync_timer;
124 };
125
126 struct _E_Devicemgr_Conf_Edd
127 {
128    struct
129    {
130       Eina_Bool button_remap_enable;          // enable feature of remap mouse right button to back key
131       Eina_Bool virtual_key_device_enable;    // create a virtual keyboard device
132       Eina_Bool virtual_mouse_device_enable;  // create a virtual mouse device
133       int back_keycode;                       // keycode of back key
134    } input;
135 };
136
137 struct _E_Devicemgr_Config_Data
138 {
139    E_Config_DD *conf_edd;
140    E_Devicemgr_Conf_Edd *conf;
141 };
142
143 struct _E_Devicemgr_Wl_Data
144 {
145    struct wl_global *global;
146    Eina_List *mgr_data_list;
147
148 #ifdef HAVE_CYNARA
149    cynara *p_cynara;
150    Eina_Bool cynara_initialized;
151 #endif
152 };
153
154 void e_devicemgr_conf_init(E_Devicemgr_Config_Data *dconfig);
155 void e_devicemgr_conf_fini(E_Devicemgr_Config_Data *dconfig);
156
157 Eina_Bool e_devicemgr_wl_init(void);
158 void e_devicemgr_wl_shutdown(void);
159 void e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev);
160 void e_devicemgr_wl_device_del(E_Devicemgr_Input_Device *dev);
161 void e_devicemgr_wl_device_update(E_Devicemgr_Input_Device *dev);
162
163 void e_devicemgr_wl_block_send_expired(struct wl_resource *resource);
164 int e_devicemgr_block_add(struct wl_client *client, struct wl_resource *resource, uint32_t clas, uint32_t duration);
165 int e_devicemgr_block_remove(struct wl_client *client);
166
167 Eina_Bool e_devicemgr_block_add_internal(uint32_t clas, uint32_t duration, E_Devicemgr_Block_Expire_Cb cb_func, void *cb_data);
168 Eina_Bool e_devicemgr_block_remove_internal(E_Devicemgr_Block_Expire_Cb cb_func, void *cb_data);
169
170 int e_devicemgr_inputgen_add(struct wl_client *client, struct wl_resource *resource, uint32_t clas, const char *name);
171 void e_devicemgr_inputgen_add_with_sync(struct wl_client *client, struct wl_resource *resource, uint32_t clas, const char *name);
172 void e_devicemgr_inputgen_remove(struct wl_client *client, struct wl_resource *resource, uint32_t clas);
173 int e_devicemgr_inputgen_generate_key(struct wl_client *client, struct wl_resource *resource, const char *keyname, Eina_Bool pressed);
174 int e_devicemgr_inputgen_generate_pointer(struct wl_client *client, struct wl_resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t button);
175 int e_devicemgr_inputgen_generate_touch(struct wl_client *client, struct wl_resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t finger);
176 void e_devicemgr_inputgen_get_device_info(E_Devicemgr_Input_Device *dev);
177 int e_devicemgr_inputgen_generate_wheel(struct wl_client *client, struct wl_resource *resource, uint32_t type, int32_t value);
178 int e_devicemgr_inputgen_touch_axis_store(struct wl_client *client, struct wl_resource *resource, uint32_t type, double value);
179
180 int e_devicemgr_create_virtual_device(Ecore_Device_Class clas, const char *name);
181 void e_devicemgr_destroy_virtual_device(int uinp_fd);
182
183 Eina_Bool e_devicemgr_strcmp(const char *dst, const char *src);
184 int e_devicemgr_input_pointer_warp(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, wl_fixed_t x, wl_fixed_t y);
185 void e_devicemgr_wl_detent_send_event(int detent);
186 Eina_Bool e_devicemgr_input_init(void);
187 void e_devicemgr_input_shutdown(void);
188
189 void e_devicemgr_wl_touch_max_count_send(int slot, struct wl_resource *res, struct wl_resource *seat_res);
190 void e_devicemgr_wl_generator_with_sync_send_event(struct wl_resource *resource, int error);
191 void e_devicemgr_inputgen_device_ready_send(E_Devicemgr_Input_Device *dev);
192
193 int e_devicemgr_keyboard_ungrab(struct wl_client *client, struct wl_resource *surface);
194 int e_devicemgr_keyboard_grab(struct wl_client *client, struct wl_resource *surface, uint32_t subclas);
195