sensor: added legacy do_rotation_event function
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 25 Sep 2013 08:30:39 +0000 (17:30 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Wed, 25 Sep 2013 08:55:05 +0000 (17:55 +0900)
Change-Id: I3e7082740c2c480efa435201e5df0eb6a232fc36
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

index f6afd82250ea5f23b54bbe4f874415bf793f6f28..9283747e3cff5d44e5a0bfeb6c8d93389d76696f 100644 (file)
@@ -176,6 +176,7 @@ enum{
 };
 
 /* request */
+int accel_min_max(double value);
 void req_set_sensor_accel(int x, int y, int z);
 
 // control sub messages
index 114d6027f7fc2722e20871260b4181ed66983103..666eff70dcae54d0d0a051082d18503bf0686118 100644 (file)
@@ -76,17 +76,22 @@ static int get_parse_val (const char* buf, char* tmp)
     return index;
 }
 
-static int accel_min_max(char* tmp)
+int accel_min_max(double value)
 {
-    int value = (int)(atof(tmp) * ACCEL_ADJUST);
+    int result = (int)(value * ACCEL_ADJUST);
 
-    if (value > ACCEL_MAX)
-        value = ACCEL_MAX;
+    if (result > ACCEL_MAX)
+        result = ACCEL_MAX;
 
-    if (value < -ACCEL_MAX)
-        value = -ACCEL_MAX;
+    if (result < -ACCEL_MAX)
+        result = -ACCEL_MAX;
 
-    return value;
+    return result;
+}
+
+static int _accel_min_max(char* tmp)
+{
+    return accel_min_max(atof(tmp));
 }
 
 void req_set_sensor_accel(int x, int y, int z)
@@ -108,15 +113,15 @@ static void _req_set_sensor_accel(int len, const char* data)
 
     // x
     len += get_parse_val(data + len, tmp);
-    x = accel_min_max(tmp);
+    x = _accel_min_max(tmp);
 
     // y
     len += get_parse_val(data + len, tmp);
-    y = accel_min_max(tmp);
+    y = _accel_min_max(tmp);
 
     // z
     len += get_parse_val(data + len, tmp);
-    z = accel_min_max(tmp);
+    z = _accel_min_max(tmp);
 
     memset(tmp, 0, TEMP_BUF_SIZE);
 
index eb25da68bae2efa5dc15d5f822fd77c5006ae777..988648c371b51aa12cba48f0585c70c3c9b5a30c 100644 (file)
@@ -322,26 +322,27 @@ void do_rotation_event(int rotation_type)
 {
     INFO("do_rotation_event rotation_type : %d\n", rotation_type);
 
+#if 0
     int x = 0, y = 0, z = 0;
 
     switch (rotation_type) {
         case ROTATION_PORTRAIT:
             x = 0;
-            y = 9.80665;
+            y = accel_min_max(9.80665);
             z = 0;
             break;
         case ROTATION_LANDSCAPE:
-            x = 9.80665;
+            x = accel_min_max(9.80665);
             y = 0;
             z = 0;
             break;
         case ROTATION_REVERSE_PORTRAIT:
             x = 0;
-            y = -9.80665;
+            y = accel_min_max(-9.80665);
             z = 0;
             break;
         case ROTATION_REVERSE_LANDSCAPE:
-            x = -9.80665;
+            x = accel_min_max(-9.80665);
             y = 0;
             z = 0;
             break;
@@ -350,6 +351,29 @@ void do_rotation_event(int rotation_type)
     }
 
     req_set_sensor_accel(x, y, z);
+#else
+    char send_buf[32] = { 0 };
+
+    switch ( rotation_type ) {
+        case ROTATION_PORTRAIT:
+            sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" );
+            break;
+        case ROTATION_LANDSCAPE:
+            sprintf( send_buf, "1\n3\n9.80665\n0\n0\n" );
+            break;
+        case ROTATION_REVERSE_PORTRAIT:
+            sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" );
+            break;
+        case ROTATION_REVERSE_LANDSCAPE:
+            sprintf(send_buf, "1\n3\n-9.80665\n0\n0\n");
+            break;
+
+        default:
+            break;
+    }
+
+    send_to_emuld( "sensor\n\n\n\n", 10, send_buf, 32 );
+#endif
 }
 
 void set_maru_screenshot(DisplaySurface *surface)