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