[FEATURE] Osp: total remove
[platform/core/system/swap-probe.git] / probe_event / keytouch.c
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Jaewon Lim <jaewon81.lim@samsung.com>
9  * Woojin Jung <woojin2.jung@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  * Anastasia Lyupa <a.lyupa@samsung.com>
12  *
13  * This library is free software; you can redistribute it and/or modify it under
14  * the terms of the GNU Lesser General Public License as published by the
15  * Free Software Foundation; either version 2.1 of the License, or (at your option)
16  * any later version.
17  *
18  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21  * License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this library; if not, write to the Free Software Foundation, Inc., 51
25  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  *
27  * Contributors:
28  * - S-Core Co., Ltd
29  * - Samsung RnD Institute Russia
30  *
31  */
32
33 //#include <stdio.h>
34 //#include <stdlib.h>
35 #include <string.h>
36 #include <stdbool.h>
37
38 //#include <fcntl.h>
39 //#include <dlfcn.h>
40 //#include <unistd.h>
41 //#include <errno.h>
42 #include <Eina.h>
43 #include <Ecore_Input.h>
44 #include <Evas.h>
45 //#include <linux/input.h>
46
47 #include "daprobe.h"
48 #include "dahelper.h"
49 #include "probeinfo.h"
50 //#include "dautil.h"
51 #include "da_event.h"
52
53 #include "binproto.h"
54
55 bool touch_pressed = false;
56
57 #define PACK_HW_EVENT(API_ID, _EVENTTYPE, _DETAILTYPE, _X, _Y, _KEYCODE, _EXTRA, \
58         _ARGDATA, _ARGTYPE, _ARGEVENT)                                                                                          \
59         do {                                                                                                                                            \
60                 setProbePoint(&probeInfo);                                                                                              \
61                 PREPARE_LOCAL_BUF();                                                                                                    \
62                 PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT, API_ID, "pdp",                                     \
63                                   voidp_to_uint64(_ARGDATA), _ARGTYPE,  \
64                                   voidp_to_uint64(_ARGEVENT));          \
65                 PACK_COMMON_END('c', 0, 0, 0);                                                                                          \
66                 PACK_UIEVENT(_EVENTTYPE, _DETAILTYPE, _X, _Y, _KEYCODE, _EXTRA);                \
67                 FLUSH_LOCAL_BUF();                                                                                                              \
68         } while (0)
69
70 Eina_Bool ecore_event_evas_key_down(void *data, int type, void *event)
71 {
72         static Eina_Bool (*ecore_event_evas_key_downp)(void *data, int type, void *event);
73         probeInfo_t     probeInfo;
74
75         GET_REAL_FUNC(ecore_event_evas_key_down, LIBECORE_INPUT_EVAS);
76
77         if(isOptionEnabled(OPT_EVENT))
78         {
79                 probeBlockStart();
80                 if(event != NULL)
81                 {
82                         Ecore_Event_Key* pEv = (Ecore_Event_Key*)event;
83                         if(strcasestr(pEv->keyname, "volume") == NULL)
84                         {
85                                 PACK_HW_EVENT(API_ID_ecore_event_evas_key_down,
86                                               _EVENT_KEY, _KEY_PRESSED, 0, 0, pEv->keyname, 0, \
87                                               data, type, event);
88                         }
89                 }
90                 probeBlockEnd();
91         }
92
93         return ecore_event_evas_key_downp(data, type, event);
94 }
95
96 Eina_Bool ecore_event_evas_key_up(void *data, int type, void *event)
97 {
98         static Eina_Bool (*ecore_event_evas_key_upp)(void *data, int type, void *event);
99         probeInfo_t     probeInfo;
100
101         GET_REAL_FUNC(ecore_event_evas_key_up, LIBECORE_INPUT_EVAS);
102
103         if(isOptionEnabled(OPT_EVENT))
104         {
105                 probeBlockStart();
106                 if(event != NULL)
107                 {
108                         Ecore_Event_Key* pEv = (Ecore_Event_Key*)event;
109                         if(strcasestr(pEv->keyname, "volume") == NULL)
110                         {
111                                 PACK_HW_EVENT(API_ID_ecore_event_evas_key_up,
112                                               _EVENT_KEY, _KEY_RELEASED, 0, 0, pEv->keyname, 0, \
113                                               data, type, event);
114                         }
115                 }
116                 probeBlockEnd();
117         }
118
119         return ecore_event_evas_key_upp(data, type, event);
120 }
121
122 Eina_Bool ecore_event_evas_mouse_button_down(void *data, int type, void *event)
123 {
124         static Eina_Bool (*ecore_event_evas_mouse_button_downp)(void *data, int type, void *event);
125         probeInfo_t     probeInfo;
126
127         GET_REAL_FUNC(ecore_event_evas_mouse_button_down, LIBECORE_INPUT_EVAS);
128
129         if(isOptionEnabled(OPT_EVENT))
130         {
131                 probeBlockStart();
132                 if(event != NULL)
133                 {
134                         Ecore_Event_Mouse_Button* pEv = (Ecore_Event_Mouse_Button*)event;
135                         touch_pressed = true;
136                         PACK_HW_EVENT(API_ID_ecore_event_evas_mouse_button_down,
137                                       _EVENT_TOUCH, _TOUCH_PRESSED, pEv->root.x, pEv->root.y, "", pEv->multi.device, \
138                                       data, type, event);
139                 }
140                 probeBlockEnd();
141         }
142
143         return ecore_event_evas_mouse_button_downp(data, type, event);
144 }
145
146 Eina_Bool ecore_event_evas_mouse_button_up(void *data, int type, void *event)
147 {
148         static Eina_Bool (*ecore_event_evas_mouse_button_upp)(void *data, int type, void *event);
149         probeInfo_t     probeInfo;
150
151         GET_REAL_FUNC(ecore_event_evas_mouse_button_up, LIBECORE_INPUT_EVAS);
152
153         if(isOptionEnabled(OPT_EVENT))
154         {
155                 probeBlockStart();
156                 if(event != NULL)
157                 {
158                         Ecore_Event_Mouse_Button* pEv = (Ecore_Event_Mouse_Button*)event;
159                         touch_pressed = false;
160                         PACK_HW_EVENT(API_ID_ecore_event_evas_mouse_button_up,
161                                       _EVENT_TOUCH, _TOUCH_RELEASED, pEv->root.x, pEv->root.y, "", pEv->multi.device, \
162                                       data, type, event);
163                 }
164                 probeBlockEnd();
165         }
166
167         return ecore_event_evas_mouse_button_upp(data, type, event);
168 }
169
170 Eina_Bool ecore_event_evas_mouse_move(void *data, int type, void *event)
171 {
172         static Eina_Bool (*ecore_event_evas_mouse_movep)(void *data, int type, void *event);
173         probeInfo_t     probeInfo;
174
175         GET_REAL_FUNC(ecore_event_evas_mouse_move, LIBECORE_INPUT_EVAS);
176
177         if(isOptionEnabled(OPT_EVENT))
178         {
179                 probeBlockStart();
180                 if(touch_pressed)
181                 {
182                         if(event != NULL)
183                         {
184                                 Ecore_Event_Mouse_Move* pEv = (Ecore_Event_Mouse_Move*)event;
185                                 PACK_HW_EVENT(API_ID_ecore_event_evas_mouse_move,
186                                               _EVENT_TOUCH, _TOUCH_MOVED, pEv->root.x, pEv->root.y, "", pEv->multi.device, \
187                                               data, type, event);
188                         }
189                 }
190                 probeBlockEnd();
191         }
192
193         return ecore_event_evas_mouse_movep(data, type, event);
194 }
195
196
197 /*
198 void evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags,
199                 unsigned int timestamp, const void *data)
200 {
201         static void (*evas_event_feed_mouse_downp)(Evas *e, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data);
202
203         probeInfo_t     probeInfo;
204
205         GET_REAL_FUNC(evas_event_feed_mouse_down, LIBEVAS);
206
207         PRE_UNCONDITIONAL_BLOCK_BEGIN();
208         HW_EVENT_LOG(_EVENT_TOUCH, _TOUCH_PRESSED, )
209         PRE_UNCONDITIONAL_BLOCK_END();
210
211
212         DECLARE_VARIABLE_EVENT;
213         int x, y;
214
215         PRE_PROBEBLOCK_BEGIN_EVENT(evas_event_feed_mouse_down, LIBEVAS, EVENT_TYPE_DOWN);
216                 evas_pointer_output_xy_get(e, &x, &y);
217         PRE_PROBEBLOCK_END_EVENT();
218
219         evas_event_feed_mouse_downp(e, b, flags, timestamp, data);
220
221         AFTER_ORIGINAL_EVENT(EVENT_TYPE_DOWN, "%d", b);
222 }
223
224 void evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags,
225                 unsigned int timestamp, const void *data)
226 {
227         static void (*evas_event_feed_mouse_upp)(Evas *e, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data);
228
229         DECLARE_VARIABLE_EVENT;
230         int x, y;
231
232         PRE_PROBEBLOCK_BEGIN_EVENT(evas_event_feed_mouse_up, LIBEVAS, EVENT_TYPE_UP);
233                 evas_pointer_output_xy_get(e, &x, &y);
234         PRE_PROBEBLOCK_END_EVENT();
235
236         evas_event_feed_mouse_upp(e, b, flags, timestamp, data);
237
238         AFTER_ORIGINAL_EVENT(EVENT_TYPE_UP, "%d", b);
239 }
240
241 void evas_event_feed_mouse_move(Evas *e, int x, int y,
242                 unsigned int timestamp, const void *data)
243 {
244         static void (*evas_event_feed_mouse_movep)(Evas *e, int x, int y, unsigned int timestamp, const void *data);
245
246         BEFORE_ORIGINAL_EVENT(evas_event_feed_mouse_move, LIBEVAS, EVENT_TYPE_MOVE);
247
248         evas_event_feed_mouse_movep(e, x, y, timestamp, data);
249
250         AFTER_ORIGINAL_EVENT(EVENT_TYPE_MOVE, "%u", timestamp);
251 }
252
253 void evas_event_feed_multi_down(Evas *e, int d, int x, int y,
254                 double rad, double radx, double rady,
255                 double pres, double ang, double fx, double fy,
256                 Evas_Button_Flags flags, unsigned int timestamp, const void *data)
257 {
258         static void (*evas_event_feed_multi_downp)(Evas *e, int d, int x, int y, double rad, double radx, double rady, double pres, double ang, double fx, double fy, Evas_Button_Flags flags, unsigned int timestamp, const void *data);
259
260         BEFORE_ORIGINAL_EVENT(evas_event_feed_multi_down, LIBEVAS, EVENT_TYPE_DOWN);
261
262         evas_event_feed_multi_downp(e, d, x, y, rad, radx,
263                         rady, pres, ang, fx, fy, flags, timestamp, data);
264
265         AFTER_ORIGINAL_EVENT(EVENT_TYPE_DOWN, "%d", d);
266 }
267
268 void evas_event_feed_multi_up(Evas *e, int d, int x, int y, double rad, double radx,
269                 double rady, double pres, double ang, double fx, double fy,
270                 Evas_Button_Flags flags, unsigned int timestamp, const void *data)
271 {
272         static void (*evas_event_feed_multi_upp)(Evas *e, int d, int x, int y, double rad, double radx, double rady, double pres, double ang, double fx, double fy, Evas_Button_Flags flags, unsigned int timestamp, const void *data);
273
274         BEFORE_ORIGINAL_EVENT(evas_event_feed_multi_up, LIBEVAS, EVENT_TYPE_UP);
275
276         evas_event_feed_multi_upp(e, d, x, y, rad, radx, rady,
277                         pres, ang, fx, fy, flags, timestamp, data);
278
279         AFTER_ORIGINAL_EVENT(EVENT_TYPE_UP, "%d", d);
280 }
281
282 void evas_event_feed_multi_move (Evas *e, int d, int x, int y, double rad, double radx,
283                 double rady, double pres, double ang, double fx, double fy,
284                 unsigned int timestamp, const void *data)
285 {
286         static void (*evas_event_feed_multi_movep)(Evas *e, int d, int x, int y, double rad, double radx, double rady, double pres, double ang, double fx, double fy, unsigned int timestamp, const void *data);
287
288         BEFORE_ORIGINAL_EVENT(evas_event_feed_multi_move, LIBEVAS, EVENT_TYPE_MOVE);
289
290         evas_event_feed_multi_movep(e, d, x, y, rad, radx, rady,
291                         pres, ang, fx, fy, timestamp, data);
292
293         AFTER_ORIGINAL_EVENT(EVENT_TYPE_MOVE, "%d", d);
294 }
295 */