From 260f2a71380d63c29d178499999712a51a2c5108 Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Fri, 17 Aug 2012 13:12:34 +0900 Subject: [PATCH] [Title] rearrange multi-touch points when rotation/scaling [Type] feature [Module] Emulator / touch [Priority] major [Jira#] N_SE-7078 [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- tizen/src/maru_finger.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++- tizen/src/maru_finger.h | 1 + tizen/src/maru_sdl.c | 8 +++--- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/tizen/src/maru_finger.c b/tizen/src/maru_finger.c index bc0a6ac..c47e564 100644 --- a/tizen/src/maru_finger.c +++ b/tizen/src/maru_finger.c @@ -426,9 +426,77 @@ void maru_finger_processing_B(int touch_type, int origin_x, int origin_y, int x, } } +static bool _calculate_origin_coordinates(int scaled_lcd_w, int scaled_lcd_h, + double scale_factor, int rotaton_type, FingerPoint *finger) +{ + int point_x, point_y, rotated_point_x, rotated_point_y, flag; + + flag = 0; + + rotated_point_x = point_x = (int)(finger->x * scale_factor); + rotated_point_y = point_y = (int)(finger->y * scale_factor); + + if (rotaton_type == ROTATION_LANDSCAPE) { + rotated_point_x = point_y; + rotated_point_y = scaled_lcd_w - point_x; + } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) { + rotated_point_x = scaled_lcd_w - point_x; + rotated_point_y = scaled_lcd_h - point_y; + } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) { + rotated_point_x = scaled_lcd_h - point_y; + rotated_point_y = point_x; + } + + if (finger->origin_x != rotated_point_x) { + finger->origin_x = rotated_point_x; + flag = 1; + } + if (finger->origin_y != rotated_point_y) { + finger->origin_y = rotated_point_y; + flag = 1; + } + + if (flag) { + return true; + } + + return false; +} + +int rearrange_finger_points(int lcd_w, int lcd_h, double scale_factor, int rotaton_type) +{ + int i = 0; + int count = 0; + MultiTouchState *mts = get_emul_multi_touch_state(); + FingerPoint *finger = NULL; + + if (mts->multitouch_enable == 0) { + return 0; + } + + lcd_w *= scale_factor; + lcd_h *= scale_factor; + + for (i = 0; i < mts->finger_cnt; i++) { + finger = get_finger_point_from_slot(i); + if (finger != NULL && finger->id != 0) { + if (_calculate_origin_coordinates(lcd_w, lcd_h, + scale_factor, rotaton_type, finger) == true) { + count++; + } + } + } + + if (count != 0) { + _grab_finger_id = 0; + } + + return count; +} + void clear_finger_slot(void) { - int i; + int i = 0; MultiTouchState *mts = get_emul_multi_touch_state(); FingerPoint *finger = NULL; diff --git a/tizen/src/maru_finger.h b/tizen/src/maru_finger.h index 08bbbec..afc6564 100644 --- a/tizen/src/maru_finger.h +++ b/tizen/src/maru_finger.h @@ -67,6 +67,7 @@ FingerPoint *get_finger_point_from_slot(int index); FingerPoint *get_finger_point_search(int x, int y); void maru_finger_processing_A(int touch_type, int origin_x, int origin_y, int x, int y); void maru_finger_processing_B(int touch_type, int origin_x, int origin_y, int x, int y); +int rearrange_finger_points(int lcd_w, int lcd_h, double scale_factor, int rotaton_type); void clear_finger_slot(void); void cleanup_multi_touch_state(void); diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index e31c640..21cbaaa 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -239,9 +239,11 @@ static void _sdl_init(void) //glGenerateMipmapEXT(GL_TEXTURE_2D); // GL_MIPMAP_LINEAR } - /* remove multi-touch finger points */ - get_emul_multi_touch_state()->multitouch_enable = 0; - clear_finger_slot(); + /* rearrange multi-touch finger points */ + if (get_emul_multi_touch_state()->multitouch_enable == 1) { + rearrange_finger_points(get_emul_lcd_width(), get_emul_lcd_height(), + current_scale_factor, rotaton_type); + } } static int point_degree = 0; -- 2.7.4