From: GiWoong Kim Date: Wed, 25 Sep 2013 08:30:39 +0000 (+0900) Subject: sensor: added legacy do_rotation_event function X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~723 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d14ee3e3be068fc9956238f17e49c9ec77aca0c7;p=sdk%2Femulator%2Fqemu.git sensor: added legacy do_rotation_event function Change-Id: I3e7082740c2c480efa435201e5df0eb6a232fc36 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ecs/ecs.h b/tizen/src/ecs/ecs.h index f6afd82250..9283747e3c 100644 --- a/tizen/src/ecs/ecs.h +++ b/tizen/src/ecs/ecs.h @@ -176,6 +176,7 @@ enum{ }; /* request */ +int accel_min_max(double value); void req_set_sensor_accel(int x, int y, int z); // control sub messages diff --git a/tizen/src/ecs/ecs_sensor.c b/tizen/src/ecs/ecs_sensor.c index 114d6027f7..666eff70dc 100644 --- a/tizen/src/ecs/ecs_sensor.c +++ b/tizen/src/ecs/ecs_sensor.c @@ -76,17 +76,22 @@ static int get_parse_val (const char* buf, char* tmp) return index; } -static int accel_min_max(char* tmp) +int accel_min_max(double value) { - int value = (int)(atof(tmp) * ACCEL_ADJUST); + int result = (int)(value * ACCEL_ADJUST); - if (value > ACCEL_MAX) - value = ACCEL_MAX; + if (result > ACCEL_MAX) + result = ACCEL_MAX; - if (value < -ACCEL_MAX) - value = -ACCEL_MAX; + if (result < -ACCEL_MAX) + result = -ACCEL_MAX; - return value; + return result; +} + +static int _accel_min_max(char* tmp) +{ + return accel_min_max(atof(tmp)); } void req_set_sensor_accel(int x, int y, int z) @@ -108,15 +113,15 @@ static void _req_set_sensor_accel(int len, const char* data) // x len += get_parse_val(data + len, tmp); - x = accel_min_max(tmp); + x = _accel_min_max(tmp); // y len += get_parse_val(data + len, tmp); - y = accel_min_max(tmp); + y = _accel_min_max(tmp); // z len += get_parse_val(data + len, tmp); - z = accel_min_max(tmp); + z = _accel_min_max(tmp); memset(tmp, 0, TEMP_BUF_SIZE); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index eb25da68ba..988648c371 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -322,26 +322,27 @@ void do_rotation_event(int rotation_type) { INFO("do_rotation_event rotation_type : %d\n", rotation_type); +#if 0 int x = 0, y = 0, z = 0; switch (rotation_type) { case ROTATION_PORTRAIT: x = 0; - y = 9.80665; + y = accel_min_max(9.80665); z = 0; break; case ROTATION_LANDSCAPE: - x = 9.80665; + x = accel_min_max(9.80665); y = 0; z = 0; break; case ROTATION_REVERSE_PORTRAIT: x = 0; - y = -9.80665; + y = accel_min_max(-9.80665); z = 0; break; case ROTATION_REVERSE_LANDSCAPE: - x = -9.80665; + x = accel_min_max(-9.80665); y = 0; z = 0; break; @@ -350,6 +351,29 @@ void do_rotation_event(int rotation_type) } req_set_sensor_accel(x, y, z); +#else + char send_buf[32] = { 0 }; + + switch ( rotation_type ) { + case ROTATION_PORTRAIT: + sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" ); + break; + case ROTATION_LANDSCAPE: + sprintf( send_buf, "1\n3\n9.80665\n0\n0\n" ); + break; + case ROTATION_REVERSE_PORTRAIT: + sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" ); + break; + case ROTATION_REVERSE_LANDSCAPE: + sprintf(send_buf, "1\n3\n-9.80665\n0\n0\n"); + break; + + default: + break; + } + + send_to_emuld( "sensor\n\n\n\n", 10, send_buf, 32 ); +#endif } void set_maru_screenshot(DisplaySurface *surface)