From 5b96895f84c5a740b302424b0bb4bf873c86741c Mon Sep 17 00:00:00 2001 From: Kitae Kim Date: Fri, 1 Aug 2014 15:06:52 +0900 Subject: [PATCH] tethering: handle hwkey event and source clean-up Change-Id: Ic1d794b8e136417e6ed2aae0a02af1082f194745 Signed-off-by: Kitae Kim --- tizen/src/ecs/ecs_tethering.c | 13 +- tizen/src/ecs/ecs_tethering.h | 2 + tizen/src/tethering/common.c | 65 --------- tizen/src/tethering/genmsg/tethering.pb-c.c | 148 ++++++++++++++++++-- tizen/src/tethering/genmsg/tethering.pb-c.h | 49 ++++++- tizen/src/tethering/msg/tethering.proto | 15 ++ tizen/src/tethering/sensor.c | 32 ----- tizen/src/tethering/touch.c | 81 ++--------- 8 files changed, 227 insertions(+), 178 deletions(-) diff --git a/tizen/src/ecs/ecs_tethering.c b/tizen/src/ecs/ecs_tethering.c index 2960048cd6..f6828d3784 100644 --- a/tizen/src/ecs/ecs_tethering.c +++ b/tizen/src/ecs/ecs_tethering.c @@ -35,6 +35,7 @@ #include "tethering/sensor.h" #include "tethering/touch.h" #include "hw/virtio/maru_virtio_touchscreen.h" +#include "hw/virtio/maru_virtio_hwkey.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(tizen, ecs_tethering); @@ -42,6 +43,9 @@ MULTI_DEBUG_CHANNEL(tizen, ecs_tethering); #define MSG_BUF_SIZE 255 #define MSG_LEN_SIZE 4 +#define PRESSED 1 +#define RELEASED 2 + // static bool send_tethering_ntf(const char *data, const int len); static bool send_tethering_ntf(const char *data); static void send_tethering_status_ntf(type_group group, type_action action); @@ -95,7 +99,6 @@ static void send_tethering_port_ecp(void) TRACE(">> send tethering_ntf to ecp. action=%d, group=%d, data=%s\n", action, group, data); -// send_tethering_ntf((const char *)msg, MSG_BUF_SIZE); send_tethering_ntf((const char *)msg); if (msg) { @@ -143,7 +146,6 @@ static void send_tethering_status_ntf(type_group group, type_action action) TRACE(">> send tethering_ntf to ecp. action=%d, group=%d, data=%s\n", action, group, data); -// send_tethering_ntf((const char *)msg, MSG_BUF_SIZE); send_tethering_ntf((const char *)msg); if (msg) { @@ -151,7 +153,6 @@ static void send_tethering_status_ntf(type_group group, type_action action) } } -// static bool send_tethering_ntf(const char *data, const int len) static bool send_tethering_ntf(const char *data) { type_length length = 0; @@ -217,6 +218,12 @@ void send_tethering_touch_data(int x, int y, int index, int status) virtio_touchscreen_event(x, y, index, status); } +void send_tethering_hwkey_data(int keycode) +{ + maru_hwkey_event(PRESSED, keycode); + maru_hwkey_event(RELEASED, keycode); +} + // handle tethering_req message bool msgproc_tethering_req(ECS_Client* ccli, ECS__TetheringReq* msg) { diff --git a/tizen/src/ecs/ecs_tethering.h b/tizen/src/ecs/ecs_tethering.h index 1acf0787ef..34aaf7bac6 100644 --- a/tizen/src/ecs/ecs_tethering.h +++ b/tizen/src/ecs/ecs_tethering.h @@ -62,3 +62,5 @@ void send_tethering_connection_status_ecp(void); void send_tethering_sensor_data(const char *data, int len); void send_tethering_touch_data(int x, int y, int index, int status); + +void send_tethering_hwkey_data(int keycode); diff --git a/tizen/src/tethering/common.c b/tizen/src/tethering/common.c index 408d919d10..6e11e765d5 100644 --- a/tizen/src/tethering/common.c +++ b/tizen/src/tethering/common.c @@ -43,7 +43,6 @@ #include "common.h" #include "sensor.h" #include "touch.h" -// #include "display.h" #include "emul_state.h" #include "ecs/ecs_tethering.h" #include "genmsg/tethering.pb-c.h" @@ -68,15 +67,6 @@ typedef struct tethering_recv_buf { 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; @@ -110,32 +100,6 @@ 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) { @@ -370,15 +334,12 @@ 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(TETHERING__STATE__ENABLED); if (is_emul_input_touch_enable()) { touch_status = TETHERING__STATE__ENABLED; - // set_tethering_touch_status(ENABLED); } else { touch_status = TETHERING__STATE__DISABLED; - // set_tethering_touch_status(DISABLED); } set_tethering_touch_status(touch_status); @@ -478,28 +439,12 @@ static bool handle_tethering_msg_from_controller(char *data, int len) } break; -#if 0 - case TETHERING__TETHERING_MSG__TYPE__DISPLAY_MSG: - { - Tethering__DisplayMsg *msg = tethering->displaymsg; - - LOG_TRACE("receive display_msg\n"); - if (!msg) { - ret = false; - } else { - msgproc_tethering_display_msg(msg); - } - } - break; -#endif - default: LOG_WARNING("invalid type message\n"); ret = false; break; } -// g_free(data); tethering__tethering_msg__free_unpacked(tethering, NULL); return ret; } @@ -773,7 +718,6 @@ static void tethering_notify_exit(Notifier *notifier, void *data) 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) { @@ -895,12 +839,3 @@ static void *initialize_tethering_socket(void *opaque) return client; } - -#if 0 -static void release_tethering_thread(void *opaque) -{ - TetheringState *client = (TetheringState *)opaque; - - qemu_thread_join(&client->thread); -} -#endif diff --git a/tizen/src/tethering/genmsg/tethering.pb-c.c b/tizen/src/tethering/genmsg/tethering.pb-c.c index 0620a77854..1b4a7e0c36 100644 --- a/tizen/src/tethering/genmsg/tethering.pb-c.c +++ b/tizen/src/tethering/genmsg/tethering.pb-c.c @@ -694,6 +694,49 @@ void tethering__touch_data__free_unpacked PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__touch_data__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } +void tethering__hwkey_msg__init + (Tethering__HWKeyMsg *message) +{ + static Tethering__HWKeyMsg init_value = TETHERING__HWKEY_MSG__INIT; + *message = init_value; +} +size_t tethering__hwkey_msg__get_packed_size + (const Tethering__HWKeyMsg *message) +{ + PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__hwkey_msg__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t tethering__hwkey_msg__pack + (const Tethering__HWKeyMsg *message, + uint8_t *out) +{ + PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__hwkey_msg__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t tethering__hwkey_msg__pack_to_buffer + (const Tethering__HWKeyMsg *message, + ProtobufCBuffer *buffer) +{ + PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__hwkey_msg__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Tethering__HWKeyMsg * + tethering__hwkey_msg__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Tethering__HWKeyMsg *) + protobuf_c_message_unpack (&tethering__hwkey_msg__descriptor, + allocator, len, data); +} +void tethering__hwkey_msg__free_unpacked + (Tethering__HWKeyMsg *message, + ProtobufCAllocator *allocator) +{ + PROTOBUF_C_ASSERT (message->base.descriptor == &tethering__hwkey_msg__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} void tethering__touch_msg__init (Tethering__TouchMsg *message) { @@ -1668,7 +1711,45 @@ const ProtobufCMessageDescriptor tethering__touch_data__descriptor = (ProtobufCMessageInit) tethering__touch_data__init, NULL,NULL,NULL /* reserved[123] */ }; -const ProtobufCEnumValue tethering__touch_msg__type__enum_values_by_number[7] = +static const ProtobufCFieldDescriptor tethering__hwkey_msg__field_descriptors[1] = +{ + { + "type", + 1, + PROTOBUF_C_LABEL_REQUIRED, + PROTOBUF_C_TYPE_ENUM, + 0, /* quantifier_offset */ + PROTOBUF_C_OFFSETOF(Tethering__HWKeyMsg, type), + &tethering__hwkey_type__descriptor, + NULL, + 0, /* packed */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned tethering__hwkey_msg__field_indices_by_name[] = { + 0, /* field[0] = type */ +}; +static const ProtobufCIntRange tethering__hwkey_msg__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor tethering__hwkey_msg__descriptor = +{ + PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + "tethering.HWKeyMsg", + "HWKeyMsg", + "Tethering__HWKeyMsg", + "tethering", + sizeof(Tethering__HWKeyMsg), + 1, + tethering__hwkey_msg__field_descriptors, + tethering__hwkey_msg__field_indices_by_name, + 1, tethering__hwkey_msg__number_ranges, + (ProtobufCMessageInit) tethering__hwkey_msg__init, + NULL,NULL,NULL /* reserved[123] */ +}; +const ProtobufCEnumValue tethering__touch_msg__type__enum_values_by_number[8] = { { "START_REQ", "TETHERING__TOUCH_MSG__TYPE__START_REQ", 2 }, { "START_ANS", "TETHERING__TOUCH_MSG__TYPE__START_ANS", 3 }, @@ -1677,13 +1758,15 @@ const ProtobufCEnumValue tethering__touch_msg__type__enum_values_by_number[7] = { "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 }, + { "HWKEY_MSG", "TETHERING__TOUCH_MSG__TYPE__HWKEY_MSG", 9 }, }; static const ProtobufCIntRange tethering__touch_msg__type__value_ranges[] = { -{2, 0},{0, 7} +{2, 0},{0, 8} }; -const ProtobufCEnumValueIndex tethering__touch_msg__type__enum_values_by_name[7] = +const ProtobufCEnumValueIndex tethering__touch_msg__type__enum_values_by_name[8] = { { "DISPLAY_MSG", 6 }, + { "HWKEY_MSG", 7 }, { "MAX_COUNT", 3 }, { "RESOLUTION", 5 }, { "START_ANS", 1 }, @@ -1698,15 +1781,15 @@ const ProtobufCEnumDescriptor tethering__touch_msg__type__descriptor = "Type", "Tethering__TouchMsg__Type", "tethering", - 7, + 8, tethering__touch_msg__type__enum_values_by_number, - 7, + 8, tethering__touch_msg__type__enum_values_by_name, 1, tethering__touch_msg__type__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -static const ProtobufCFieldDescriptor tethering__touch_msg__field_descriptors[8] = +static const ProtobufCFieldDescriptor tethering__touch_msg__field_descriptors[9] = { { "type", @@ -1804,9 +1887,22 @@ static const ProtobufCFieldDescriptor tethering__touch_msg__field_descriptors[8] 0, /* packed */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "hwkey", + 9, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + PROTOBUF_C_OFFSETOF(Tethering__TouchMsg, hwkey), + &tethering__hwkey_msg__descriptor, + NULL, + 0, /* packed */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned tethering__touch_msg__field_indices_by_name[] = { 7, /* field[7] = display */ + 8, /* field[8] = hwkey */ 4, /* field[4] = maxCount */ 6, /* field[6] = resolution */ 2, /* field[2] = startAns */ @@ -1818,7 +1914,7 @@ static const unsigned tethering__touch_msg__field_indices_by_name[] = { static const ProtobufCIntRange tethering__touch_msg__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 8 } + { 0, 9 } }; const ProtobufCMessageDescriptor tethering__touch_msg__descriptor = { @@ -1828,7 +1924,7 @@ const ProtobufCMessageDescriptor tethering__touch_msg__descriptor = "Tethering__TouchMsg", "tethering", sizeof(Tethering__TouchMsg), - 8, + 9, tethering__touch_msg__field_descriptors, tethering__touch_msg__field_indices_by_name, 1, tethering__touch_msg__number_ranges, @@ -2180,3 +2276,39 @@ const ProtobufCEnumDescriptor tethering__touch_state__descriptor = tethering__touch_state__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; +const ProtobufCEnumValue tethering__hwkey_type__enum_values_by_number[6] = +{ + { "MENU", "TETHERING__HWKEY_TYPE__MENU", 1 }, + { "HOME", "TETHERING__HWKEY_TYPE__HOME", 2 }, + { "BACK", "TETHERING__HWKEY_TYPE__BACK", 3 }, + { "POWER", "TETHERING__HWKEY_TYPE__POWER", 4 }, + { "VOLUME_UP", "TETHERING__HWKEY_TYPE__VOLUME_UP", 5 }, + { "VOLUME_DOWN", "TETHERING__HWKEY_TYPE__VOLUME_DOWN", 6 }, +}; +static const ProtobufCIntRange tethering__hwkey_type__value_ranges[] = { +{1, 0},{0, 6} +}; +const ProtobufCEnumValueIndex tethering__hwkey_type__enum_values_by_name[6] = +{ + { "BACK", 2 }, + { "HOME", 1 }, + { "MENU", 0 }, + { "POWER", 3 }, + { "VOLUME_DOWN", 5 }, + { "VOLUME_UP", 4 }, +}; +const ProtobufCEnumDescriptor tethering__hwkey_type__descriptor = +{ + PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + "tethering.HWKeyType", + "HWKeyType", + "Tethering__HWKeyType", + "tethering", + 6, + tethering__hwkey_type__enum_values_by_number, + 6, + tethering__hwkey_type__enum_values_by_name, + 1, + tethering__hwkey_type__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; diff --git a/tizen/src/tethering/genmsg/tethering.pb-c.h b/tizen/src/tethering/genmsg/tethering.pb-c.h index a2fc95751d..c2049b36bf 100644 --- a/tizen/src/tethering/genmsg/tethering.pb-c.h +++ b/tizen/src/tethering/genmsg/tethering.pb-c.h @@ -24,6 +24,7 @@ typedef struct _Tethering__Resolution Tethering__Resolution; typedef struct _Tethering__DisplayMsg Tethering__DisplayMsg; typedef struct _Tethering__TouchMaxCount Tethering__TouchMaxCount; typedef struct _Tethering__TouchData Tethering__TouchData; +typedef struct _Tethering__HWKeyMsg Tethering__HWKeyMsg; typedef struct _Tethering__TouchMsg Tethering__TouchMsg; typedef struct _Tethering__TetheringMsg Tethering__TetheringMsg; @@ -50,7 +51,8 @@ typedef enum _Tethering__TouchMsg__Type { 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__TOUCH_MSG__TYPE__DISPLAY_MSG = 8, + TETHERING__TOUCH_MSG__TYPE__HWKEY_MSG = 9 } Tethering__TouchMsg__Type; typedef enum _Tethering__TetheringMsg__Type { TETHERING__TETHERING_MSG__TYPE__HANDSHAKE_REQ = 2, @@ -90,6 +92,14 @@ typedef enum _Tethering__TouchState { TETHERING__TOUCH_STATE__PRESSED = 1, TETHERING__TOUCH_STATE__RELEASED = 2 } Tethering__TouchState; +typedef enum _Tethering__HWKeyType { + TETHERING__HWKEY_TYPE__MENU = 1, + TETHERING__HWKEY_TYPE__HOME = 2, + TETHERING__HWKEY_TYPE__BACK = 3, + TETHERING__HWKEY_TYPE__POWER = 4, + TETHERING__HWKEY_TYPE__VOLUME_UP = 5, + TETHERING__HWKEY_TYPE__VOLUME_DOWN = 6 +} Tethering__HWKeyType; /* --- messages --- */ @@ -280,6 +290,16 @@ struct _Tethering__TouchData , 0,0, 0,0, 0,0, 0,0 } +struct _Tethering__HWKeyMsg +{ + ProtobufCMessage base; + Tethering__HWKeyType type; +}; +#define TETHERING__HWKEY_MSG__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&tethering__hwkey_msg__descriptor) \ + , 0 } + + struct _Tethering__TouchMsg { ProtobufCMessage base; @@ -291,10 +311,11 @@ struct _Tethering__TouchMsg Tethering__TouchData *touchdata; Tethering__Resolution *resolution; Tethering__DisplayMsg *display; + Tethering__HWKeyMsg *hwkey; }; #define TETHERING__TOUCH_MSG__INIT \ { PROTOBUF_C_MESSAGE_INIT (&tethering__touch_msg__descriptor) \ - , 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL } + , 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } struct _Tethering__TetheringMsg @@ -618,6 +639,25 @@ Tethering__TouchData * void tethering__touch_data__free_unpacked (Tethering__TouchData *message, ProtobufCAllocator *allocator); +/* Tethering__HWKeyMsg methods */ +void tethering__hwkey_msg__init + (Tethering__HWKeyMsg *message); +size_t tethering__hwkey_msg__get_packed_size + (const Tethering__HWKeyMsg *message); +size_t tethering__hwkey_msg__pack + (const Tethering__HWKeyMsg *message, + uint8_t *out); +size_t tethering__hwkey_msg__pack_to_buffer + (const Tethering__HWKeyMsg *message, + ProtobufCBuffer *buffer); +Tethering__HWKeyMsg * + tethering__hwkey_msg__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void tethering__hwkey_msg__free_unpacked + (Tethering__HWKeyMsg *message, + ProtobufCAllocator *allocator); /* Tethering__TouchMsg methods */ void tethering__touch_msg__init (Tethering__TouchMsg *message); @@ -706,6 +746,9 @@ typedef void (*Tethering__TouchMaxCount_Closure) typedef void (*Tethering__TouchData_Closure) (const Tethering__TouchData *message, void *closure_data); +typedef void (*Tethering__HWKeyMsg_Closure) + (const Tethering__HWKeyMsg *message, + void *closure_data); typedef void (*Tethering__TouchMsg_Closure) (const Tethering__TouchMsg *message, void *closure_data); @@ -724,6 +767,7 @@ extern const ProtobufCEnumDescriptor tethering__event_type__descriptor; extern const ProtobufCEnumDescriptor tethering__state__descriptor; extern const ProtobufCEnumDescriptor tethering__sensor_type__descriptor; extern const ProtobufCEnumDescriptor tethering__touch_state__descriptor; +extern const ProtobufCEnumDescriptor tethering__hwkey_type__descriptor; extern const ProtobufCMessageDescriptor tethering__hand_shake_req__descriptor; extern const ProtobufCMessageDescriptor tethering__hand_shake_ans__descriptor; extern const ProtobufCMessageDescriptor tethering__emulator_state__descriptor; @@ -742,6 +786,7 @@ extern const ProtobufCMessageDescriptor tethering__resolution__descriptor; extern const ProtobufCMessageDescriptor tethering__display_msg__descriptor; extern const ProtobufCMessageDescriptor tethering__touch_max_count__descriptor; extern const ProtobufCMessageDescriptor tethering__touch_data__descriptor; +extern const ProtobufCMessageDescriptor tethering__hwkey_msg__descriptor; extern const ProtobufCMessageDescriptor tethering__touch_msg__descriptor; extern const ProtobufCEnumDescriptor tethering__touch_msg__type__descriptor; extern const ProtobufCMessageDescriptor tethering__tethering_msg__descriptor; diff --git a/tizen/src/tethering/msg/tethering.proto b/tizen/src/tethering/msg/tethering.proto index cf1c01cbce..01988bc394 100644 --- a/tizen/src/tethering/msg/tethering.proto +++ b/tizen/src/tethering/msg/tethering.proto @@ -158,6 +158,19 @@ message TouchData { optional TouchState state = 4; } +enum HWKeyType { + MENU = 1; + HOME = 2; + BACK = 3; + POWER = 4; + VOLUME_UP = 5; + VOLUME_DOWN = 6; +} + +message HWKeyMsg { + required HWKeyType type = 1; +} + message TouchMsg { enum Type { START_REQ = 2; @@ -167,6 +180,7 @@ message TouchMsg { TOUCH_DATA = 6; RESOLUTION = 7; DISPLAY_MSG = 8; + HWKEY_MSG = 9; } required Type type = 1; optional StartReq startReq = 2; @@ -176,6 +190,7 @@ message TouchMsg { optional TouchData touchData = 6; optional Resolution resolution = 7; optional DisplayMsg display = 8; + optional HWKeyMsg hwkey = 9; } message TetheringMsg { diff --git a/tizen/src/tethering/sensor.c b/tizen/src/tethering/sensor.c index 14589e5b3c..567427d645 100644 --- a/tizen/src/tethering/sensor.c +++ b/tizen/src/tethering/sensor.c @@ -70,35 +70,6 @@ enum sensor_level { 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) { @@ -245,9 +216,6 @@ bool msgproc_tethering_sensor_msg(void *message) case TETHERING__SENSOR_MSG__TYPE__START_REQ: LOG_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); diff --git a/tizen/src/tethering/touch.c b/tizen/src/tethering/touch.c index 625cbbfb7d..85f067cd9d 100644 --- a/tizen/src/tethering/touch.c +++ b/tizen/src/tethering/touch.c @@ -39,50 +39,11 @@ DECLARE_DEBUG_CHANNEL(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; - -// static void set_touch_event_status(bool status); static bool send_display_image_data(void); -#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 +#define HARD_KEY_MENU 169 +#define HARD_KEY_BACK 158 static bool build_touch_msg(Tethering__TouchMsg *touch) { @@ -199,21 +160,13 @@ static bool send_set_touch_resolution(void) return ret; } -#if 0 -static void set_touch_event_status(bool status) -{ - is_touch_event = status; - - LOG_TRACE("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_ ; + keycode = HARD_KEY_MENU; break; case TETHERING__HWKEY_TYPE__HOME: @@ -221,18 +174,18 @@ static void set_hwkey_data(Tethering__HWKeyMsg *msg) break; case TETHERING__HWKEY_TYPE__BACK: - // keycode = ; + keycode = HARD_KEY_BACK; break; case TETHERING__HWKEY_TYPE__POWER: keycode = HARD_KEY_POWER; break; - case TETHERING__HWKEY_TYPE__VOLUMEUP: + case TETHERING__HWKEY_TYPE__VOLUME_UP: keycode = HARD_KEY_VOL_UP; break; - case TETHERING__HWKEY_TYPE__VOLUMEDOWN: + case TETHERING__HWKEY_TYPE__VOLUME_DOWN: keycode = HARD_KEY_VOL_DOWN; break; @@ -243,7 +196,6 @@ static void set_hwkey_data(Tethering__HWKeyMsg *msg) LOG_TRACE("convert hwkey msg to keycode: %d\n", keycode); send_tethering_hwkey_data(keycode); } -#endif static bool is_display_dirty = false; @@ -253,50 +205,43 @@ void set_display_dirty(bool dirty) is_display_dirty = dirty; } -// 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: LOG_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: LOG_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: + LOG_TRACE("TOUCH_MSG_TYPE_TOUCH_DATA\n"); set_touch_data(msg->touchdata); break; case TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG: + LOG_TRACE("TOUCH_MSG_TYPE_DISPLAY_MSG\n"); + if (is_display_dirty) { + LOG_TRACE("display dirty status!! send the image\n"); + send_display_image_data(); is_display_dirty = false; } break; -#if 0 case TETHERING__TOUCH_MSG__TYPE__HWKEY_MSG: + LOG_TRACE("TOUCH_MSG_TYPE_HWKEY_MSG\n"); set_hwkey_data(msg->hwkey); break; -#endif + default: LOG_TRACE("invalid touch_msg\n"); ret = false; -- 2.34.1