Add probe to ecore_event_evas_mouse_move
[platform/core/system/swap-probe.git] / probe_event / da_event.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 <appfw/app.h>
32 #include <runtime_info.h>
33
34 #include <Ecore.h>
35 #include <Eina.h>
36 #include <Ecore_X.h>
37
38 #include "daprobe.h"
39 #include "dahelper.h"
40 #include "da_event.h"
41
42 static int external_angle = 0;
43 static int internal_angle = 0;
44 static bool orientation_enabled = false;
45
46 // ===================================================================
47 // orientation related functions
48 // ===================================================================
49
50 static int convert_angle(int angle)
51 {
52         int os = _OS_NONE;
53
54         switch(angle)
55         {
56         case 0:
57                 os = _OS_PORTRAIT;
58                 break;
59         case 90:
60                 os = _OS_LANDSCAPE_REVERSE;
61                 break;
62         case 180:
63                 os = _OS_PORTRAIT_REVERSE;
64                 break;
65         case 270:
66                 os = _OS_LANDSCAPE;
67                 break;
68         default:
69                 break;
70         }
71
72         return os;
73 }
74
75 void on_orientation_changed(int angle, bool capi)
76 {
77         DECLARE_COMMON_VARIABLE;
78         bool autoRotation = true;
79
80         probeBlockStart();
81
82         internal_angle = angle;
83         runtime_info_get_value_bool(
84                         RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotation);
85
86         if(autoRotation)        // rotation is not locked
87         {
88                 external_angle = internal_angle;
89
90                 if(isOptionEnabled(OPT_EVENT))
91                 {
92                         setProbePoint(&probeInfo);
93                         INIT_LOG;
94                         APPEND_LOG_BASIC_NAME(LC_UIEVENT, "OrientationChanged");
95                         APPEND_LOG_COMMON_NONE(0);
96                         log.length += sprintf(log.data + log.length, "`,%d`,`,`,`,%d`,",
97                                         _EVENT_ORIENTATION, convert_angle(external_angle));
98                         printLog(&log, MSG_LOG);
99                 }
100
101 //              if(orientation_enabled)
102 //              {
103                         SCREENSHOT_SET();
104 //                      if(!capi)
105 //                      {
106 //                              SCREENSHOT_DONE();
107 //                      }
108 //              }
109         }
110         else { }        // do nothing
111
112         probeBlockEnd();
113 }
114
115 void orientationEnabled()
116 {
117         orientation_enabled = true;
118 }
119
120 int getOrientation()
121 {
122         return external_angle;
123 }
124
125 // ====================================================================
126 // initialize and finalize event
127 // ====================================================================
128
129 int initialize_event()
130 {
131         external_angle = internal_angle = app_get_device_orientation();
132         return 0;
133 }
134
135 int finalize_event()
136 {
137         return 0;
138 }
139
140