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