tizen 2.3 release
[framework/system/swap-probe.git] / probe_event / da_event.h
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 #ifndef __DA_EVENT_H__
34 #define __DA_EVENT_H__
35
36 #include "daprobe.h"
37
38 /*******************************************************************
39  * Type definition
40  *******************************************************************/
41
42 enum __event_type
43 {
44         _EVENT_KEY = 1,
45         _EVENT_TOUCH = 2,
46         _EVENT_GESTURE = 3,
47         _EVENT_ORIENTATION = 4,
48         _EVENT_LISTENER = 5
49 } EVENT_TYPE;
50
51 enum __key_status
52 {
53         _KEY_PRESSED = 0,
54         _KEY_RELEASED = 1
55 } KEY_STATUS;
56
57 enum __touch_status
58 {
59         _TOUCH_PRESSED = 0,
60         _TOUCH_LONG_PRESSED = 1,
61         _TOUCH_RELEASED = 2,
62         _TOUCH_MOVED = 3,
63         _TOUCH_DOUBLE_PRESSED = 4,
64         _TOUCH_FOCUS_IN = 5,
65         _TOUCH_FOCUS_OUT = 6,
66         _TOUCH_CANCELED = 7
67 } _TOUCH_STATUS;
68
69 enum __gesture_type
70 {
71         _GESTURE_FLICK = 0,
72         _GESTURE_LONGPRESS = 1,
73         _GESTURE_PANNING = 2,
74         _GESTURE_PINCH = 3,
75         _GESTURE_ROTATION = 4,
76         _GESTURE_TAP = 5,
77         _GESTURE_CUSTOM = 6
78 } GESTURE_TYPE;
79
80 enum _orientation_status
81 {
82         _OS_NONE = 0,
83         _OS_PORTRAIT = 1,
84         _OS_LANDSCAPE = 2,
85         _OS_PORTRAIT_REVERSE = 3,
86         _OS_LANDSCAPE_REVERSE = 4
87 } ORIENTATION_STATUS;
88
89
90 /*******************************************************************
91  * macros for event probe
92  *
93  * log format:
94  *              SeqNumber`,ApiName`,Time`,Pid`,Tid`,InputParm`,Return`,PCAddr`,Error`,x`,y`,\n
95  *              callstack_start`,callstack`,callstack_end
96  *
97  *******************************************************************/
98
99 #define DECLARE_VARIABLE_EVENT                  \
100         probeInfo_t     probeInfo;                              \
101         static unsigned int oldtime = 0;        \
102         int blockresult = 0
103
104 #define PRE_PROBEBLOCK_BEGIN_EVENT(FUNCNAME, LIBNAME, EVENTTYPE)        \
105         GET_REAL_FUNC(FUNCNAME, LIBNAME);                                                               \
106         do {                                                                                                                    \
107                 if(oldtime != timestamp && (EVENTTYPE != EVENT_TYPE_MOVE ||     \
108                         getTouchState() == EVENT_TYPE_DOWN ||                                   \
109                         getTouchState() == EVENT_TYPE_MOVE))                                    \
110                 {                                                                                                                       \
111                         blockresult = 1;                                                                                \
112                         detectTouchEvent(EVENTTYPE);                                                    \
113                         PRE_UNCONDITIONAL_BLOCK_BEGIN()
114
115 #define PRE_PROBEBLOCK_END_EVENT()                      \
116                         PRE_UNCONDITIONAL_BLOCK_END();  \
117                 }                                                                       \
118         } while(0)
119
120 #define BEFORE_ORIGINAL_EVENT(FUNCNAME, LIBNAME, EVENTTYPE)             \
121         DECLARE_VARIABLE_EVENT;                                                                         \
122         PRE_PROBEBLOCK_BEGIN_EVENT(FUNCNAME, LIBNAME, EVENTTYPE);       \
123         PRE_PROBEBLOCK_END_EVENT()
124
125 #define AFTER_ORIGINAL_EVENT(EVENTTYPE, INPUTFORMAT, ...)               \
126         do {                                                                                                            \
127                 if(blockresult == 1) {                                                                  \
128                         POST_UNCONDITIONAL_BLOCK_BEGIN(LC_UIEVENT);                     \
129                         APPEND_LOG_INPUT(INPUTFORMAT, __VA_ARGS__);                     \
130                         log.length += sprintf(log.data + log.length,            \
131                                         "`,`,`,`,1`,`,%d`,%d`,%d", x, y, EVENTTYPE);\
132                         APPEND_LOG_NULL_CALLSTACK();                                            \
133                         POST_UNCONDITIONAL_BLOCK_END();                                         \
134                         oldtime = timestamp;                                                            \
135                 }                                                                                                               \
136         } while(0)
137
138
139 #endif // __DA_EVENT_H__