tizen 2.3 release
[framework/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 #include "real_functions.h"
55
56 bool touch_pressed = false;
57
58 #define PACK_HW_EVENT(API_ID, _EVENTTYPE, _DETAILTYPE, _X, _Y, _KEYCODE, _EXTRA, \
59         _ARGDATA, _ARGTYPE, _ARGEVENT)                                                                                          \
60         do {                                                                                                                                            \
61                 setProbePoint(&probeInfo);                                                                                              \
62                 PREPARE_LOCAL_BUF();                                                                                                    \
63                 PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT, API_ID, "pdp",                                     \
64                                   voidp_to_uint64(_ARGDATA), _ARGTYPE,  \
65                                   voidp_to_uint64(_ARGEVENT));          \
66                 PACK_COMMON_END('c', 0, 0, 0);                                                                                          \
67                 PACK_UIEVENT(_EVENTTYPE, _DETAILTYPE, _X, _Y, _KEYCODE, _EXTRA);                \
68                 FLUSH_LOCAL_BUF();                                                                                                              \
69         } while (0)
70
71 Eina_Bool ecore_event_evas_key_down(void *data, int type, void *event)
72 {
73         static Eina_Bool (*ecore_event_evas_key_downp)(void *data, int type, void *event);
74         probeInfo_t     probeInfo;
75
76         GET_REAL_FUNC(ecore_event_evas_key_down, LIBECORE_INPUT_EVAS);
77
78         if(isOptionEnabled(OPT_EVENT))
79         {
80                 probeBlockStart();
81                 if(event != NULL)
82                 {
83                         Ecore_Event_Key* pEv = (Ecore_Event_Key*)event;
84                         if(strcasestr(pEv->keyname, "volume") == NULL)
85                         {
86                                 PACK_HW_EVENT(API_ID_ecore_event_evas_key_down,
87                                               _EVENT_KEY, _KEY_PRESSED, 0, 0, pEv->keyname, 0, \
88                                               data, type, event);
89                         }
90                 }
91                 probeBlockEnd();
92         }
93
94         return ecore_event_evas_key_downp(data, type, event);
95 }
96
97 Eina_Bool ecore_event_evas_key_up(void *data, int type, void *event)
98 {
99         static Eina_Bool (*ecore_event_evas_key_upp)(void *data, int type, void *event);
100         probeInfo_t     probeInfo;
101
102         GET_REAL_FUNC(ecore_event_evas_key_up, LIBECORE_INPUT_EVAS);
103
104         if(isOptionEnabled(OPT_EVENT))
105         {
106                 probeBlockStart();
107                 if(event != NULL)
108                 {
109                         Ecore_Event_Key* pEv = (Ecore_Event_Key*)event;
110                         if(strcasestr(pEv->keyname, "volume") == NULL)
111                         {
112                                 PACK_HW_EVENT(API_ID_ecore_event_evas_key_up,
113                                               _EVENT_KEY, _KEY_RELEASED, 0, 0, pEv->keyname, 0, \
114                                               data, type, event);
115                         }
116                 }
117                 probeBlockEnd();
118         }
119
120         return ecore_event_evas_key_upp(data, type, event);
121 }
122
123 Eina_Bool ecore_event_evas_mouse_button_down(void *data, int type, void *event)
124 {
125         static Eina_Bool (*ecore_event_evas_mouse_button_downp)(void *data, int type, void *event);
126         probeInfo_t     probeInfo;
127
128         GET_REAL_FUNC(ecore_event_evas_mouse_button_down, LIBECORE_INPUT_EVAS);
129
130         if(isOptionEnabled(OPT_EVENT))
131         {
132                 probeBlockStart();
133                 if(event != NULL)
134                 {
135                         Ecore_Event_Mouse_Button* pEv = (Ecore_Event_Mouse_Button*)event;
136                         touch_pressed = true;
137                         PACK_HW_EVENT(API_ID_ecore_event_evas_mouse_button_down,
138                                       _EVENT_TOUCH, _TOUCH_PRESSED, pEv->root.x, pEv->root.y, "", pEv->multi.device, \
139                                       data, type, event);
140                 }
141                 probeBlockEnd();
142         }
143
144         return ecore_event_evas_mouse_button_downp(data, type, event);
145 }
146
147 Eina_Bool ecore_event_evas_mouse_button_up(void *data, int type, void *event)
148 {
149         static Eina_Bool (*ecore_event_evas_mouse_button_upp)(void *data, int type, void *event);
150         probeInfo_t     probeInfo;
151
152         GET_REAL_FUNC(ecore_event_evas_mouse_button_up, LIBECORE_INPUT_EVAS);
153
154         if(isOptionEnabled(OPT_EVENT))
155         {
156                 probeBlockStart();
157                 if(event != NULL)
158                 {
159                         Ecore_Event_Mouse_Button* pEv = (Ecore_Event_Mouse_Button*)event;
160                         touch_pressed = false;
161                         PACK_HW_EVENT(API_ID_ecore_event_evas_mouse_button_up,
162                                       _EVENT_TOUCH, _TOUCH_RELEASED, pEv->root.x, pEv->root.y, "", pEv->multi.device, \
163                                       data, type, event);
164                 }
165                 probeBlockEnd();
166         }
167
168         return ecore_event_evas_mouse_button_upp(data, type, event);
169 }
170
171 Eina_Bool ecore_event_evas_mouse_move(void *data, int type, void *event)
172 {
173         static Eina_Bool (*ecore_event_evas_mouse_movep)(void *data, int type, void *event);
174         probeInfo_t     probeInfo;
175
176         GET_REAL_FUNC(ecore_event_evas_mouse_move, LIBECORE_INPUT_EVAS);
177
178         if(isOptionEnabled(OPT_EVENT))
179         {
180                 probeBlockStart();
181                 if(touch_pressed)
182                 {
183                         if(event != NULL)
184                         {
185                                 Ecore_Event_Mouse_Move* pEv = (Ecore_Event_Mouse_Move*)event;
186                                 PACK_HW_EVENT(API_ID_ecore_event_evas_mouse_move,
187                                               _EVENT_TOUCH, _TOUCH_MOVED, pEv->root.x, pEv->root.y, "", pEv->multi.device, \
188                                               data, type, event);
189                         }
190                 }
191                 probeBlockEnd();
192         }
193
194         return ecore_event_evas_mouse_movep(data, type, event);
195 }