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