Those functions are required to give connection infomation to ECP-UI and ECP-CLI.
Change-Id: Ibc65454fe1621fe98283aff4dbb5eb93c8294736
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
#include "../tethering/sensor.h"
#include "../tethering/touch.h"
#include "../hw/maru_virtio_touchscreen.h"
+#include "../hw/maru_virtio_hwkey.h"
#include "../debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, ecs_tethering);
#define MSG_BUF_SIZE 255
#define MSG_LEN_SIZE 4
-// static bool send_tethering_ntf(const char *data, const int len);
+#define PRESSED 1
+#define RELEASED 2
+
static bool send_tethering_ntf(const char *data);
static void send_tethering_status_ntf(type_group group, type_action action);
ECS_TETHERING_MSG_ACTION_CONNECTION_STATUS);
}
+#if 0
static void send_tethering_port_ecp(void)
{
type_length length;
}
TRACE(">> send port_num: %d\n", tethering_port);
-
g_snprintf(data, sizeof(data) - 1, "%d", tethering_port);
length = strlen(data);
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) {
g_free(msg);
}
}
+#endif
+
+static void send_tethering_connection_info(void)
+{
+ type_length length;
+ type_group group = ECS_TETHERING_MSG_GROUP_ECP;
+ type_action action = ECS_TETHERING_MSG_ACTION_CONNECT;
+ uint8_t *msg = NULL;
+ gchar data[64];
+
+ msg = g_malloc(MSG_BUF_SIZE);
+ if (!msg) {
+ ERR("failed to allocate memory\n");
+ return;
+ }
+
+ INFO(">> send port_num: %d\n", tethering_port);
+ {
+ const char *ip = get_tethering_connected_ipaddr();
+ int port = get_tethering_connected_port();
+
+ if (!ip) {
+ ERR("invalid connected ip\n");
+ return;
+ }
+
+ if (!port) {
+ ERR("invalid connected port\n");
+ return;
+ }
+ g_snprintf(data, sizeof(data) - 1, "%s:%d", ip, port);
+ length = strlen(data);
+ data[length] = '\0';
+ }
+
+ memcpy(msg, ECS_TETHERING_MSG_CATEGORY, 10);
+ memcpy(msg + 10, &length, sizeof(unsigned short));
+ memcpy(msg + 12, &group, sizeof(unsigned char));
+ memcpy(msg + 13, &action, sizeof(unsigned char));
+ memcpy(msg + 14, data, length);
+
+ INFO(">> send connection msg to ecp. "
+ "action=%d, group=%d, data=%s length=%d\n",
+ action, group, data, length);
+
+ send_tethering_ntf((const char *)msg);
+
+ g_free(msg);
+}
static void send_tethering_status_ntf(type_group group, type_action action)
{
gchar data[2];
switch (action) {
- case ECS_TETHERING_MSG_ACTION_CONNECTION_STATUS:
- status = get_tethering_connection_status();
- if (status == CONNECTED) {
- send_tethering_port_ecp();
- }
- break;
- case ECS_TETHERING_MSG_ACTION_SENSOR_STATUS:
- status = get_tethering_sensor_status();
- break;
- case ECS_TETHERING_MSG_ACTION_TOUCH_STATUS:
- status = get_tethering_touch_status();
- break;
- default:
- break;
+ case ECS_TETHERING_MSG_ACTION_CONNECTION_STATUS:
+ status = get_tethering_connection_status();
+ if (status == CONNECTED) {
+ send_tethering_connection_info();
+ }
+ break;
+ case ECS_TETHERING_MSG_ACTION_SENSOR_STATUS:
+ status = get_tethering_sensor_status();
+ break;
+ case ECS_TETHERING_MSG_ACTION_TOUCH_STATUS:
+ status = get_tethering_touch_status();
+ break;
+ default:
+ break;
}
msg = g_malloc(MSG_BUF_SIZE);
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) {
}
}
-// static bool send_tethering_ntf(const char *data, const int len)
static bool send_tethering_ntf(const char *data)
{
type_length length = 0;
const char* ijdata = (data + catsize + 2 + 1 + 1);
- TRACE("<< header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
+ TRACE(">> header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
ECS__Master master = ECS__MASTER__INIT;
ECS__TetheringNtf ntf = ECS__TETHERING_NTF__INIT;
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)
{
gchar cmd[10] = {0};
gchar **server_addr = NULL;
+ TRACE("enter %s\n", __func__);
+
g_strlcpy(cmd, msg->category, sizeof(cmd));
type_length length = (type_length) msg->length;
type_group group = (type_group) (msg->group & 0xff);
type_action action = (type_action) (msg->action & 0xff);
- TRACE(">> header = cmd = %s, length = %d, action=%d, group=%d\n",
+ TRACE("<< header = cmd = %s, length = %d, action=%d, group=%d\n",
cmd, length, action, group);
- if (group == ECS_TETHERING_MSG_GROUP_ECP) {
- switch(action) {
+ switch(action) {
case ECS_TETHERING_MSG_ACTION_CONNECT:
- {
- // get ip address and port
+ INFO("MSG_ACTION_CONNECT\n");
+
if (msg->data.data && msg->data.len > 0) {
const gchar *data = (const gchar *)msg->data.data;
gchar *ip_address = NULL;
} else {
ERR("failed to parse port number\n");
}
-
- TRACE("MSG_ACTION_CONNECT");
TRACE("len = %zd, data\" %s\"", strlen(data), data);
connect_tethering_app(ip_address, port);
TRACE(">> port_num: %d, %d\n", port, tethering_port);
g_free(ip_address);
-
g_strfreev(server_addr);
+ } else {
+ INFO("ip address and port value are null\n");
}
- }
break;
case ECS_TETHERING_MSG_ACTION_DISCONNECT:
INFO(">> MSG_ACTION_DISCONNECT\n");
break;
default:
break;
- }
}
+ TRACE("leave %s\n", __func__);
+
return true;
}
* define tethering messages between ecs and ecp
*/
#define ECS_TETHERING_MSG_CATEGORY "tethering"
-
#define ECS_TETHERING_MSG_GROUP_ECP 1
-// #define TETHERING_MSG_GROUP_USB
-// #define TETHERING_MSG_GROUP_WIFI
-
-#if 0
-#define ECS_TETHERING_MSG_ACTION_CONNECT 1
-#define ECS_TETHERING_MSG_ACTION_DISCONNECT 2
-#define ECS_TETHERING_MSG_ACTION_CONNECTION_STATUS 3
-#define ECS_TETHERING_MSG_ACTION_SENSOR_STATUS 4
-#define ECS_TETHERING_MSG_ACTION_TOUCH_STATUS 5
-#endif
enum ECS_TETHERING_MSG_ACTION {
ECS_TETHERING_MSG_ACTION_CONNECT = 1,
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);
+
* - S-Core Co., Ltd
*
*/
+
#ifndef __WIN32
#include <sys/ioctl.h>
#else
#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"
#define SEND_BUF_MAX_SIZE 4096
static const char *loopback = "127.0.0.1";
+enum connection_type {
+ NONE = 0,
+ USB,
+ WIFI,
+};
+
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;
// connection state
int status;
+ int type;
// receiver handling thread
QemuThread thread;
} TetheringState;
-static TetheringState *tethering_client;
+static TetheringState *tethering_client = NULL;
static tethering_recv_buf recv_buf;
-// static bool app_state = false;
static void end_tethering_socket(int sockfd);
static void set_tethering_connection_status(int status);
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)
{
// message handlers
static void msgproc_tethering_handshake_ans(Tethering__HandShakeAns *msg)
{
- // FIXME: handle handshake answer
- // ans = msg->result;
+ // handle handshake answer
}
static void msgproc_app_state_msg(Tethering__AppState *msg)
set_tethering_touch_status(status);
disconnect_tethering_app();
- } else {
- // does nothing
}
}
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);
}
break;
-#if 0
- case TETHERING__TETHERING_MSG__TYPE__DISPLAY_MSG:
- {
- Tethering__DisplayMsg *msg = tethering->displaymsg;
-
- TRACE("receive display_msg\n");
- if (!msg) {
- ret = false;
- } else {
- msgproc_tethering_display_msg(msg);
- }
- }
- break;
-#endif
-
default:
TRACE("invalid type message\n");
ret = false;
break;
}
-// g_free(data);
tethering__tethering_msg__free_unpacked(tethering, NULL);
return ret;
}
static int start_tethering_socket(const char *ipaddress, int port)
{
struct sockaddr_in addr;
-
- int sock = -1;
- int ret = 0;
+ int sock = -1, ret = 0;
addr.sin_family = AF_INET;
addr.sin_port = htons(port); // i.e. 1234
INFO("server ip address: %s, port: %d\n", ipaddress, port);
ret = inet_aton(ipaddress, &addr.sin_addr);
-
if (ret == 0) {
ERR("inet_aton failure\n");
return -1;
int status = 0;
if (!tethering_client) {
- return -1;
+ INFO("tethering_client is null\n");
+ INFO("tetherging connection status: %d\n", status);
+ return DISCONNECTED;
}
qemu_mutex_lock(&tethering_client->mutex);
status = tethering_client->status;
qemu_mutex_unlock(&tethering_client->mutex);
+ INFO("tetherging connection status: %d\n", status);
+
return status;
}
+int get_tethering_connected_port(void)
+{
+ if (!tethering_client) {
+ ERR("tethering_client is null\n");
+ return 0;
+ }
+
+ ERR("connected port: %d\n", tethering_client->port);
+ return tethering_client->port;
+}
+
+const char *get_tethering_connected_ipaddr(void)
+{
+ if (!tethering_client) {
+ ERR("tethering client is null\n");
+ return NULL;
+ }
+
+ TRACE("connected ip address: %s\n", tethering_client->ipaddress);
+ return tethering_client->ipaddress;
+}
+
static void set_tethering_connection_status(int status)
{
if (!tethering_client) {
}
static void *initialize_tethering_socket(void *opaque);
-// static void release_tethering_thread(void *opaque);
int connect_tethering_app(const char *ipaddress, int port)
{
if (ipaddress) {
ipaddr_len = strlen(ipaddress);
+ client->type = WIFI;
} else {
ipaddr_len = strlen(loopback);
ipaddress = loopback;
+ client->type = USB;
}
client->ipaddress = g_malloc0(ipaddr_len + 1);
if (!client->ipaddress) {
+ ERR("failed to allocate ipaddress buffer\n");
g_free(client);
return -1;
}
+
g_strlcpy(client->ipaddress, ipaddress, ipaddr_len + 1);
+ INFO("connection info. ip %s, port %d type %d\n",
+ client->ipaddress, client->port, client->type);
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);
sock = tethering_client->fd;
if (sock < 0) {
- ERR("tethering socket is terminated or not ready\n");
+ ERR("tethering socket is already terminated or not ready\n");
return -1;
} else {
send_emul_state_msg();
return client;
}
-
-#if 0
-static void release_tethering_thread(void *opaque)
-{
- TetheringState *client = (TetheringState *)opaque;
-
- qemu_thread_join(&client->thread);
-}
-#endif
*
*/
-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,
+ DISCONNECTED = 0,
+ CONNECTED,
CONNECTING,
CONNREFUSED,
};
int get_tethering_connection_status(void);
-int add_input_device(void *opaque);
+int get_tethering_connected_port(void);
+
+const char *get_tethering_connected_ipaddr(void);
\ No newline at end of file
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)
{
(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 },
{ "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 },
"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",
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 */
static const ProtobufCIntRange tethering__touch_msg__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 8 }
+ { 0, 9 }
};
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,
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] */
+};
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;
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,
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 --- */
, 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;
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
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);
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);
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;
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;
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;
TOUCH_DATA = 6;
RESOLUTION = 7;
DISPLAY_MSG = 8;
+ HWKEY_MSG = 9;
}
required Type type = 1;
optional StartReq startReq = 2;
optional TouchData touchData = 6;
optional Resolution resolution = 7;
optional DisplayMsg display = 8;
+ optional HWKeyMsg hwkey = 9;
}
message TetheringMsg {
#define EISCONN WSAEISCONN
#endif
-#include "qemu-common.h"
#include "qemu/main-loop.h"
#include "qemu/sockets.h"
#include "ui/console.h"
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;
- }
+#define ACCEL_ADJUST 100000
+#define GYRO_ADJUST 17.50
- 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
+static int sensor_device_status;
// create a sensor message.
static bool build_sensor_msg(Tethering__SensorMsg *sensor)
{
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);
+ sprintf(tmp, "%d\n%d\n%lf\n%lf\n%lf\n",
+ level_accel, 3, (atof(data->x) * ACCEL_ADJUST),
+ (atof(data->y) * ACCEL_ADJUST), (atof(data->z) * ACCEL_ADJUST));
send_tethering_sensor_data(tmp, strlen(tmp));
TRACE("sensor_accel x: %s, y: %s, z: %s\n",
{
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);
+ sprintf(tmp, "%d\n%d\n%lf\n%lf\n%lf\n",
+ level_gyro, 3, (atof(data->x) / GYRO_ADJUST),
+ (atof(data->y) / GYRO_ADJUST), (atof(data->z) / GYRO_ADJUST));
send_tethering_sensor_data(tmp, strlen(tmp));
TRACE("sensor_gyro x: %s, y: %s, z: %s\n",
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);
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;
-
-// 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)
{
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_ ;
+ keycode = HARD_KEY_MENU;
break;
case TETHERING__HWKEY_TYPE__HOME:
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;
INFO("convert hwkey msg to keycode: %d\n", keycode);
send_tethering_hwkey_data(keycode);
}
-#endif
static bool is_display_dirty = false;
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:
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:
+ TRACE("TOUCH_MSG_TYPE_TOUCH_DATA\n");
set_touch_data(msg->touchdata);
break;
case TETHERING__TOUCH_MSG__TYPE__DISPLAY_MSG:
+ TRACE("TOUCH_MSG_TYPE_DISPLAY_MSG\n");
+
if (is_display_dirty) {
+ 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:
+ TRACE("TOUCH_MSG_TYPE_HWKEY_MSG\n");
set_hwkey_data(msg->hwkey);
break;
-#endif
+
default:
TRACE("invalid touch_msg\n");
ret = false;