tethering: support display feature. 88/24488/5
authorKitae Kim <kt920.kim@samsung.com>
Tue, 15 Jul 2014 07:16:12 +0000 (16:16 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Tue, 15 Jul 2014 11:38:21 +0000 (20:38 +0900)
When app on server side request display update,
emulator sends encoded framebuffer to it.

Change-Id: I1e65404a74b4a7871224e577c9fc4750c5489553
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
14 files changed:
tizen/emulator_configure.sh
tizen/src/ecs/ecs_tethering.c
tizen/src/tethering/Makefile.objs
tizen/src/tethering/common.c [moved from tizen/src/tethering/app_tethering.c with 57% similarity]
tizen/src/tethering/common.h [moved from tizen/src/tethering/app_tethering.h with 85% similarity]
tizen/src/tethering/encode_fb.c [new file with mode: 0644]
tizen/src/tethering/encode_fb.h [new file with mode: 0644]
tizen/src/tethering/genmsg/tethering.pb-c.c
tizen/src/tethering/genmsg/tethering.pb-c.h
tizen/src/tethering/msg/tethering.proto
tizen/src/tethering/sensor.c [new file with mode: 0644]
tizen/src/tethering/sensor.h [new file with mode: 0644]
tizen/src/tethering/touch.c [new file with mode: 0644]
tizen/src/tethering/touch.h [new file with mode: 0644]

index cebc28e..50c4435 100755 (executable)
@@ -183,7 +183,7 @@ else
 fi
 
 # append common flags
-CONFIGURE_APPEND="--enable-maru --enable-libav --enable-curl --disable-gtk $CONFIGURE_APPEND"
+CONFIGURE_APPEND="--enable-maru --enable-libav --enable-curl --enable-png --disable-gtk $CONFIGURE_APPEND"
 
 if [ -z ${PKG_CONFIG_PATH} ] ; then    # avoid pkg-config bug on Windows
 export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/distrib/lib/pkgconfig
@@ -204,7 +204,6 @@ exec ./configure \
  --disable-pie \
  --enable-virtfs \
  --disable-xen \
- --enable-png \
  $CONFIGURE_APPEND \
 ;;
 MINGW*)
@@ -221,7 +220,6 @@ exec ./configure \
  --audio-drv-list=winwave \
  --enable-hax \
  --disable-vnc \
- --enable-png \
  $CONFIGURE_APPEND \
 ;;
 Darwin*)
index eec010b..2960048 100644 (file)
@@ -31,7 +31,9 @@
 
 #include "ecs.h"
 #include "ecs_tethering.h"
-#include "tethering/app_tethering.h"
+#include "tethering/common.h"
+#include "tethering/sensor.h"
+#include "tethering/touch.h"
 #include "hw/virtio/maru_virtio_touchscreen.h"
 #include "debug_ch.h"
 
@@ -119,7 +121,7 @@ static void send_tethering_status_ntf(type_group group, type_action action)
         status = get_tethering_sensor_status();
         break;
     case ECS_TETHERING_MSG_ACTION_TOUCH_STATUS:
-        status = get_tethering_multitouch_status();
+        status = get_tethering_touch_status();
         break;
     default:
         break;
index 3a0b9e4..e18d263 100644 (file)
@@ -1,2 +1,5 @@
 obj-y += genmsg/tethering.pb-c.o # protobuf-c.o
-obj-y += app_tethering.o
+obj-y += common.o
+obj-y += sensor.o
+obj-y += touch.o
+obj-y += encode_fb.o
similarity index 57%
rename from tizen/src/tethering/app_tethering.c
rename to tizen/src/tethering/common.c
index 5607e38..3b9333e 100644 (file)
 #include "ui/console.h"
 
 #include "emulator.h"
+#include "common.h"
+#include "sensor.h"
+#include "touch.h"
+// #include "display.h"
 #include "emul_state.h"
-#include "app_tethering.h"
 #include "ecs/ecs_tethering.h"
 #include "genmsg/tethering.pb-c.h"
 
@@ -56,55 +59,83 @@ MULTI_DEBUG_CHANNEL(tizen, app_tethering);
 #define min(a,b) ((a)<(b)?(a):(b))
 #endif
 
+#define SEND_BUF_MAX_SIZE 4096
+
 typedef struct tethering_recv_buf {
     uint32_t len;
     uint32_t stack_size;
     char data[MSG_BUF_SIZE];
 } tethering_recv_buf;
 
+#if 0
+typedef struct input_device_list {
+    int type;
+    void *opaque;
+
+    QTAILQ_ENTRY(input_device_list) node;
+} input_device_list;
+#endif
+
 typedef struct _TetheringState {
     int fd;
+
+    // server address
     int port;
     gchar *ipaddress;
 
+    // connection state
     int status;
-    tethering_recv_buf recv_buf;
 
+    // receiver handling thread
     QemuThread thread;
-} TetheringState;
+    QemuMutex mutex;
 
-static TetheringState *tethering_client;
+    tethering_recv_buf recv_buf;
 
-enum sensor_level {
-    level_accel = 1,
-    level_proxi = 2,
-    level_light = 3,
-    level_gyro = 4,
-    level_geo = 5,
-    level_tilt = 12,
-    level_magnetic = 13
-};
-
-#ifndef DEBUG
-const char *connection_status_str[4] = {"CONNECTED", "DISCONNECTED",
-                                        "CONNECTING", "CONNREFUSED"};
-#endif
+    // device state
+    QTAILQ_HEAD(device, input_device_list) device;
+    int device_node_cnt;
 
-static tethering_recv_buf recv_buf;
+} TetheringState;
 
+static TetheringState *tethering_client;
+static tethering_recv_buf recv_buf;
 // static bool app_state = false;
-static int sensor_device_status = DISABLED;
-static int mt_device_status = DISABLED;
 
 static void end_tethering_socket(int sockfd);
 static void set_tethering_connection_status(int status);
-static void set_tethering_sensor_status(int status);
-static void set_tethering_multitouch_status(int status);
 #if 0
 static void set_tethering_app_state(bool state);
 static bool get_tethering_app_state(void);
 #endif
 
+#if 0
+int add_input_device(void *opaque)
+{
+    input_device_list *elem = (input_device_list *)opaque;
+
+    if (!tethering_client) {
+        return -1;
+    }
+
+    QTAILQ_INSERT_TAIL(&tethering_client->device, elem, node);
+
+    return (tethering_client->device_node_cnt++);
+}
+
+int remove_input_device(void *opaque)
+{
+    if (!tethering_client) {
+        return -1;
+    }
+
+    QTAILQ_REMOVE(&tethering_client->device, opaque, node);
+
+    tethering_client->device_node_cnt--;
+}
+#endif
+
+// create master message
 static void *build_tethering_msg(Tethering__TetheringMsg* msg, int *payloadsize)
 {
     void *buf = NULL;
@@ -132,48 +163,73 @@ static void *build_tethering_msg(Tethering__TetheringMsg* msg, int *payloadsize)
     return buf;
 }
 
-static bool send_msg_to_controller(Tethering__TetheringMsg *msg)
+bool send_msg_to_controller(void *msg)
 {
+    Tethering__TetheringMsg * tetheringMsg = (Tethering__TetheringMsg *)msg;
+
     void *buf = NULL;
-    int payload_size = 0, sent_size = 0, total_sent_size = 0;
+    int payload_size = 0, sent_size = 0;
+    int total_buf_size = 0;
     int sockfd = 0;
     bool ret = true;
+    uint32_t buf_offset = 0;
 
-    buf = build_tethering_msg(msg, &payload_size);
+    buf = build_tethering_msg(tetheringMsg, &payload_size);
     if (!buf) {
         return false;
     }
 
     if (!tethering_client) {
+        ERR("TetheringState is NULL\n");
         g_free(buf);
         return false;
     }
-
     sockfd = tethering_client->fd;
+
+    total_buf_size = payload_size;
     do {
+        TRACE("sending a buffer as many as this size: %d\n", total_buf_size);
+
         sent_size =
-            qemu_sendto(sockfd, buf + sent_size, (payload_size - sent_size),
-                        0, NULL, 0);
+            qemu_sendto(sockfd, buf + buf_offset, total_buf_size, 0, NULL, 0);
         if (sent_size < 0) {
             perror("failed to send a packet");
+            if (errno == EAGAIN) {
+                //sleep(1);
+                fd_set writefds;
+                struct timeval timeout;
+
+                FD_ZERO(&writefds);
+                FD_SET(sockfd, &writefds);
+
+                timeout.tv_sec = 1;
+                timeout.tv_usec = 0;
+
+                ret = select(sockfd + 1, NULL, &writefds, NULL, &timeout);
+                if (ret < 0) {
+                    INFO("not possible to send data\n");
+                    break;
+                }
+                TRACE("possible to send data\n");
+                continue;
+            }
+
             ERR("failed to send a message. sent_size: %d\n", sent_size);
-            g_free(buf);
             ret = false;
             break;
         }
 
         TRACE("sent size: %d\n", sent_size);
+        buf_offset += sent_size;
+        total_buf_size -= sent_size;
+    } while (total_buf_size > 0);
 
-        total_sent_size += sent_size;
-    } while (total_sent_size != payload_size);
-
-    INFO("sent packets: %d, payload_size %d\n", total_sent_size, payload_size);
+    TRACE("sent packets: %d, payload_size %d\n", (payload_size - total_buf_size), payload_size);
     g_free(buf);
 
     return ret;
 }
 
-#if 1
 static bool send_handshake_req_msg(void)
 {
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
@@ -193,9 +249,7 @@ static bool send_handshake_req_msg(void)
 
     return true;
 }
-#endif
 
-#if 0
 static bool send_emul_state_msg(void)
 {
     Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
@@ -203,7 +257,7 @@ static bool send_emul_state_msg(void)
 
     TRACE("enter: %s\n", __func__);
 
-    emul_state.state = TETHERING__CONNECTION_STATE__TERMINATE;
+    emul_state.state = TETHERING__CONNECTION_STATE__DISCONNECTED;
 
     msg.type = TETHERING__TETHERING_MSG__TYPE__EMUL_STATE;
     msg.emulstate = &emul_state;
@@ -215,8 +269,8 @@ static bool send_emul_state_msg(void)
 
     return true;
 }
-#endif
 
+// event messages
 static bool build_event_msg(Tethering__EventMsg *event)
 {
     bool ret = false;
@@ -278,261 +332,7 @@ static bool send_set_event_status_msg(Tethering__EventType event_type,
     return ret;
 }
 
-
-// create a sensor message.
-static bool build_sensor_msg(Tethering__SensorMsg *sensor)
-{
-    bool ret = false;
-    Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    msg.type = TETHERING__TETHERING_MSG__TYPE__SENSOR_MSG;
-    msg.sensormsg = sensor;
-
-    ret = send_msg_to_controller(&msg);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
-static bool send_sensor_start_ans_msg(Tethering__MessageResult result)
-{
-    bool ret = false;
-    Tethering__SensorMsg event = TETHERING__SENSOR_MSG__INIT;
-    Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    start_ans.result = result;
-
-    event.type = TETHERING__SENSOR_MSG__TYPE__START_ANS;
-    event.startans = &start_ans;
-
-    TRACE("send sensor_start_ans message\n");
-    ret = build_sensor_msg(&event);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
-static bool send_set_sensor_status_msg(Tethering__SensorType sensor_type,
-                                    Tethering__State status)
-{
-    bool ret = false;
-
-    Tethering__SensorMsg sensor = TETHERING__SENSOR_MSG__INIT;
-    Tethering__SetSensorStatus sensor_status =
-                            TETHERING__SET_SENSOR_STATUS__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    sensor_status.type = sensor_type;
-    sensor_status.state = status;
-
-    sensor.type = TETHERING__SENSOR_MSG__TYPE__SENSOR_STATUS;
-    sensor.setstatus = &sensor_status;
-
-    TRACE("send sensor_set_event_status message\n");
-    ret = build_sensor_msg(&sensor);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
-static void set_sensor_data(Tethering__SensorData *data)
-{
-    /*
-     * data format for sensor device
-     * each value is classified by carriage return character
-     * sensor_type/param numbers/parameters
-     * ex) acceleration sensor: "level_accel\n3\nx\ny\nz\n"
-     */
-
-    switch(data->sensor) {
-    case TETHERING__SENSOR_TYPE__ACCEL:
-    {
-        char tmp[255] = {0};
-
-        sprintf(tmp, "%d\n%d\n%s\n%s\n%s\n",
-                level_accel, 3, data->x, data->y, data->z);
-        send_tethering_sensor_data(tmp, strlen(tmp));
-
-        TRACE("sensor_accel x: %s, y: %s, z: %s\n",
-            data->x, data->y, data->z);
-    }
-        break;
-    case TETHERING__SENSOR_TYPE__MAGNETIC:
-    {
-        char tmp[255] = {0};
-
-        sprintf(tmp, "%d\n%d\n%s\n%s\n%s\n",
-                level_magnetic, 3, data->x, data->y, data->z);
-        send_tethering_sensor_data(tmp, strlen(tmp));
-
-        TRACE("sensor_mag x: %s, y: %s, z: %s\n",
-            data->x, data->y, data->z);
-    }
-        break;
-    case TETHERING__SENSOR_TYPE__GYROSCOPE:
-    {
-        char tmp[255] = {0};
-
-        sprintf(tmp, "%d\n%d\n%s\n%s\n%s\n",
-                level_gyro, 3, data->x, data->y, data->z);
-        send_tethering_sensor_data(tmp, strlen(tmp));
-
-        TRACE("sensor_gyro x: %s, y: %s, z: %s\n",
-            data->x, data->y, data->z);
-    }
-        break;
-    case TETHERING__SENSOR_TYPE__PROXIMITY:
-    {
-        char tmp[255] = {0};
-        double x = (double)(atoi(data->x));
-
-        sprintf(tmp, "%d\n%d\n%.1f\n", level_proxi, 1, x);
-        send_tethering_sensor_data(tmp, strlen(tmp));
-
-        TRACE("sensor_proxi x: %.1f, %s\n", x, tmp);
-    }
-        break;
-    case TETHERING__SENSOR_TYPE__LIGHT:
-    {
-        char tmp[255] = {0};
-
-        sprintf(tmp, "%d\n%d\n%s%s\n", level_light, 2, data->x, data->y);
-        send_tethering_sensor_data(tmp, strlen(tmp));
-
-        TRACE("sensor_light x: %s\n", data->x);
-    }
-        break;
-    default:
-        TRACE("invalid sensor data\n");
-        break;
-    }
-}
-
-static bool build_multitouch_msg(Tethering__MultiTouchMsg *multitouch)
-{
-    bool ret = false;
-    Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    msg.type = TETHERING__TETHERING_MSG__TYPE__TOUCH_MSG;
-    msg.touchmsg = multitouch;
-
-    INFO("touch message size: %d\n", tethering__tethering_msg__get_packed_size(&msg));
-
-    ret = send_msg_to_controller(&msg);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
-static bool send_multitouch_start_ans_msg(Tethering__MessageResult result)
-{
-    bool ret = false;
-
-    Tethering__MultiTouchMsg mt = TETHERING__MULTI_TOUCH_MSG__INIT;
-    Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    start_ans.result = result;
-
-    mt.type = TETHERING__MULTI_TOUCH_MSG__TYPE__START_ANS;
-    mt.startans = &start_ans;
-
-    ret = build_multitouch_msg(&mt);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
-static bool send_set_multitouch_max_count(void)
-{
-    bool ret = false;
-
-    Tethering__MultiTouchMsg mt = TETHERING__MULTI_TOUCH_MSG__INIT;
-    Tethering__MultiTouchMaxCount touch_cnt =
-        TETHERING__MULTI_TOUCH_MAX_COUNT__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    touch_cnt.max = get_emul_max_touch_point();
-
-    mt.type = TETHERING__MULTI_TOUCH_MSG__TYPE__MAX_COUNT;
-    mt.maxcount = &touch_cnt;
-
-    INFO("send multi-touch max count: %d\n", touch_cnt.max);
-    ret = build_multitouch_msg(&mt);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
-static void set_multitouch_data(Tethering__MultiTouchData *data)
-{
-    float x = 0.0, y = 0.0;
-    int32_t index = 0, state = 0;
-
-    switch(data->state) {
-    case TETHERING__TOUCH_STATE__PRESSED:
-        TRACE("touch pressed\n");
-        index = data->index;
-        x = data->xpoint;
-        y = data->ypoint;
-        state = PRESSED;
-        break;
-    case TETHERING__TOUCH_STATE__RELEASED:
-        TRACE("touch released\n");
-        index = data->index;
-        x = data->xpoint;
-        y = data->ypoint;
-        state = RELEASED;
-        break;
-    default:
-        TRACE("invalid multitouch data\n");
-        break;
-    }
-
-    INFO("set touch_data. index: %d, x: %lf, y: %lf\n", index, x, y);
-    // set ecs_multitouch
-    send_tethering_touch_data(x, y, index, state);
-}
-
-static bool send_set_multitouch_resolution(void)
-{
-    bool ret = false;
-
-    Tethering__MultiTouchMsg mt = TETHERING__MULTI_TOUCH_MSG__INIT;
-    Tethering__Resolution resolution = TETHERING__RESOLUTION__INIT;
-
-    TRACE("enter: %s\n", __func__);
-
-    resolution.width = get_emul_resolution_width();
-    resolution.height = get_emul_resolution_height();
-
-    mt.type = TETHERING__MULTI_TOUCH_MSG__TYPE__RESOLUTION;
-    mt.resolution = &resolution;
-
-    INFO("send multi-touch resolution: %dx%d\n",
-        resolution.width, resolution.height);
-    ret = build_multitouch_msg(&mt);
-
-    TRACE("leave: %s, ret: %d\n", __func__, ret);
-
-    return ret;
-}
-
+// message handlers
 static void msgproc_tethering_handshake_ans(Tethering__HandShakeAns *msg)
 {
     // FIXME: handle handshake answer
@@ -541,12 +341,14 @@ static void msgproc_tethering_handshake_ans(Tethering__HandShakeAns *msg)
 
 static void msgproc_app_state_msg(Tethering__AppState *msg)
 {
+    int status = TETHERING__STATE__DISABLED;
+
     if (msg->state == TETHERING__CONNECTION_STATE__TERMINATED) {
-        INFO("App is terminated\n");
+        INFO("app is terminated\n");
 
-//      set_tethering_app_state(false);
-        set_tethering_sensor_status(DISABLED);
-        set_tethering_multitouch_status(DISABLED);
+        // set_tethering_app_state(false);
+        set_tethering_sensor_status(status);
+        set_tethering_touch_status(status);
 
         disconnect_tethering_app();
     } else {
@@ -554,7 +356,6 @@ static void msgproc_app_state_msg(Tethering__AppState *msg)
     }
 }
 
-
 static bool msgproc_tethering_event_msg(Tethering__EventMsg *msg)
 {
     bool ret = true;
@@ -569,15 +370,17 @@ static bool msgproc_tethering_event_msg(Tethering__EventMsg *msg)
                                 TETHERING__STATE__ENABLED);
 
         // TODO: check sensor device whether it exists or not
-        set_tethering_sensor_status(ENABLED);
+        // set_tethering_sensor_status(ENABLED);
+        set_tethering_sensor_status(TETHERING__STATE__ENABLED);
 
         if (is_emul_input_touch_enable()) {
             touch_status = TETHERING__STATE__ENABLED;
-            set_tethering_multitouch_status(ENABLED);
+            // set_tethering_touch_status(ENABLED);
         } else {
             touch_status = TETHERING__STATE__DISABLED;
-            set_tethering_multitouch_status(DISABLED);
+            // set_tethering_touch_status(DISABLED);
         }
+        set_tethering_touch_status(touch_status);
 
         TRACE("send multi-touch event_status msg: %d\n", touch_status);
         send_set_event_status_msg(TETHERING__EVENT_TYPE__TOUCH, touch_status);
@@ -597,75 +400,6 @@ static bool msgproc_tethering_event_msg(Tethering__EventMsg *msg)
     return ret;
 }
 
-static bool msgproc_tethering_sensor_msg(Tethering__SensorMsg *msg)
-{
-    bool ret = true;
-
-    switch(msg->type) {
-    case TETHERING__SENSOR_MSG__TYPE__START_REQ:
-        TRACE("SENSOR_MSG_TYPE_START_REQ\n");
-
-        // set sensor type.
-        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__ACCEL,
-                                TETHERING__STATE__ENABLED);
-        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__MAGNETIC,
-                                TETHERING__STATE__ENABLED);
-        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__GYROSCOPE,
-                                TETHERING__STATE__ENABLED);
-        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__PROXIMITY,
-                                TETHERING__STATE__ENABLED);
-        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__LIGHT,
-                                TETHERING__STATE__ENABLED);
-
-        TRACE("SENSOR_MSG_TYPE_START_ANS\n");
-        send_sensor_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
-
-        break;
-    case TETHERING__SENSOR_MSG__TYPE__TERMINATE:
-        TRACE("SENSOR_MSG_TYPE_TERMINATE\n");
-        break;
-
-    case TETHERING__SENSOR_MSG__TYPE__SENSOR_DATA:
-        TRACE("SENSOR_MSG_TYPE_SENSOR_DATA\n");
-        set_sensor_data(msg->data);
-        break;
-    default:
-        TRACE("invalid sensor_msg type");
-        ret = false;
-        break;
-    }
-
-    return ret;
-}
-
-static bool msgproc_tethering_mt_msg(Tethering__MultiTouchMsg *msg)
-{
-    bool ret = true;
-
-    switch(msg->type) {
-    case TETHERING__MULTI_TOUCH_MSG__TYPE__START_REQ:
-        TRACE("TOUCH_MSG_TYPE_START\n");
-
-        send_set_multitouch_max_count();
-        send_set_multitouch_resolution();
-
-        ret = send_multitouch_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
-        break;
-    case TETHERING__MULTI_TOUCH_MSG__TYPE__TERMINATE:
-        TRACE("TOUCH_MSG_TYPE_TERMINATE\n");
-        break;
-    case TETHERING__MULTI_TOUCH_MSG__TYPE__TOUCH_DATA:
-        set_multitouch_data(msg->touchdata);
-        break;
-    default:
-        TRACE("invalid multitouch_msg\n");
-        ret = false;
-        break;
-    }
-
-    return ret;
-}
-
 static bool handle_tethering_msg_from_controller(char *data, int len)
 {
     Tethering__TetheringMsg *tethering = NULL;
@@ -675,7 +409,6 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
                                             (const uint8_t *)data);
 
     if (!tethering) {
-        // error message
         ERR("no tethering massage\n");
         return false;
     }
@@ -689,7 +422,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
             ret = false;
         } else {
             msgproc_tethering_handshake_ans(msg);
-            INFO("receive handshake answer\n");
+            TRACE("receive handshake answer\n");
 
             set_tethering_connection_status(CONNECTED);
         }
@@ -699,7 +432,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__AppState *msg = tethering->appstate;
 
-        INFO("receive app_state msg\n");
+        TRACE("receive app_state msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -711,7 +444,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__EventMsg *msg = tethering->eventmsg;
 
-        INFO("receive event_msg\n");
+        TRACE("receive event_msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -723,7 +456,7 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
     {
         Tethering__SensorMsg *msg = tethering->sensormsg;
 
-        INFO("receive sensor_msg\n");
+        TRACE("receive sensor_msg\n");
         if (!msg) {
             ret = false;
         } else {
@@ -733,28 +466,39 @@ static bool handle_tethering_msg_from_controller(char *data, int len)
         break;
     case TETHERING__TETHERING_MSG__TYPE__TOUCH_MSG:
     {
-        Tethering__MultiTouchMsg *msg = tethering->touchmsg;
+        Tethering__TouchMsg *msg = tethering->touchmsg;
+
+        TRACE("receive touch_msg\n");
+        if (!msg) {
+            ret = false;
+        } else {
+            msgproc_tethering_touch_msg(msg);
+        }
+    }
+        break;
+
+#if 0
+    case TETHERING__TETHERING_MSG__TYPE__DISPLAY_MSG:
+    {
+        Tethering__DisplayMsg *msg = tethering->displaymsg;
 
-        INFO("receive multitouch_msg\n");
+        TRACE("receive display_msg\n");
         if (!msg) {
             ret = false;
         } else {
-            msgproc_tethering_mt_msg(msg);
+            msgproc_tethering_display_msg(msg);
         }
     }
         break;
+#endif
+
     default:
         TRACE("invalid type message\n");
         ret = false;
         break;
     }
 
-#if 1
-    if (data) {
-        g_free(data);
-    }
-#endif
-
+//    g_free(data);
     tethering__tethering_msg__free_unpacked(tethering, NULL);
     return ret;
 }
@@ -765,17 +509,21 @@ static void reset_tethering_recv_buf(void *opaque)
 }
 
 // tethering client socket
-static void tethering_io_handler(int sockfd)
+static void tethering_io_handler(void *opaque)
 {
-    int ret = 0;
     int payloadsize = 0, read_size = 0;
     int to_read_bytes = 0;
+    int sockfd = 0, ret = 0;
+
+    if (!tethering_client) {
+        return;
+    }
+    sockfd = tethering_client->fd;
 
 #ifndef CONFIG_WIN32
     ret = ioctl(sockfd, FIONREAD, &to_read_bytes);
     if (ret < 0) {
         perror("invalid ioctl opertion\n");
-
         disconnect_tethering_app();
         return;
     }
@@ -785,7 +533,6 @@ static void tethering_io_handler(int sockfd)
     ret = ioctlsocket(sockfd, FIONREAD, &to_read_bytes_long);
     if (ret < 0) {
         perror("invalid ioctl opertion\n");
-
         disconnect_tethering_app();
         return;
     }
@@ -800,6 +547,7 @@ static void tethering_io_handler(int sockfd)
         return;
     }
 
+    // TODO: why this conditional is used??
     if (recv_buf.len == 0) {
         ret = qemu_recv(sockfd, &payloadsize, sizeof(payloadsize), 0);
         if (ret < sizeof(payloadsize)) {
@@ -832,23 +580,26 @@ static void tethering_io_handler(int sockfd)
         ERR("failed to read data\n");
         disconnect_tethering_app();
         return;
-    } else {
-        recv_buf.stack_size += read_size;
     }
 
+    recv_buf.stack_size += read_size;
+
     if (recv_buf.len == recv_buf.stack_size) {
         char *snd_buf = NULL;
-        int snd_buf_size = recv_buf.stack_size;
 
-        snd_buf = g_malloc(snd_buf_size);
-        memcpy(snd_buf, recv_buf.data, snd_buf_size);
-        reset_tethering_recv_buf(&recv_buf);
-
-        handle_tethering_msg_from_controller(snd_buf, snd_buf_size);
-        g_free(snd_buf);
+        snd_buf = g_malloc(recv_buf.stack_size);
+        if (!snd_buf) {
+            return;
+        } else {
+            memcpy(snd_buf, recv_buf.data, recv_buf.stack_size);
+            handle_tethering_msg_from_controller(snd_buf, recv_buf.stack_size);
+            g_free(snd_buf);
+            reset_tethering_recv_buf(&recv_buf);
+        }
     }
 }
 
+// socket functions
 static int start_tethering_socket(const char *ipaddress, int port)
 {
     struct sockaddr_in addr;
@@ -868,7 +619,6 @@ static int start_tethering_socket(const char *ipaddress, int port)
     }
 
     INFO("server ip address: %s, port: %d\n", serveraddr, port);
-
     ret = inet_aton(serveraddr, &addr.sin_addr);
 
     if (ret == 0) {
@@ -890,7 +640,6 @@ static int start_tethering_socket(const char *ipaddress, int port)
     do {
         if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
             perror("connect failure");
-            INFO("tethering socket is connecting.\n");
             ret = -socket_error();
         } else {
             INFO("tethering socket is connected.\n");
@@ -898,7 +647,7 @@ static int start_tethering_socket(const char *ipaddress, int port)
             // set_tethering_app_state(true);
             break;
         }
-        INFO("ret: %d\n", ret);
+        TRACE("ret: %d\n", ret);
     } while (ret == -EINPROGRESS);
 
     if (ret < 0 && ret != -EISCONN) {
@@ -911,13 +660,13 @@ static int start_tethering_socket(const char *ipaddress, int port)
         sock = -1;
     }
 
-    // qemu_set_block(sock);
-
     return sock;
 }
 
 static void end_tethering_socket(int sockfd)
 {
+    int status = TETHERING__STATE__DISABLED;
+
     if (closesocket(sockfd) < 0) {
         perror("closesocket failure");
         return;
@@ -927,8 +676,8 @@ static void end_tethering_socket(int sockfd)
 
     INFO("close tethering socket\n");
     set_tethering_connection_status(DISCONNECTED);
-    set_tethering_sensor_status(DISABLED);
-    set_tethering_multitouch_status(DISABLED);
+    set_tethering_sensor_status(status);
+    set_tethering_touch_status(status);
 }
 
 #if 0
@@ -947,84 +696,39 @@ static bool get_tethering_app_state(void)
 // ecs <-> tethering
 int get_tethering_connection_status(void)
 {
+    int status = 0;
+
     if (!tethering_client) {
         return -1;
     }
 
-    return tethering_client->status;
+    qemu_mutex_lock(&tethering_client->mutex);
+    status = tethering_client->status;
+    qemu_mutex_unlock(&tethering_client->mutex);
+
+    return status;
 }
 
 static void set_tethering_connection_status(int status)
 {
-
     if (!tethering_client) {
         return;
     }
 
-    if (status) {
-        INFO("connection status: %s\n", connection_status_str[status - 1]);
-    }
-
+    qemu_mutex_lock(&tethering_client->mutex);
     tethering_client->status = status;
+    qemu_mutex_unlock(&tethering_client->mutex);
 
     send_tethering_connection_status_ecp();
 }
 
-int get_tethering_sensor_status(void)
-{
-    return sensor_device_status;
-}
-
-static void set_tethering_sensor_status(int status)
-{
-    sensor_device_status = status;
-    send_tethering_sensor_status_ecp();
-}
-
-int get_tethering_multitouch_status(void)
-{
-    return mt_device_status;
-}
-
-static void set_tethering_multitouch_status(int status)
-{
-    mt_device_status = status;
-    send_tethering_touch_status_ecp();
-}
-
-int disconnect_tethering_app(void)
-{
-    int sock = 0;
-
-    INFO("disconnect app from ecp\n");
-    if (!tethering_client) {
-        return -1;
-    }
-
-    sock = tethering_client->fd;
-    if (sock < 0) {
-        ERR("tethering socket is terminated or not ready\n");
-    } else {
-#if 0
-        if (get_tethering_app_state()) {
-            send_emul_state_msg();
-        }
-#endif
-        end_tethering_socket(sock);
-    }
-
-    g_free(tethering_client->ipaddress);
-    g_free(tethering_client);
-
-    return 0;
-}
-
 static void tethering_notify_exit(Notifier *notifier, void *data) {
     disconnect_tethering_app();
 }
 static Notifier tethering_exit = { .notify = tethering_notify_exit };
 
 static void *initialize_tethering_socket(void *opaque);
+// static void release_tethering_thread(void *opaque);
 
 int connect_tethering_app(const char *ipaddress, int port)
 {
@@ -1055,15 +759,45 @@ int connect_tethering_app(const char *ipaddress, int port)
 
     tethering_client = client;
 
+    qemu_mutex_init(&tethering_client->mutex);
+
     qemu_thread_create(&tethering_client->thread, "tethering-io-thread",
-            initialize_tethering_socket, client, QEMU_THREAD_DETACHED);
+            initialize_tethering_socket, client,
+            QEMU_THREAD_DETACHED);
+
+    return 0;
+}
+
+int disconnect_tethering_app(void)
+{
+    int sock = 0;
+
+    INFO("disconnect app from ecp\n");
+    if (!tethering_client) {
+        return -1;
+    }
+
+    sock = tethering_client->fd;
+    if (sock < 0) {
+        ERR("tethering socket is terminated or not ready\n");
+    } else {
+        // destroy_tethering_io_handler(sock);
+#if 0
+        if (get_tethering_app_state()) {
+            send_emul_state_msg();
+        }
+#endif
+        send_emul_state_msg();
+
+        end_tethering_socket(sock);
+        // release_tethering_thread(tethering_client);
+    }
 
     return 0;
 }
 
-static int tethering_loop(TetheringState *client)
+static int tethering_loop(int sockfd)
 {
-    int sockfd = client->fd;
     int ret = 0;
     fd_set readfds;
     struct timeval timeout;
@@ -1079,7 +813,7 @@ static int tethering_loop(TetheringState *client)
 
     if (ret > 0) {
         TRACE("ready for read operation!!\n");
-        tethering_io_handler(sockfd);
+        tethering_io_handler(socket);
     }
 
     return ret;
@@ -1098,6 +832,7 @@ static void *initialize_tethering_socket(void *opaque)
     socket->fd = start_tethering_socket(socket->ipaddress, socket->port);
     if (socket->fd < 0) {
         ERR("failed to start tethering_socket\n");
+        // tethering_sock = -1;
         return NULL;
     }
 
@@ -1109,13 +844,25 @@ static void *initialize_tethering_socket(void *opaque)
     emulator_add_exit_notifier(&tethering_exit);
 
     while (1) {
+        qemu_mutex_lock(&socket->mutex);
         if (socket->status == DISCONNECTED) {
+            qemu_mutex_unlock(&socket->mutex);
             INFO("disconnected socket. destroy this thread\n");
             break;
         }
+        qemu_mutex_unlock(&socket->mutex);
 
-        tethering_loop(socket);
+        tethering_loop(socket->fd);
     }
 
     return socket;
 }
+
+#if 0
+static void release_tethering_thread(void *opaque)
+{
+    TetheringState *client = (TetheringState *)opaque;
+
+    qemu_thread_join(&client->thread);
+}
+#endif
similarity index 85%
rename from tizen/src/tethering/app_tethering.h
rename to tizen/src/tethering/common.h
index c2ba1d2..c9c2892 100644 (file)
  *
  */
 
+typedef struct input_device_list {
+    int type;
+    void *opaque;
+
+    QTAILQ_ENTRY(input_device_list) node;
+} input_device_list;
+
+// common
 enum connection_status {
     CONNECTED = 1,
     DISCONNECTED,
@@ -35,22 +43,17 @@ enum connection_status {
     CONNREFUSED,
 };
 
-enum device_status {
-    ENABLED = 1,
-    DISABLED,
-};
-
 enum touch_status {
     RELEASED = 0,
     PRESSED,
 };
 
+bool send_msg_to_controller(void *msg);
+
 int connect_tethering_app(const char *ipaddress, int port);
 
 int disconnect_tethering_app(void);
 
 int get_tethering_connection_status(void);
 
-int get_tethering_sensor_status(void);
-
-int get_tethering_multitouch_status(void);
+int add_input_device(void *opaque);
diff --git a/tizen/src/tethering/encode_fb.c b/tizen/src/tethering/encode_fb.c
new file mode 100644 (file)
index 0000000..a8f4603
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * emulator controller client
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Kitae Kim <kt920.kim@samsung.com>
+ *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <png.h>
+#ifdef CONFIG_WEBP
+#include <webp/types.h>
+#include <webp/encode.h>
+#endif
+
+#include "emul_state.h"
+#include "skin/maruskin_operation.h"
+#include "encode_fb.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+
+#ifdef CONFIG_WEBP
+static void *encode_webp(void);
+#endif
+static void *encode_png(void);
+
+void *encode_framebuffer(int encoder)
+{
+    void *output = NULL;
+
+#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG)
+    struct timespec start, end;
+
+    clock_gettime(CLOCK_MONOTONIC, &start);
+#endif
+
+#ifdef CONFIG_WEBP
+    if (encoder == 0) {
+        output = encode_webp();
+    } else if (encoder == 1) {
+        output = encode_png();
+    }
+#else
+    output = encode_png();
+#endif
+
+#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG)
+    clock_gettime(CLOCK_MONOTONIC, &end);
+
+    INFO("encoding time: %.5f seconds\n",
+        ((double)end.tv_sec + (1.0e-9 * end.tv_nsec)) -
+        ((double)start.tv_sec + (1.0e-9 * start.tv_nsec)));
+#endif
+
+    return output;
+}
+
+static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t len)
+{
+    struct encode_mem *p = (struct encode_mem *)png_get_io_ptr(png_ptr);
+    size_t nsize = p->length + len;
+
+    if (p->buffer) {
+        p->buffer = g_realloc(p->buffer, nsize);
+    } else {
+        p->buffer = g_malloc(nsize);
+    }
+
+    if (!p->buffer) {
+        ERR("failed to allocate \n");
+    }
+
+    memcpy(p->buffer + p->length, data, len);
+    p->length += len;
+}
+
+static void user_flush_data(png_structp png_ptr)
+{
+}
+
+static void *encode_png(void)
+{
+    int width = 0, height = 0, image_stride = 0;
+    int row_index;
+    /*
+     * bit_depth: depending on color type
+     * in case of RGB_ALPHA, 8 or 16
+     */
+    int bit_depth = 8;
+    struct encode_mem *container = NULL;
+
+    png_structp png_ptr = NULL;
+    png_infop info_ptr = NULL;
+    png_bytepp row_pointers = NULL;
+
+    Framebuffer *surface = NULL;
+
+    surface = request_screenshot();
+    if (!surface) {
+        ERR("failed to get framebuffer\n");
+        return NULL;
+    }
+
+    width = get_emul_resolution_width();
+    height = get_emul_resolution_height();
+
+    image_stride = width * 4;
+    TRACE("width %d, height %d, stride %d, raw image %d\n",
+        width, height, image_stride, (image_stride * height));
+
+    TRACE("png_create_write_struct\n");
+    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+    if (!png_ptr) {
+        ERR("png_create_write_struct failure\n");
+        g_free(surface->data);
+        g_free(surface);
+        return NULL;
+    }
+
+    TRACE("png_create_info_struct\n");
+    info_ptr = png_create_info_struct(png_ptr);
+    if (!png_ptr) {
+        ERR("png_create_info_struct failure\n");
+        g_free(surface->data);
+        g_free(surface);
+        png_destroy_write_struct(&png_ptr, &info_ptr);
+        return NULL;
+    }
+
+    TRACE("try png_jmpbuf\n");
+    if (setjmp(png_jmpbuf(png_ptr))) {
+        ERR("png_jmpbuf failure\n");
+        g_free(surface->data);
+        g_free(surface);
+        png_destroy_write_struct(&png_ptr, &info_ptr);
+        png_destroy_info_struct(png_ptr, &info_ptr);
+        return NULL;
+    }
+
+    TRACE("png_init_io\n");
+    container = g_malloc(sizeof(struct encode_mem));
+    if (!container) {
+        ERR("failed to allocate encode_mem\n");
+        g_free(surface->data);
+        g_free(surface);
+        png_destroy_write_struct(&png_ptr, &info_ptr);
+        png_destroy_info_struct(png_ptr, &info_ptr);
+        return NULL;
+    }
+
+    container->buffer = NULL;
+    container->length = 0;
+
+    png_set_write_fn(png_ptr, container, user_write_data, user_flush_data);
+
+    // set image attributes
+    png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
+        PNG_COLOR_TYPE_RGB_ALPHA,
+        PNG_INTERLACE_NONE,
+        PNG_COMPRESSION_TYPE_DEFAULT,
+        PNG_FILTER_TYPE_DEFAULT);
+
+    png_write_info(png_ptr, info_ptr);
+
+    // Filp BGR pixels to RGB
+    png_set_bgr(png_ptr);
+
+    row_pointers = png_malloc(png_ptr, sizeof(png_bytep) * height);
+    if (row_pointers == NULL) {
+        ERR("failed to allocate png memory\n");
+        g_free(surface->data);
+        g_free(surface);
+        png_destroy_write_struct(&png_ptr, &info_ptr);
+        png_destroy_info_struct(png_ptr, &info_ptr);
+        return NULL;
+    }
+
+    for (row_index = 0; row_index < height; row_index++) {
+        row_pointers[row_index] = surface->data + (row_index * image_stride);
+    }
+
+    TRACE("png_write_image\n");
+    png_write_image(png_ptr, row_pointers);
+
+    TRACE("png_write_end\n");
+    png_write_end(png_ptr, info_ptr);
+
+    g_free(surface->data);
+    g_free(surface);
+
+    TRACE("png image size %d\n", container->length);
+    png_destroy_write_struct(&png_ptr, &info_ptr);
+    png_destroy_info_struct(png_ptr, &info_ptr);
+
+    return container;
+}
+
+#ifdef CONFIG_WEBP
+static void *encode_webp(void)
+{
+    int width = 0, height = 0, image_stride = 0;
+    // float quality = 0;
+    size_t ret = 0;
+
+    struct encode_mem *container = NULL;
+    Framebuffer *surface = NULL;
+
+    container = g_malloc(sizeof(struct encode_mem));
+    if (!container) {
+        ERR("failed to allocate encode_mem\n");
+        return NULL;
+    }
+
+    container->buffer = NULL;
+    container->length = 0;
+
+    surface = request_screenshot();
+    if (!surface) {
+        ERR("failed to get framebuffer\n");
+        g_free(container);
+        return NULL;
+    }
+
+    width = get_emul_resolution_width();
+    height = get_emul_resolution_height();
+
+    image_stride = width * 4;
+    TRACE("width %d, height %d, stride %d, raw image %d\n",
+        width, height, image_stride, (image_stride * height));
+
+    ret = WebPEncodeLosslessBGRA((const uint8_t *)surface->data, width,
+            height, image_stride, &container->buffer);
+    TRACE("lossless encode framebuffer via webp. result %zu\n", ret);
+
+    container->length = (int)ret;
+
+    g_free(surface->data);
+    g_free(surface);
+
+    return container;
+}
+#endif
diff --git a/tizen/src/tethering/encode_fb.h b/tizen/src/tethering/encode_fb.h
new file mode 100644 (file)
index 0000000..235f782
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * emulator controller client
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Kitae Kim <kt920.kim@samsung.com>
+ *  JiHye Kim <jihye1128.kim@samsung.com>
+ *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <time.h>
+
+struct encode_mem {
+    uint8_t *buffer;
+    uint32_t length;
+};
+
+void *encode_framebuffer(int encoder);
index fe58d32..0620a77 100644 (file)
@@ -608,133 +608,133 @@ void   tethering__display_msg__free_unpacked
   PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__display_msg__descriptor);
   protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
 }
-void   tethering__multi_touch_max_count__init
-                     (Tethering__MultiTouchMaxCount         *message)
+void   tethering__touch_max_count__init
+                     (Tethering__TouchMaxCount         *message)
 {
-  static Tethering__MultiTouchMaxCount init_value = TETHERING__MULTI_TOUCH_MAX_COUNT__INIT;
+  static Tethering__TouchMaxCount init_value = TETHERING__TOUCH_MAX_COUNT__INIT;
   *message = init_value;
 }
-size_t tethering__multi_touch_max_count__get_packed_size
-                     (const Tethering__MultiTouchMaxCount *message)
+size_t tethering__touch_max_count__get_packed_size
+                     (const Tethering__TouchMaxCount *message)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_max_count__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_max_count__descriptor);
   return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
 }
-size_t tethering__multi_touch_max_count__pack
-                     (const Tethering__MultiTouchMaxCount *message,
+size_t tethering__touch_max_count__pack
+                     (const Tethering__TouchMaxCount *message,
                       uint8_t       *out)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_max_count__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_max_count__descriptor);
   return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
 }
-size_t tethering__multi_touch_max_count__pack_to_buffer
-                     (const Tethering__MultiTouchMaxCount *message,
+size_t tethering__touch_max_count__pack_to_buffer
+                     (const Tethering__TouchMaxCount *message,
                       ProtobufCBuffer *buffer)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_max_count__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_max_count__descriptor);
   return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
 }
-Tethering__MultiTouchMaxCount *
-       tethering__multi_touch_max_count__unpack
+Tethering__TouchMaxCount *
+       tethering__touch_max_count__unpack
                      (ProtobufCAllocator  *allocator,
                       size_t               len,
                       const uint8_t       *data)
 {
-  return (Tethering__MultiTouchMaxCount *)
-     protobuf_c_message_unpack (&tethering__multi_touch_max_count__descriptor,
+  return (Tethering__TouchMaxCount *)
+     protobuf_c_message_unpack (&tethering__touch_max_count__descriptor,
                                 allocator, len, data);
 }
-void   tethering__multi_touch_max_count__free_unpacked
-                     (Tethering__MultiTouchMaxCount *message,
+void   tethering__touch_max_count__free_unpacked
+                     (Tethering__TouchMaxCount *message,
                       ProtobufCAllocator *allocator)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_max_count__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_max_count__descriptor);
   protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
 }
-void   tethering__multi_touch_data__init
-                     (Tethering__MultiTouchData         *message)
+void   tethering__touch_data__init
+                     (Tethering__TouchData         *message)
 {
-  static Tethering__MultiTouchData init_value = TETHERING__MULTI_TOUCH_DATA__INIT;
+  static Tethering__TouchData init_value = TETHERING__TOUCH_DATA__INIT;
   *message = init_value;
 }
-size_t tethering__multi_touch_data__get_packed_size
-                     (const Tethering__MultiTouchData *message)
+size_t tethering__touch_data__get_packed_size
+                     (const Tethering__TouchData *message)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_data__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_data__descriptor);
   return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
 }
-size_t tethering__multi_touch_data__pack
-                     (const Tethering__MultiTouchData *message,
+size_t tethering__touch_data__pack
+                     (const Tethering__TouchData *message,
                       uint8_t       *out)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_data__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_data__descriptor);
   return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
 }
-size_t tethering__multi_touch_data__pack_to_buffer
-                     (const Tethering__MultiTouchData *message,
+size_t tethering__touch_data__pack_to_buffer
+                     (const Tethering__TouchData *message,
                       ProtobufCBuffer *buffer)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_data__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_data__descriptor);
   return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
 }
-Tethering__MultiTouchData *
-       tethering__multi_touch_data__unpack
+Tethering__TouchData *
+       tethering__touch_data__unpack
                      (ProtobufCAllocator  *allocator,
                       size_t               len,
                       const uint8_t       *data)
 {
-  return (Tethering__MultiTouchData *)
-     protobuf_c_message_unpack (&tethering__multi_touch_data__descriptor,
+  return (Tethering__TouchData *)
+     protobuf_c_message_unpack (&tethering__touch_data__descriptor,
                                 allocator, len, data);
 }
-void   tethering__multi_touch_data__free_unpacked
-                     (Tethering__MultiTouchData *message,
+void   tethering__touch_data__free_unpacked
+                     (Tethering__TouchData *message,
                       ProtobufCAllocator *allocator)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_data__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_data__descriptor);
   protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
 }
-void   tethering__multi_touch_msg__init
-                     (Tethering__MultiTouchMsg         *message)
+void   tethering__touch_msg__init
+                     (Tethering__TouchMsg         *message)
 {
-  static Tethering__MultiTouchMsg init_value = TETHERING__MULTI_TOUCH_MSG__INIT;
+  static Tethering__TouchMsg init_value = TETHERING__TOUCH_MSG__INIT;
   *message = init_value;
 }
-size_t tethering__multi_touch_msg__get_packed_size
-                     (const Tethering__MultiTouchMsg *message)
+size_t tethering__touch_msg__get_packed_size
+                     (const Tethering__TouchMsg *message)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_msg__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_msg__descriptor);
   return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
 }
-size_t tethering__multi_touch_msg__pack
-                     (const Tethering__MultiTouchMsg *message,
+size_t tethering__touch_msg__pack
+                     (const Tethering__TouchMsg *message,
                       uint8_t       *out)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_msg__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_msg__descriptor);
   return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
 }
-size_t tethering__multi_touch_msg__pack_to_buffer
-                     (const Tethering__MultiTouchMsg *message,
+size_t tethering__touch_msg__pack_to_buffer
+                     (const Tethering__TouchMsg *message,
                       ProtobufCBuffer *buffer)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_msg__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_msg__descriptor);
   return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
 }
-Tethering__MultiTouchMsg *
-       tethering__multi_touch_msg__unpack
+Tethering__TouchMsg *
+       tethering__touch_msg__unpack
                      (ProtobufCAllocator  *allocator,
                       size_t               len,
                       const uint8_t       *data)
 {
-  return (Tethering__MultiTouchMsg *)
-     protobuf_c_message_unpack (&tethering__multi_touch_msg__descriptor,
+  return (Tethering__TouchMsg *)
+     protobuf_c_message_unpack (&tethering__touch_msg__descriptor,
                                 allocator, len, data);
 }
-void   tethering__multi_touch_msg__free_unpacked
-                     (Tethering__MultiTouchMsg *message,
+void   tethering__touch_msg__free_unpacked
+                     (Tethering__TouchMsg *message,
                       ProtobufCAllocator *allocator)
 {
-  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__multi_touch_msg__descriptor);
+  PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_msg__descriptor);
   protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
 }
 void   tethering__tethering_msg__init
@@ -1498,23 +1498,11 @@ const ProtobufCMessageDescriptor tethering__resolution__descriptor =
   (ProtobufCMessageInit) tethering__resolution__init,
   NULL,NULL,NULL    /* reserved[123] */
 };
-static const ProtobufCFieldDescriptor tethering__display_msg__field_descriptors[3] =
+static const ProtobufCFieldDescriptor tethering__display_msg__field_descriptors[2] =
 {
   {
-    "onOff",
-    2,
-    PROTOBUF_C_LABEL_REQUIRED,
-    PROTOBUF_C_TYPE_BOOL,
-    0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__DisplayMsg, onoff),
-    NULL,
-    NULL,
-    0,            /* packed */
-    0,NULL,NULL    /* reserved1,reserved2, etc */
-  },
-  {
     "frameRate",
-    3,
+    1,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_INT32,
     PROTOBUF_C_OFFSETOF(Tethering__DisplayMsg, has_framerate),
@@ -1526,7 +1514,7 @@ static const ProtobufCFieldDescriptor tethering__display_msg__field_descriptors[
   },
   {
     "imageData",
-    4,
+    2,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_BYTES,
     PROTOBUF_C_OFFSETOF(Tethering__DisplayMsg, has_imagedata),
@@ -1538,14 +1526,13 @@ static const ProtobufCFieldDescriptor tethering__display_msg__field_descriptors[
   },
 };
 static const unsigned tethering__display_msg__field_indices_by_name[] = {
-  1,   /* field[1] = frameRate */
-  2,   /* field[2] = imageData */
-  0,   /* field[0] = onOff */
+  0,   /* field[0] = frameRate */
+  1,   /* field[1] = imageData */
 };
 static const ProtobufCIntRange tethering__display_msg__number_ranges[1 + 1] =
 {
-  { 2, 0 },
-  { 0, 3 }
+  { 1, 0 },
+  { 0, 2 }
 };
 const ProtobufCMessageDescriptor tethering__display_msg__descriptor =
 {
@@ -1555,66 +1542,66 @@ const ProtobufCMessageDescriptor tethering__display_msg__descriptor =
   "Tethering__DisplayMsg",
   "tethering",
   sizeof(Tethering__DisplayMsg),
-  3,
+  2,
   tethering__display_msg__field_descriptors,
   tethering__display_msg__field_indices_by_name,
   1,  tethering__display_msg__number_ranges,
   (ProtobufCMessageInit) tethering__display_msg__init,
   NULL,NULL,NULL    /* reserved[123] */
 };
-static const int32_t tethering__multi_touch_max_count__max__default_value = 10;
-static const ProtobufCFieldDescriptor tethering__multi_touch_max_count__field_descriptors[1] =
+static const int32_t tethering__touch_max_count__max__default_value = 10;
+static const ProtobufCFieldDescriptor tethering__touch_max_count__field_descriptors[1] =
 {
   {
     "max",
     1,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_INT32,
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMaxCount, has_max),
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMaxCount, max),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMaxCount, has_max),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMaxCount, max),
     NULL,
-    &tethering__multi_touch_max_count__max__default_value,
+    &tethering__touch_max_count__max__default_value,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
 };
-static const unsigned tethering__multi_touch_max_count__field_indices_by_name[] = {
+static const unsigned tethering__touch_max_count__field_indices_by_name[] = {
   0,   /* field[0] = max */
 };
-static const ProtobufCIntRange tethering__multi_touch_max_count__number_ranges[1 + 1] =
+static const ProtobufCIntRange tethering__touch_max_count__number_ranges[1 + 1] =
 {
   { 1, 0 },
   { 0, 1 }
 };
-const ProtobufCMessageDescriptor tethering__multi_touch_max_count__descriptor =
+const ProtobufCMessageDescriptor tethering__touch_max_count__descriptor =
 {
   PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
-  "tethering.MultiTouchMaxCount",
-  "MultiTouchMaxCount",
-  "Tethering__MultiTouchMaxCount",
+  "tethering.TouchMaxCount",
+  "TouchMaxCount",
+  "Tethering__TouchMaxCount",
   "tethering",
-  sizeof(Tethering__MultiTouchMaxCount),
+  sizeof(Tethering__TouchMaxCount),
   1,
-  tethering__multi_touch_max_count__field_descriptors,
-  tethering__multi_touch_max_count__field_indices_by_name,
-  1,  tethering__multi_touch_max_count__number_ranges,
-  (ProtobufCMessageInit) tethering__multi_touch_max_count__init,
+  tethering__touch_max_count__field_descriptors,
+  tethering__touch_max_count__field_indices_by_name,
+  1,  tethering__touch_max_count__number_ranges,
+  (ProtobufCMessageInit) tethering__touch_max_count__init,
   NULL,NULL,NULL    /* reserved[123] */
 };
-static const int32_t tethering__multi_touch_data__index__default_value = 0;
-static const float tethering__multi_touch_data__x_point__default_value = 0;
-static const float tethering__multi_touch_data__y_point__default_value = 0;
-static const ProtobufCFieldDescriptor tethering__multi_touch_data__field_descriptors[4] =
+static const int32_t tethering__touch_data__index__default_value = 0;
+static const float tethering__touch_data__x_point__default_value = 0;
+static const float tethering__touch_data__y_point__default_value = 0;
+static const ProtobufCFieldDescriptor tethering__touch_data__field_descriptors[4] =
 {
   {
     "index",
     1,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_INT32,
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, has_index),
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, index),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, has_index),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, index),
     NULL,
-    &tethering__multi_touch_data__index__default_value,
+    &tethering__touch_data__index__default_value,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
@@ -1623,10 +1610,10 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_data__field_descrip
     2,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_FLOAT,
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, has_xpoint),
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, xpoint),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, has_xpoint),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, xpoint),
     NULL,
-    &tethering__multi_touch_data__x_point__default_value,
+    &tethering__touch_data__x_point__default_value,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
@@ -1635,10 +1622,10 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_data__field_descrip
     3,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_FLOAT,
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, has_ypoint),
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, ypoint),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, has_ypoint),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, ypoint),
     NULL,
-    &tethering__multi_touch_data__y_point__default_value,
+    &tethering__touch_data__y_point__default_value,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
@@ -1647,56 +1634,56 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_data__field_descrip
     4,
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_ENUM,
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, has_state),
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchData, state),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, has_state),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchData, state),
     &tethering__touch_state__descriptor,
     NULL,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
 };
-static const unsigned tethering__multi_touch_data__field_indices_by_name[] = {
+static const unsigned tethering__touch_data__field_indices_by_name[] = {
   0,   /* field[0] = index */
   3,   /* field[3] = state */
   1,   /* field[1] = xPoint */
   2,   /* field[2] = yPoint */
 };
-static const ProtobufCIntRange tethering__multi_touch_data__number_ranges[1 + 1] =
+static const ProtobufCIntRange tethering__touch_data__number_ranges[1 + 1] =
 {
   { 1, 0 },
   { 0, 4 }
 };
-const ProtobufCMessageDescriptor tethering__multi_touch_data__descriptor =
+const ProtobufCMessageDescriptor tethering__touch_data__descriptor =
 {
   PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
-  "tethering.MultiTouchData",
-  "MultiTouchData",
-  "Tethering__MultiTouchData",
+  "tethering.TouchData",
+  "TouchData",
+  "Tethering__TouchData",
   "tethering",
-  sizeof(Tethering__MultiTouchData),
+  sizeof(Tethering__TouchData),
   4,
-  tethering__multi_touch_data__field_descriptors,
-  tethering__multi_touch_data__field_indices_by_name,
-  1,  tethering__multi_touch_data__number_ranges,
-  (ProtobufCMessageInit) tethering__multi_touch_data__init,
+  tethering__touch_data__field_descriptors,
+  tethering__touch_data__field_indices_by_name,
+  1,  tethering__touch_data__number_ranges,
+  (ProtobufCMessageInit) tethering__touch_data__init,
   NULL,NULL,NULL    /* reserved[123] */
 };
-const ProtobufCEnumValue tethering__multi_touch_msg__type__enum_values_by_number[7] =
+const ProtobufCEnumValue tethering__touch_msg__type__enum_values_by_number[7] =
 {
-  { "START_REQ", "TETHERING__MULTI_TOUCH_MSG__TYPE__START_REQ", 2 },
-  { "START_ANS", "TETHERING__MULTI_TOUCH_MSG__TYPE__START_ANS", 3 },
-  { "TERMINATE", "TETHERING__MULTI_TOUCH_MSG__TYPE__TERMINATE", 4 },
-  { "MAX_COUNT", "TETHERING__MULTI_TOUCH_MSG__TYPE__MAX_COUNT", 5 },
-  { "TOUCH_DATA", "TETHERING__MULTI_TOUCH_MSG__TYPE__TOUCH_DATA", 6 },
-  { "RESOLUTION", "TETHERING__MULTI_TOUCH_MSG__TYPE__RESOLUTION", 7 },
-  { "DISPLAY", "TETHERING__MULTI_TOUCH_MSG__TYPE__DISPLAY", 8 },
+  { "START_REQ", "TETHERING__TOUCH_MSG__TYPE__START_REQ", 2 },
+  { "START_ANS", "TETHERING__TOUCH_MSG__TYPE__START_ANS", 3 },
+  { "TERMINATE", "TETHERING__TOUCH_MSG__TYPE__TERMINATE", 4 },
+  { "MAX_COUNT", "TETHERING__TOUCH_MSG__TYPE__MAX_COUNT", 5 },
+  { "TOUCH_DATA", "TETHERING__TOUCH_MSG__TYPE__TOUCH_DATA", 6 },
+  { "RESOLUTION", "TETHERING__TOUCH_MSG__TYPE__RESOLUTION", 7 },
+  { "DISPLAY_MSG", "TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG", 8 },
 };
-static const ProtobufCIntRange tethering__multi_touch_msg__type__value_ranges[] = {
+static const ProtobufCIntRange tethering__touch_msg__type__value_ranges[] = {
 {2, 0},{0, 7}
 };
-const ProtobufCEnumValueIndex tethering__multi_touch_msg__type__enum_values_by_name[7] =
+const ProtobufCEnumValueIndex tethering__touch_msg__type__enum_values_by_name[7] =
 {
-  { "DISPLAY", 6 },
+  { "DISPLAY_MSG", 6 },
   { "MAX_COUNT", 3 },
   { "RESOLUTION", 5 },
   { "START_ANS", 1 },
@@ -1704,22 +1691,22 @@ const ProtobufCEnumValueIndex tethering__multi_touch_msg__type__enum_values_by_n
   { "TERMINATE", 2 },
   { "TOUCH_DATA", 4 },
 };
-const ProtobufCEnumDescriptor tethering__multi_touch_msg__type__descriptor =
+const ProtobufCEnumDescriptor tethering__touch_msg__type__descriptor =
 {
   PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC,
-  "tethering.MultiTouchMsg.Type",
+  "tethering.TouchMsg.Type",
   "Type",
-  "Tethering__MultiTouchMsg__Type",
+  "Tethering__TouchMsg__Type",
   "tethering",
   7,
-  tethering__multi_touch_msg__type__enum_values_by_number,
+  tethering__touch_msg__type__enum_values_by_number,
   7,
-  tethering__multi_touch_msg__type__enum_values_by_name,
+  tethering__touch_msg__type__enum_values_by_name,
   1,
-  tethering__multi_touch_msg__type__value_ranges,
+  tethering__touch_msg__type__value_ranges,
   NULL,NULL,NULL,NULL   /* reserved[1234] */
 };
-static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descriptors[8] =
+static const ProtobufCFieldDescriptor tethering__touch_msg__field_descriptors[8] =
 {
   {
     "type",
@@ -1727,8 +1714,8 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_REQUIRED,
     PROTOBUF_C_TYPE_ENUM,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, type),
-    &tethering__multi_touch_msg__type__descriptor,
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, type),
+    &tethering__touch_msg__type__descriptor,
     NULL,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
@@ -1739,7 +1726,7 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, startreq),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, startreq),
     &tethering__start_req__descriptor,
     NULL,
     0,            /* packed */
@@ -1751,7 +1738,7 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, startans),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, startans),
     &tethering__start_ans__descriptor,
     NULL,
     0,            /* packed */
@@ -1763,7 +1750,7 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, terminate),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, terminate),
     &tethering__event_terminate__descriptor,
     NULL,
     0,            /* packed */
@@ -1775,8 +1762,8 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, maxcount),
-    &tethering__multi_touch_max_count__descriptor,
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, maxcount),
+    &tethering__touch_max_count__descriptor,
     NULL,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
@@ -1787,8 +1774,8 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, touchdata),
-    &tethering__multi_touch_data__descriptor,
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, touchdata),
+    &tethering__touch_data__descriptor,
     NULL,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
@@ -1799,7 +1786,7 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, resolution),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, resolution),
     &tethering__resolution__descriptor,
     NULL,
     0,            /* packed */
@@ -1811,14 +1798,14 @@ static const ProtobufCFieldDescriptor tethering__multi_touch_msg__field_descript
     PROTOBUF_C_LABEL_OPTIONAL,
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
-    PROTOBUF_C_OFFSETOF(Tethering__MultiTouchMsg, display),
+    PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, display),
     &tethering__display_msg__descriptor,
     NULL,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
 };
-static const unsigned tethering__multi_touch_msg__field_indices_by_name[] = {
+static const unsigned tethering__touch_msg__field_indices_by_name[] = {
   7,   /* field[7] = display */
   4,   /* field[4] = maxCount */
   6,   /* field[6] = resolution */
@@ -1828,24 +1815,24 @@ static const unsigned tethering__multi_touch_msg__field_indices_by_name[] = {
   5,   /* field[5] = touchData */
   0,   /* field[0] = type */
 };
-static const ProtobufCIntRange tethering__multi_touch_msg__number_ranges[1 + 1] =
+static const ProtobufCIntRange tethering__touch_msg__number_ranges[1 + 1] =
 {
   { 1, 0 },
   { 0, 8 }
 };
-const ProtobufCMessageDescriptor tethering__multi_touch_msg__descriptor =
+const ProtobufCMessageDescriptor tethering__touch_msg__descriptor =
 {
   PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
-  "tethering.MultiTouchMsg",
-  "MultiTouchMsg",
-  "Tethering__MultiTouchMsg",
+  "tethering.TouchMsg",
+  "TouchMsg",
+  "Tethering__TouchMsg",
   "tethering",
-  sizeof(Tethering__MultiTouchMsg),
+  sizeof(Tethering__TouchMsg),
   8,
-  tethering__multi_touch_msg__field_descriptors,
-  tethering__multi_touch_msg__field_indices_by_name,
-  1,  tethering__multi_touch_msg__number_ranges,
-  (ProtobufCMessageInit) tethering__multi_touch_msg__init,
+  tethering__touch_msg__field_descriptors,
+  tethering__touch_msg__field_indices_by_name,
+  1,  tethering__touch_msg__number_ranges,
+  (ProtobufCMessageInit) tethering__touch_msg__init,
   NULL,NULL,NULL    /* reserved[123] */
 };
 const ProtobufCEnumValue tethering__tethering_msg__type__enum_values_by_number[7] =
@@ -1979,7 +1966,7 @@ static const ProtobufCFieldDescriptor tethering__tethering_msg__field_descriptor
     PROTOBUF_C_TYPE_MESSAGE,
     0,   /* quantifier_offset */
     PROTOBUF_C_OFFSETOF(Tethering__TetheringMsg, touchmsg),
-    &tethering__multi_touch_msg__descriptor,
+    &tethering__touch_msg__descriptor,
     NULL,
     0,            /* packed */
     0,NULL,NULL    /* reserved1,reserved2, etc */
index 7b28c00..a2fc957 100644 (file)
@@ -22,9 +22,9 @@ typedef struct _Tethering__SensorData Tethering__SensorData;
 typedef struct _Tethering__SensorMsg Tethering__SensorMsg;
 typedef struct _Tethering__Resolution Tethering__Resolution;
 typedef struct _Tethering__DisplayMsg Tethering__DisplayMsg;
-typedef struct _Tethering__MultiTouchMaxCount Tethering__MultiTouchMaxCount;
-typedef struct _Tethering__MultiTouchData Tethering__MultiTouchData;
-typedef struct _Tethering__MultiTouchMsg Tethering__MultiTouchMsg;
+typedef struct _Tethering__TouchMaxCount Tethering__TouchMaxCount;
+typedef struct _Tethering__TouchData Tethering__TouchData;
+typedef struct _Tethering__TouchMsg Tethering__TouchMsg;
 typedef struct _Tethering__TetheringMsg Tethering__TetheringMsg;
 
 
@@ -43,15 +43,15 @@ typedef enum _Tethering__SensorMsg__Type {
   TETHERING__SENSOR_MSG__TYPE__SENSOR_STATUS = 5,
   TETHERING__SENSOR_MSG__TYPE__SENSOR_DATA = 6
 } Tethering__SensorMsg__Type;
-typedef enum _Tethering__MultiTouchMsg__Type {
-  TETHERING__MULTI_TOUCH_MSG__TYPE__START_REQ = 2,
-  TETHERING__MULTI_TOUCH_MSG__TYPE__START_ANS = 3,
-  TETHERING__MULTI_TOUCH_MSG__TYPE__TERMINATE = 4,
-  TETHERING__MULTI_TOUCH_MSG__TYPE__MAX_COUNT = 5,
-  TETHERING__MULTI_TOUCH_MSG__TYPE__TOUCH_DATA = 6,
-  TETHERING__MULTI_TOUCH_MSG__TYPE__RESOLUTION = 7,
-  TETHERING__MULTI_TOUCH_MSG__TYPE__DISPLAY = 8
-} Tethering__MultiTouchMsg__Type;
+typedef enum _Tethering__TouchMsg__Type {
+  TETHERING__TOUCH_MSG__TYPE__START_REQ = 2,
+  TETHERING__TOUCH_MSG__TYPE__START_ANS = 3,
+  TETHERING__TOUCH_MSG__TYPE__TERMINATE = 4,
+  TETHERING__TOUCH_MSG__TYPE__MAX_COUNT = 5,
+  TETHERING__TOUCH_MSG__TYPE__TOUCH_DATA = 6,
+  TETHERING__TOUCH_MSG__TYPE__RESOLUTION = 7,
+  TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG = 8
+} Tethering__TouchMsg__Type;
 typedef enum _Tethering__TetheringMsg__Type {
   TETHERING__TETHERING_MSG__TYPE__HANDSHAKE_REQ = 2,
   TETHERING__TETHERING_MSG__TYPE__HANDSHAKE_ANS = 3,
@@ -242,7 +242,6 @@ struct  _Tethering__Resolution
 struct  _Tethering__DisplayMsg
 {
   ProtobufCMessage base;
-  protobuf_c_boolean onoff;
   protobuf_c_boolean has_framerate;
   int32_t framerate;
   protobuf_c_boolean has_imagedata;
@@ -250,21 +249,21 @@ struct  _Tethering__DisplayMsg
 };
 #define TETHERING__DISPLAY_MSG__INIT \
  { PROTOBUF_C_MESSAGE_INIT (&tethering__display_msg__descriptor) \
-    , 0, 0,0, 0,{0,NULL} }
+    , 0,0, 0,{0,NULL} }
 
 
-struct  _Tethering__MultiTouchMaxCount
+struct  _Tethering__TouchMaxCount
 {
   ProtobufCMessage base;
   protobuf_c_boolean has_max;
   int32_t max;
 };
-#define TETHERING__MULTI_TOUCH_MAX_COUNT__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&tethering__multi_touch_max_count__descriptor) \
+#define TETHERING__TOUCH_MAX_COUNT__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&tethering__touch_max_count__descriptor) \
     , 0,10 }
 
 
-struct  _Tethering__MultiTouchData
+struct  _Tethering__TouchData
 {
   ProtobufCMessage base;
   protobuf_c_boolean has_index;
@@ -276,25 +275,25 @@ struct  _Tethering__MultiTouchData
   protobuf_c_boolean has_state;
   Tethering__TouchState state;
 };
-#define TETHERING__MULTI_TOUCH_DATA__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&tethering__multi_touch_data__descriptor) \
+#define TETHERING__TOUCH_DATA__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&tethering__touch_data__descriptor) \
     , 0,0, 0,0, 0,0, 0,0 }
 
 
-struct  _Tethering__MultiTouchMsg
+struct  _Tethering__TouchMsg
 {
   ProtobufCMessage base;
-  Tethering__MultiTouchMsg__Type type;
+  Tethering__TouchMsg__Type type;
   Tethering__StartReq *startreq;
   Tethering__StartAns *startans;
   Tethering__EventTerminate *terminate;
-  Tethering__MultiTouchMaxCount *maxcount;
-  Tethering__MultiTouchData *touchdata;
+  Tethering__TouchMaxCount *maxcount;
+  Tethering__TouchData *touchdata;
   Tethering__Resolution *resolution;
   Tethering__DisplayMsg *display;
 };
-#define TETHERING__MULTI_TOUCH_MSG__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&tethering__multi_touch_msg__descriptor) \
+#define TETHERING__TOUCH_MSG__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&tethering__touch_msg__descriptor) \
     , 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
 
 
@@ -308,7 +307,7 @@ struct  _Tethering__TetheringMsg
   Tethering__AppState *appstate;
   Tethering__EventMsg *eventmsg;
   Tethering__SensorMsg *sensormsg;
-  Tethering__MultiTouchMsg *touchmsg;
+  Tethering__TouchMsg *touchmsg;
 };
 #define TETHERING__TETHERING_MSG__INIT \
  { PROTOBUF_C_MESSAGE_INIT (&tethering__tethering_msg__descriptor) \
@@ -581,62 +580,62 @@ Tethering__DisplayMsg *
 void   tethering__display_msg__free_unpacked
                      (Tethering__DisplayMsg *message,
                       ProtobufCAllocator *allocator);
-/* Tethering__MultiTouchMaxCount methods */
-void   tethering__multi_touch_max_count__init
-                     (Tethering__MultiTouchMaxCount         *message);
-size_t tethering__multi_touch_max_count__get_packed_size
-                     (const Tethering__MultiTouchMaxCount   *message);
-size_t tethering__multi_touch_max_count__pack
-                     (const Tethering__MultiTouchMaxCount   *message,
+/* Tethering__TouchMaxCount methods */
+void   tethering__touch_max_count__init
+                     (Tethering__TouchMaxCount         *message);
+size_t tethering__touch_max_count__get_packed_size
+                     (const Tethering__TouchMaxCount   *message);
+size_t tethering__touch_max_count__pack
+                     (const Tethering__TouchMaxCount   *message,
                       uint8_t             *out);
-size_t tethering__multi_touch_max_count__pack_to_buffer
-                     (const Tethering__MultiTouchMaxCount   *message,
+size_t tethering__touch_max_count__pack_to_buffer
+                     (const Tethering__TouchMaxCount   *message,
                       ProtobufCBuffer     *buffer);
-Tethering__MultiTouchMaxCount *
-       tethering__multi_touch_max_count__unpack
+Tethering__TouchMaxCount *
+       tethering__touch_max_count__unpack
                      (ProtobufCAllocator  *allocator,
                       size_t               len,
                       const uint8_t       *data);
-void   tethering__multi_touch_max_count__free_unpacked
-                     (Tethering__MultiTouchMaxCount *message,
+void   tethering__touch_max_count__free_unpacked
+                     (Tethering__TouchMaxCount *message,
                       ProtobufCAllocator *allocator);
-/* Tethering__MultiTouchData methods */
-void   tethering__multi_touch_data__init
-                     (Tethering__MultiTouchData         *message);
-size_t tethering__multi_touch_data__get_packed_size
-                     (const Tethering__MultiTouchData   *message);
-size_t tethering__multi_touch_data__pack
-                     (const Tethering__MultiTouchData   *message,
+/* Tethering__TouchData methods */
+void   tethering__touch_data__init
+                     (Tethering__TouchData         *message);
+size_t tethering__touch_data__get_packed_size
+                     (const Tethering__TouchData   *message);
+size_t tethering__touch_data__pack
+                     (const Tethering__TouchData   *message,
                       uint8_t             *out);
-size_t tethering__multi_touch_data__pack_to_buffer
-                     (const Tethering__MultiTouchData   *message,
+size_t tethering__touch_data__pack_to_buffer
+                     (const Tethering__TouchData   *message,
                       ProtobufCBuffer     *buffer);
-Tethering__MultiTouchData *
-       tethering__multi_touch_data__unpack
+Tethering__TouchData *
+       tethering__touch_data__unpack
                      (ProtobufCAllocator  *allocator,
                       size_t               len,
                       const uint8_t       *data);
-void   tethering__multi_touch_data__free_unpacked
-                     (Tethering__MultiTouchData *message,
+void   tethering__touch_data__free_unpacked
+                     (Tethering__TouchData *message,
                       ProtobufCAllocator *allocator);
-/* Tethering__MultiTouchMsg methods */
-void   tethering__multi_touch_msg__init
-                     (Tethering__MultiTouchMsg         *message);
-size_t tethering__multi_touch_msg__get_packed_size
-                     (const Tethering__MultiTouchMsg   *message);
-size_t tethering__multi_touch_msg__pack
-                     (const Tethering__MultiTouchMsg   *message,
+/* Tethering__TouchMsg methods */
+void   tethering__touch_msg__init
+                     (Tethering__TouchMsg         *message);
+size_t tethering__touch_msg__get_packed_size
+                     (const Tethering__TouchMsg   *message);
+size_t tethering__touch_msg__pack
+                     (const Tethering__TouchMsg   *message,
                       uint8_t             *out);
-size_t tethering__multi_touch_msg__pack_to_buffer
-                     (const Tethering__MultiTouchMsg   *message,
+size_t tethering__touch_msg__pack_to_buffer
+                     (const Tethering__TouchMsg   *message,
                       ProtobufCBuffer     *buffer);
-Tethering__MultiTouchMsg *
-       tethering__multi_touch_msg__unpack
+Tethering__TouchMsg *
+       tethering__touch_msg__unpack
                      (ProtobufCAllocator  *allocator,
                       size_t               len,
                       const uint8_t       *data);
-void   tethering__multi_touch_msg__free_unpacked
-                     (Tethering__MultiTouchMsg *message,
+void   tethering__touch_msg__free_unpacked
+                     (Tethering__TouchMsg *message,
                       ProtobufCAllocator *allocator);
 /* Tethering__TetheringMsg methods */
 void   tethering__tethering_msg__init
@@ -701,14 +700,14 @@ typedef void (*Tethering__Resolution_Closure)
 typedef void (*Tethering__DisplayMsg_Closure)
                  (const Tethering__DisplayMsg *message,
                   void *closure_data);
-typedef void (*Tethering__MultiTouchMaxCount_Closure)
-                 (const Tethering__MultiTouchMaxCount *message,
+typedef void (*Tethering__TouchMaxCount_Closure)
+                 (const Tethering__TouchMaxCount *message,
                   void *closure_data);
-typedef void (*Tethering__MultiTouchData_Closure)
-                 (const Tethering__MultiTouchData *message,
+typedef void (*Tethering__TouchData_Closure)
+                 (const Tethering__TouchData *message,
                   void *closure_data);
-typedef void (*Tethering__MultiTouchMsg_Closure)
-                 (const Tethering__MultiTouchMsg *message,
+typedef void (*Tethering__TouchMsg_Closure)
+                 (const Tethering__TouchMsg *message,
                   void *closure_data);
 typedef void (*Tethering__TetheringMsg_Closure)
                  (const Tethering__TetheringMsg *message,
@@ -741,10 +740,10 @@ extern const ProtobufCMessageDescriptor tethering__sensor_msg__descriptor;
 extern const ProtobufCEnumDescriptor    tethering__sensor_msg__type__descriptor;
 extern const ProtobufCMessageDescriptor tethering__resolution__descriptor;
 extern const ProtobufCMessageDescriptor tethering__display_msg__descriptor;
-extern const ProtobufCMessageDescriptor tethering__multi_touch_max_count__descriptor;
-extern const ProtobufCMessageDescriptor tethering__multi_touch_data__descriptor;
-extern const ProtobufCMessageDescriptor tethering__multi_touch_msg__descriptor;
-extern const ProtobufCEnumDescriptor    tethering__multi_touch_msg__type__descriptor;
+extern const ProtobufCMessageDescriptor tethering__touch_max_count__descriptor;
+extern const ProtobufCMessageDescriptor tethering__touch_data__descriptor;
+extern const ProtobufCMessageDescriptor tethering__touch_msg__descriptor;
+extern const ProtobufCEnumDescriptor    tethering__touch_msg__type__descriptor;
 extern const ProtobufCMessageDescriptor tethering__tethering_msg__descriptor;
 extern const ProtobufCEnumDescriptor    tethering__tethering_msg__type__descriptor;
 
index 9db3c38..cf1c01c 100644 (file)
@@ -2,8 +2,9 @@ package tethering;
 
 option java_package = "device.tethering.genmsg";
 
-// define value
+// protoc-c --c_out=../genmsg tethering.proto
 
+// define value
 enum MessageResult {
        SUCCESS = 1;
        FAILURE = 2;
@@ -26,7 +27,7 @@ enum State {
        DISABLED = 2;
 }
 
-enum SensorType{
+enum SensorType {
        ACCEL = 1;
        MAGNETIC = 2;
        GYROSCOPE = 3;
@@ -40,7 +41,6 @@ enum TouchState {
 }
 
 // define messages
-
 message HandShakeReq {
        required int32 key = 1;
 }
@@ -123,25 +123,42 @@ message Resolution {
        required int32 height = 2;
 }
 
+/*
+message DisplayMsg {
+       enum Type {
+               START_REQ = 2;
+               START_ANS = 3;
+               TERMINATE = 4;
+               FRAME_RATE = 5;
+               IMAGE_DATA = 6;
+       }
+
+       required Type type = 1;
+       optional StartReq startReq= 2;
+       optional StartAns startAns= 3;
+       optional EventTerminate terminate = 4;
+       optional int32 frameRate = 5;
+       optional bytes imageData = 6;
+}
+*/
+
 message DisplayMsg {
-       // required Resolution resolution = 1;
-       required bool onOff = 2;
-       optional int32 frameRate = 3;
-       optional bytes imageData = 4;
+       optional int32 frameRate = 1;
+       optional bytes imageData = 2;
 }
 
-message MultiTouchMaxCount {
+message TouchMaxCount {
        optional int32 max = 1 [default = 10];
 }
 
-message MultiTouchData {
+message TouchData {
        optional int32 index = 1 [default = 0];
        optional float xPoint = 2 [default = 0.0];
        optional float yPoint = 3 [default = 0.0];
        optional TouchState state = 4;
 }
 
-message MultiTouchMsg {
+message TouchMsg {
        enum Type {
                START_REQ = 2;
                START_ANS = 3;
@@ -149,14 +166,14 @@ message MultiTouchMsg {
                MAX_COUNT = 5;
                TOUCH_DATA = 6;
                RESOLUTION = 7;
-               DISPLAY = 8;
+               DISPLAY_MSG = 8;
        }
        required Type type = 1;
        optional StartReq startReq = 2;
        optional StartAns startAns = 3;
        optional EventTerminate terminate = 4;
-       optional MultiTouchMaxCount maxCount = 5;
-       optional MultiTouchData touchData = 6;
+       optional TouchMaxCount maxCount = 5;
+       optional TouchData touchData = 6;
        optional Resolution resolution = 7;
        optional DisplayMsg display = 8;
 }
@@ -178,5 +195,5 @@ message TetheringMsg {
        optional AppState appState = 5;
        optional EventMsg eventMsg = 6;
        optional SensorMsg sensorMsg = 7;
-       optional MultiTouchMsg touchMsg = 8;
+       optional TouchMsg touchMsg = 8;
 }
diff --git a/tizen/src/tethering/sensor.c b/tizen/src/tethering/sensor.c
new file mode 100644 (file)
index 0000000..43f7a0a
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * emulator controller client
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Kitae Kim <kt920.kim@samsung.com>
+ *  JiHye Kim <jihye1128.kim@samsung.com>
+ *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#if 0
+#ifndef __WIN32
+#include <sys/ioctl.h>
+#else
+#define EISCONN WSAEISCONN
+#endif
+
+#include "qemu-common.h"
+#include "qemu/main-loop.h"
+#include "qemu/sockets.h"
+#include "ui/console.h"
+#endif
+
+#include "emul_state.h"
+
+#include "sensor.h"
+#include "common.h"
+#include "ecs/ecs_tethering.h"
+#include "genmsg/tethering.pb-c.h"
+
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+
+typedef struct sensor_state {
+    bool is_sensor_event;
+    bool is_sensor_supported;
+
+} sensor_state;
+
+enum sensor_level {
+    level_accel = 1,
+    level_proxi = 2,
+    level_light = 3,
+    level_gyro = 4,
+    level_geo = 5,
+    level_tilt = 12,
+    level_magnetic = 13
+};
+
+static int sensor_device_status;
+
+#if 0
+static void init_sensor_state(void)
+{
+    input_device_list *device = NULL;
+    sensor_state *sensor = NULL;
+    int ret = 0;
+
+    device = g_malloc0(sizeof(device));
+    if (!device) {
+        return;
+    }
+
+    sensor = g_malloc0(sizeof(sensor_state));
+    if (!sensor) {
+        g_free(device);
+        return;
+    }
+
+    device->type = TETHERING__TETHERING_MSG__TYPE__SENSOR_MSG;
+    device->opaque = sensor;
+
+    ret = add_input_device(device);
+    if (ret < 0) {
+        g_free(sensor);
+        g_free(device);
+    }
+}
+#endif
+
+// create a sensor message.
+static bool build_sensor_msg(Tethering__SensorMsg *sensor)
+{
+    bool ret = false;
+    Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    msg.type = TETHERING__TETHERING_MSG__TYPE__SENSOR_MSG;
+    msg.sensormsg = sensor;
+
+    ret = send_msg_to_controller(&msg);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+static bool send_sensor_start_ans_msg(Tethering__MessageResult result)
+{
+    bool ret = false;
+    Tethering__SensorMsg event = TETHERING__SENSOR_MSG__INIT;
+    Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    start_ans.result = result;
+
+    event.type = TETHERING__SENSOR_MSG__TYPE__START_ANS;
+    event.startans = &start_ans;
+
+    TRACE("send sensor_start_ans message\n");
+    ret = build_sensor_msg(&event);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+static bool send_set_sensor_status_msg(Tethering__SensorType sensor_type,
+                                    Tethering__State status)
+{
+    bool ret = false;
+
+    Tethering__SensorMsg sensor = TETHERING__SENSOR_MSG__INIT;
+    Tethering__SetSensorStatus sensor_status =
+                            TETHERING__SET_SENSOR_STATUS__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    sensor_status.type = sensor_type;
+    sensor_status.state = status;
+
+    sensor.type = TETHERING__SENSOR_MSG__TYPE__SENSOR_STATUS;
+    sensor.setstatus = &sensor_status;
+
+    TRACE("send sensor_set_event_status message\n");
+    ret = build_sensor_msg(&sensor);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+static void set_sensor_data(Tethering__SensorData *data)
+{
+    /*
+     * data format for sensor device
+     * each value is classified by carriage return character
+     * sensor_type/param numbers/parameters
+     * ex) acceleration sensor: "level_accel\n3\nx\ny\nz\n"
+     */
+
+    switch(data->sensor) {
+    case TETHERING__SENSOR_TYPE__ACCEL:
+    {
+        char tmp[255] = {0};
+
+        sprintf(tmp, "%d\n%d\n%s\n%s\n%s\n",
+                level_accel, 3, data->x, data->y, data->z);
+        send_tethering_sensor_data(tmp, strlen(tmp));
+
+        TRACE("sensor_accel x: %s, y: %s, z: %s\n",
+            data->x, data->y, data->z);
+    }
+        break;
+    case TETHERING__SENSOR_TYPE__MAGNETIC:
+    {
+        char tmp[255] = {0};
+
+        sprintf(tmp, "%d\n%d\n%s\n%s\n%s\n",
+                level_magnetic, 3, data->x, data->y, data->z);
+        send_tethering_sensor_data(tmp, strlen(tmp));
+
+        TRACE("sensor_mag x: %s, y: %s, z: %s\n",
+            data->x, data->y, data->z);
+    }
+        break;
+    case TETHERING__SENSOR_TYPE__GYROSCOPE:
+    {
+        char tmp[255] = {0};
+
+        sprintf(tmp, "%d\n%d\n%s\n%s\n%s\n",
+                level_gyro, 3, data->x, data->y, data->z);
+        send_tethering_sensor_data(tmp, strlen(tmp));
+
+        TRACE("sensor_gyro x: %s, y: %s, z: %s\n",
+            data->x, data->y, data->z);
+    }
+        break;
+    case TETHERING__SENSOR_TYPE__PROXIMITY:
+    {
+        char tmp[255] = {0};
+        double x = (double)(atoi(data->x));
+
+        sprintf(tmp, "%d\n%d\n%.1f\n", level_proxi, 1, x);
+        send_tethering_sensor_data(tmp, strlen(tmp));
+
+        TRACE("sensor_proxi x: %.1f, %s\n", x, tmp);
+    }
+        break;
+    case TETHERING__SENSOR_TYPE__LIGHT:
+    {
+        char tmp[255] = {0};
+
+        sprintf(tmp, "%d\n%d\n%s%s\n", level_light, 2, data->x, data->y);
+        send_tethering_sensor_data(tmp, strlen(tmp));
+
+        TRACE("sensor_light x: %s\n", data->x);
+    }
+        break;
+    default:
+        TRACE("invalid sensor data\n");
+        break;
+    }
+}
+
+bool msgproc_tethering_sensor_msg(void *message)
+{
+    bool ret = true;
+    Tethering__SensorMsg *msg = (Tethering__SensorMsg *)message;
+
+    switch(msg->type) {
+    case TETHERING__SENSOR_MSG__TYPE__START_REQ:
+        TRACE("SENSOR_MSG_TYPE_START_REQ\n");
+
+        // TODO
+        // init_sensor_state();
+
+        // set sensor type.
+        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__ACCEL,
+                                TETHERING__STATE__ENABLED);
+        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__MAGNETIC,
+                                TETHERING__STATE__ENABLED);
+        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__GYROSCOPE,
+                                TETHERING__STATE__ENABLED);
+        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__PROXIMITY,
+                                TETHERING__STATE__ENABLED);
+        send_set_sensor_status_msg(TETHERING__SENSOR_TYPE__LIGHT,
+                                TETHERING__STATE__ENABLED);
+
+        TRACE("SENSOR_MSG_TYPE_START_ANS\n");
+        send_sensor_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
+
+        break;
+    case TETHERING__SENSOR_MSG__TYPE__TERMINATE:
+        TRACE("SENSOR_MSG_TYPE_TERMINATE\n");
+        break;
+
+    case TETHERING__SENSOR_MSG__TYPE__SENSOR_DATA:
+        TRACE("SENSOR_MSG_TYPE_SENSOR_DATA\n");
+        set_sensor_data(msg->data);
+        break;
+    default:
+        TRACE("invalid sensor_msg type");
+        ret = false;
+        break;
+    }
+
+    return ret;
+}
+
+int get_tethering_sensor_status(void)
+{
+    return sensor_device_status;
+}
+
+void set_tethering_sensor_status(int status)
+{
+    sensor_device_status = status;
+    send_tethering_sensor_status_ecp();
+}
diff --git a/tizen/src/tethering/sensor.h b/tizen/src/tethering/sensor.h
new file mode 100644 (file)
index 0000000..42ece22
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * emulator controller client
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Kitae Kim <kt920.kim@samsung.com>
+ *  JiHye Kim <jihye1128.kim@samsung.com>
+ *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+bool msgproc_tethering_sensor_msg(void *msg);
+
+int get_tethering_sensor_status(void);
+
+void set_tethering_sensor_status(int status);
diff --git a/tizen/src/tethering/touch.c b/tizen/src/tethering/touch.c
new file mode 100644 (file)
index 0000000..296b656
--- /dev/null
@@ -0,0 +1,363 @@
+/*
+ * emulator controller client
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Kitae Kim <kt920.kim@samsung.com>
+ *  JiHye Kim <jihye1128.kim@samsung.com>
+ *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "emul_state.h"
+#include "common.h"
+#include "touch.h"
+#include "genmsg/tethering.pb-c.h"
+#include "ecs/ecs_tethering.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(tizen, app_tethering);
+
+typedef struct touch_state {
+    bool is_touch_event;
+    bool is_touch_supported;
+
+    // int touch_max_point;
+
+    // display_state *display;
+} touch_event;
+
+// static bool is_touch_event;
+static int touch_device_status;
+
+#ifndef DISPLAY_FEATURE
+#include "encode_fb.h"
+
+enum {
+    ENCODE_WEBP = 0,
+    ENCODE_PNG,
+};
+
+// static void set_touch_event_status(bool status);
+static bool send_display_image_data(void);
+#endif
+
+
+#if 0
+touch_state *init_touch_state(void)
+{
+    input_device_list *device = NULL;
+    touch_state *touch = NULL;
+    int ret = 0;
+
+    device = g_malloc0(sizeof(device));
+    if (!device) {
+        return NULL;
+    }
+
+    touch = g_malloc0(sizeof(touch_state));
+    if (!touch) {
+        g_free(device);
+        return NULL;
+    }
+
+    device->type = TETHERING__TETHERING_MSG__TYPE__TOUCH_MSG;
+    device->opaque = touch;
+
+    ret = add_input_device(device);
+    if (ret < 0) {
+        g_free(touch);
+        g_free(device);
+    }
+
+    return touch;
+}
+#endif
+
+static bool build_touch_msg(Tethering__TouchMsg *touch)
+{
+    bool ret = false;
+    Tethering__TetheringMsg msg = TETHERING__TETHERING_MSG__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    msg.type = TETHERING__TETHERING_MSG__TYPE__TOUCH_MSG;
+    msg.touchmsg = touch;
+
+    TRACE("touch message size: %d\n", tethering__tethering_msg__get_packed_size(&msg));
+    ret = send_msg_to_controller(&msg);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+static bool send_touch_start_ans_msg(Tethering__MessageResult result)
+{
+    bool ret = false;
+
+    Tethering__TouchMsg mt = TETHERING__TOUCH_MSG__INIT;
+    Tethering__StartAns start_ans = TETHERING__START_ANS__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    start_ans.result = result;
+
+    mt.type = TETHERING__TOUCH_MSG__TYPE__START_ANS;
+    mt.startans = &start_ans;
+
+    ret = build_touch_msg(&mt);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+static bool send_set_touch_max_count(void)
+{
+    bool ret = false;
+
+    Tethering__TouchMsg mt = TETHERING__TOUCH_MSG__INIT;
+    Tethering__TouchMaxCount touch_cnt =
+        TETHERING__TOUCH_MAX_COUNT__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    touch_cnt.max = get_emul_max_touch_point();
+
+    mt.type = TETHERING__TOUCH_MSG__TYPE__MAX_COUNT;
+    mt.maxcount = &touch_cnt;
+
+    TRACE("send touch max count: %d\n", touch_cnt.max);
+    ret = build_touch_msg(&mt);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+static void set_touch_data(Tethering__TouchData *data)
+{
+    float x = 0.0, y = 0.0;
+    int32_t index = 0, state = 0;
+
+    switch(data->state) {
+    case TETHERING__TOUCH_STATE__PRESSED:
+        TRACE("touch pressed\n");
+        index = data->index;
+        x = data->xpoint;
+        y = data->ypoint;
+        state = PRESSED;
+        break;
+    case TETHERING__TOUCH_STATE__RELEASED:
+        TRACE("touch released\n");
+        index = data->index;
+        x = data->xpoint;
+        y = data->ypoint;
+        state = RELEASED;
+        break;
+    default:
+        TRACE("invalid touch data\n");
+        break;
+    }
+
+    TRACE("set touch_data. index: %d, x: %lf, y: %lf\n", index, x, y);
+    send_tethering_touch_data(x, y, index, state);
+}
+
+static bool send_set_touch_resolution(void)
+{
+    bool ret = false;
+
+    Tethering__TouchMsg mt = TETHERING__TOUCH_MSG__INIT;
+    Tethering__Resolution resolution = TETHERING__RESOLUTION__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    resolution.width = get_emul_resolution_width();
+    resolution.height = get_emul_resolution_height();
+
+    mt.type = TETHERING__TOUCH_MSG__TYPE__RESOLUTION;
+    mt.resolution = &resolution;
+
+    TRACE("send touch resolution: %dx%d\n",
+        resolution.width, resolution.height);
+    ret = build_touch_msg(&mt);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+
+    return ret;
+}
+
+#if 0
+static void set_touch_event_status(bool status)
+{
+    is_touch_event = status;
+
+    INFO("set touch_event status: %d\n", status);
+}
+
+static void set_hwkey_data(Tethering__HWKeyMsg *msg)
+{
+    int32_t keycode = 0;
+
+    switch (msg->type) {
+    case TETHERING__HWKEY_TYPE__MENU:
+        // keycode = HARD_KEY_ ;
+        break;
+
+    case TETHERING__HWKEY_TYPE__HOME:
+        keycode = HARD_KEY_HOME;
+        break;
+
+    case TETHERING__HWKEY_TYPE__BACK:
+        // keycode = ;
+        break;
+
+    case TETHERING__HWKEY_TYPE__POWER:
+        keycode = HARD_KEY_POWER;
+        break;
+
+    case TETHERING__HWKEY_TYPE__VOLUMEUP:
+        keycode = HARD_KEY_VOL_UP;
+        break;
+
+    case TETHERING__HWKEY_TYPE__VOLUMEDOWN:
+        keycode = HARD_KEY_VOL_DOWN;
+        break;
+
+    default:
+        INFO("undefined type: %d\n", msg->type);
+    }
+
+    INFO("convert hwkey msg to keycode: %d\n", keycode);
+    send_tethering_hwkey_data(keycode);
+}
+#endif
+
+// bool msgproc_tethering_touch_msg(Tethering__TouchMsg *msg)
+bool msgproc_tethering_touch_msg(void *message)
+{
+    bool ret = true;
+    Tethering__TouchMsg *msg = (Tethering__TouchMsg *)message;
+
+    // touch_state *state = NULL;
+
+    switch(msg->type) {
+    case TETHERING__TOUCH_MSG__TYPE__START_REQ:
+        TRACE("TOUCH_MSG_TYPE_START\n");
+        // state = init_touch_state();
+
+        // it means that app starts to send touch values.
+        // set_touch_event_status(true);
+
+        send_set_touch_max_count();
+        send_set_touch_resolution();
+
+        ret = send_touch_start_ans_msg(TETHERING__MESSAGE_RESULT__SUCCESS);
+        break;
+    case TETHERING__TOUCH_MSG__TYPE__TERMINATE:
+        TRACE("TOUCH_MSG_TYPE_TERMINATE\n");
+
+        // it means that app stops to send touch values.
+        // set_touch_event_status(false);
+        break;
+
+    case TETHERING__TOUCH_MSG__TYPE__TOUCH_DATA:
+        set_touch_data(msg->touchdata);
+        break;
+
+    case TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG:
+        send_display_image_data();
+        break;
+
+#if 0
+    case TETHERING__TOUCH_MSG__TYPE__HWKEY_MSG:
+        set_hwkey_data(msg->hwkey);
+        break;
+#endif
+    default:
+        TRACE("invalid touch_msg\n");
+        ret = false;
+        break;
+    }
+
+    return ret;
+}
+
+int get_tethering_touch_status(void)
+{
+    return touch_device_status;
+}
+
+void set_tethering_touch_status(int status)
+{
+    touch_device_status = status;
+    send_tethering_touch_status_ecp();
+}
+
+static bool send_display_image_data(void)
+{
+    bool ret = false;
+    struct encode_mem *image = NULL;
+
+    Tethering__TouchMsg touch = TETHERING__TOUCH_MSG__INIT;
+    Tethering__DisplayMsg display = TETHERING__DISPLAY_MSG__INIT;
+
+    TRACE("enter: %s\n", __func__);
+
+    image = (struct encode_mem *)encode_framebuffer(ENCODE_WEBP);
+    if (!image) {
+        ERR("failed to encode framebuffer\n");
+        return false;
+    }
+
+    TRACE("image data size %d\n", image->length);
+    display.has_imagedata = true;
+    display.imagedata.len = image->length;
+    display.imagedata.data = image->buffer;
+
+#ifdef IMAGE_DUMP
+    {
+        FILE *fp = NULL;
+
+        fp = fopen("test2.png", "wb");
+        if (fp != NULL) {
+            fwrite(image->buffer, 1, image->length, fp);
+            fclose(fp);
+        }
+    }
+#endif
+
+    touch.type = TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG;
+    touch.display = &display;
+
+    // ret = build_display_msg(&display);
+    ret = build_touch_msg(&touch);
+    INFO("send display message: %d\n", ret);
+
+    g_free(image->buffer);
+    g_free(image);
+
+    TRACE("leave: %s, ret: %d\n", __func__, ret);
+    return ret;
+}
diff --git a/tizen/src/tethering/touch.h b/tizen/src/tethering/touch.h
new file mode 100644 (file)
index 0000000..3fbd6c9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * emulator controller client
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ *  Kitae Kim <kt920.kim@samsung.com>
+ *  JiHye Kim <jihye1128.kim@samsung.com>
+ *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+// #include "genmsg/tethering.pb-c.h"
+
+// bool msgproc_tethering_touch_msg(Tethering__TouchMsg *msg);
+bool msgproc_tethering_touch_msg(void *message);
+
+int get_tethering_touch_status(void);
+
+void set_tethering_touch_status(int status);