sensor: replace emuld to ECS when rotating
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 25 Sep 2013 08:23:06 +0000 (17:23 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Wed, 25 Sep 2013 08:26:10 +0000 (17:26 +0900)
replace emuld to EmulatorControlServer when skin rotating

Change-Id: I599eb8dd3b8460dc0a017bca3c508ac914fbd368
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ecs/ecs.h
tizen/src/ecs/ecs_sensor.c
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c

index f5b6cd8..f6afd82 100644 (file)
@@ -175,6 +175,9 @@ enum{
     CONTROL_COMMAND_SCREENSHOT_REQ = 2
 };
 
+/* request */
+void req_set_sensor_accel(int x, int y, int z);
+
 // control sub messages
 void msgproc_control_hostkeyboard_req(ECS_Client *cli, ECS__HostKeyboardReq* req);
 
index 5e029c3..114d602 100644 (file)
@@ -89,7 +89,16 @@ static int accel_min_max(char* tmp)
     return value;
 }
 
-static void req_set_sensor_accel(int len, const char* data)
+void req_set_sensor_accel(int x, int y, int z)
+{
+    char tmp[TEMP_BUF_SIZE] = { 0, };
+
+    sprintf(tmp, "%d, %d, %d", x, y, z);
+
+    set_sensor_accel(tmp, strlen(tmp));
+}
+
+static void _req_set_sensor_accel(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
     int x, y, z;
@@ -116,7 +125,7 @@ static void req_set_sensor_accel(int len, const char* data)
     set_sensor_accel(tmp, strlen(tmp));
 }
 
-static void req_set_sensor_proxi(int len, const char* data)
+static void _req_set_sensor_proxi(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
 
@@ -129,7 +138,7 @@ static void req_set_sensor_proxi(int len, const char* data)
     set_sensor_proxi(tmp, strlen(tmp));
 }
 
-static void req_set_sensor_light(int len, const char* data)
+static void _req_set_sensor_light(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
     int x;
@@ -149,7 +158,7 @@ static void req_set_sensor_light(int len, const char* data)
     }
 }
 
-static void req_set_sensor_gyro(int len, const char* data)
+static void _req_set_sensor_gyro(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
     int x, y, z;
@@ -176,7 +185,7 @@ static void req_set_sensor_gyro(int len, const char* data)
     set_sensor_gyro(tmp, strlen(tmp));
 }
 
-static void req_set_sensor_geo(int len, const char* data)
+static void _req_set_sensor_geo(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
     int x, y, z, accuracy, t_north, t_east, t_vertical;
@@ -224,7 +233,7 @@ static void req_set_sensor_geo(int len, const char* data)
     set_sensor_mag(tmp, strlen(tmp));
 }
 
-static void req_set_sensor_tilt(int len, const char* data)
+static void _req_set_sensor_tilt(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
     int x, y, z, accuracy = 3;
@@ -251,7 +260,7 @@ static void req_set_sensor_tilt(int len, const char* data)
     set_sensor_tilt(tmp, strlen(tmp));
 }
 
-static void req_set_sensor_mag(int len, const char* data)
+static void _req_set_sensor_mag(int len, const char* data)
 {
     char tmp[TEMP_BUF_SIZE];
     int x, y, z;
@@ -285,25 +294,25 @@ void set_sensor_data(int length, const char* data)
 
     switch(atoi(tmpbuf)) {
         case level_accel:
-            req_set_sensor_accel(len, data);
+            _req_set_sensor_accel(len, data);
             break;
         case level_proxi:
-            req_set_sensor_proxi(len, data);
+            _req_set_sensor_proxi(len, data);
             break;
         case level_light:
-            req_set_sensor_light(len, data);
+            _req_set_sensor_light(len, data);
             break;
         case level_gyro:
-            req_set_sensor_gyro(len, data);
+            _req_set_sensor_gyro(len, data);
             break;
         case level_geo:
-            req_set_sensor_geo(len, data);
+            _req_set_sensor_geo(len, data);
             break;
         case level_tilt:
-            req_set_sensor_tilt(len, data);
+            _req_set_sensor_tilt(len, data);
             break;
         case level_magnetic:
-            req_set_sensor_mag(len, data);
+            _req_set_sensor_mag(len, data);
             break;
         default:
             break;
index d8cd39e..eb25da6 100644 (file)
@@ -47,9 +47,8 @@
 #include "emul_state.h"
 #include "maruskin_keymap.h"
 #include "maruskin_server.h"
-#include "emul_state.h"
 #include "hw/maru_pm.h"
-#include "emul_state.h"
+#include "ecs/ecs.h"
 
 #ifdef CONFIG_HAX
 #include "guest_debug.h"
@@ -307,7 +306,7 @@ void do_hardkey_event(int event_type, int keycode)
 
 void do_scale_event(double scale_factor)
 {
-    INFO("do_scale_event scale_factor:%lf\n", scale_factor);
+    INFO("do_scale_event scale_factor : %lf\n", scale_factor);
 
     set_emul_win_scale(scale_factor);
 
@@ -321,38 +320,36 @@ void do_scale_event(double scale_factor)
 
 void do_rotation_event(int rotation_type)
 {
+    INFO("do_rotation_event rotation_type : %d\n", rotation_type);
 
-    INFO( "do_rotation_event rotation_type:%d\n", rotation_type);
+    int x = 0, y = 0, z = 0;
 
-    set_emul_rotation( rotation_type );
-}
-
-void send_rotation_event(int rotation_type)
-{
-
-    INFO( "send_rotation_event rotation_type:%d\n", rotation_type);
-
-    char send_buf[32] = { 0 };
-
-    switch ( rotation_type ) {
+    switch (rotation_type) {
         case ROTATION_PORTRAIT:
-            sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" );
+            x = 0;
+            y = 9.80665;
+            z = 0;
             break;
         case ROTATION_LANDSCAPE:
-            sprintf( send_buf, "1\n3\n9.80665\n0\n0\n" );
+            x = 9.80665;
+            y = 0;
+            z = 0;
             break;
         case ROTATION_REVERSE_PORTRAIT:
-            sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" );
+            x = 0;
+            y = -9.80665;
+            z = 0;
             break;
         case ROTATION_REVERSE_LANDSCAPE:
-            sprintf(send_buf, "1\n3\n-9.80665\n0\n0\n");
+            x = -9.80665;
+            y = 0;
+            z = 0;
             break;
-
         default:
             break;
     }
 
-    send_to_emuld( "sensor\n\n\n\n", 10, send_buf, 32 );
+    req_set_sensor_accel(x, y, z);
 }
 
 void set_maru_screenshot(DisplaySurface *surface)
index bf189a4..3d03e76 100644 (file)
@@ -58,7 +58,6 @@ void do_key_event(int event_type,
 void do_hardkey_event(int event_type, int keycode);
 void do_scale_event(double scale_factor);
 void do_rotation_event(int rotation_type);
-void send_rotation_event(int rotation_type);
 
 QemuSurfaceInfo *get_screenshot_info(void);
 DetailInfo *get_detail_info(int qemu_argc, char **qemu_argv);
index e5e4c67..3f212ed 100644 (file)
@@ -934,11 +934,11 @@ static void* run_skin_server(void* args)
                     break;
                 }
                 case RECV_CHANGE_LCD_STATE: {
-                    log_cnt += sprintf( log_buf + log_cnt, "RECV_CHANGE_LCD_STATE ==\n" );
-                    TRACE( log_buf );
+                    log_cnt += sprintf(log_buf + log_cnt, "RECV_CHANGE_LCD_STATE ==\n");
+                    TRACE(log_buf);
 
-                    if ( 0 >= length ) {
-                        ERR( "there is no data looking at 0 length." );
+                    if (0 >= length) {
+                        ERR("there is no data looking at 0 length.");
                         continue;
                     }
 
@@ -946,33 +946,37 @@ static void* run_skin_server(void* args)
                     int scale = 0;
                     double scale_ratio = 0.0;
                     short rotation_type = 0;
-                    int is_rotate = 0;
 
                     char* p = recvbuf;
-                    memcpy( &scale, p, sizeof( scale ) );
-                    p += sizeof( scale );
-                    memcpy( &rotation_type, p, sizeof( rotation_type ) );
+                    memcpy(&scale, p, sizeof(scale));
+                    p += sizeof(scale);
+                    memcpy(&rotation_type, p, sizeof(rotation_type));
 
-                    scale = ntohl( scale );
-                    scale_ratio = ( (double) scale ) / 100;
-                    rotation_type = ntohs( rotation_type );
+                    scale = ntohl(scale);
+                    scale_ratio = ((double) scale) / 100;
+                    rotation_type = ntohs(rotation_type);
 
-                    if ( get_emul_win_scale() != scale_ratio ) {
-                        do_scale_event( scale_ratio );
+                    /* scaling */
+                    if (get_emul_win_scale() != scale_ratio) {
+                        do_scale_event(scale_ratio);
                     }
 
-                    if ( is_sensord_initialized == 1 && get_emul_rotation() != rotation_type ) {
-                        do_rotation_event( rotation_type );
-                        is_rotate = 1;
+                    /* rotation */
+                    bool is_rotate = false;
+                    if (is_sensord_initialized == 1 && get_emul_rotation() != rotation_type) {
+                        set_emul_rotation(rotation_type);
+                        is_rotate = true;
                     }
 
 #ifndef CONFIG_USE_SHM
-                    maruskin_sdl_resize(); /* send sdl event */
+                    maruskin_sdl_resize();
 #else
                     maruskin_shm_resize();
 #endif
-                    if (is_rotate) {
-                        send_rotation_event( rotation_type );
+
+                    /* after display resizing */
+                    if (is_rotate == true) {
+                        do_rotation_event(rotation_type);
                     }
 
                     break;