touch: modified multi-touch mode 3
authorGiWoong Kim <giwoong.kim@samsung.com>
Thu, 1 Jan 2015 08:18:24 +0000 (17:18 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Thu, 1 Jan 2015 08:54:27 +0000 (17:54 +0900)
supports sigle finger point dragging
disable multi-touch mode if the another key is pressed while
multi-touching

Change-Id: I1ea40d4d737bc0bfd8ba0845592a5e21027cd511
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/maru_finger.c
tizen/src/skin/maruskin_operation.c

index b924861a2792f5e7d381a6b8a1ceab961b599a22..979e1ee0d54a196e9e511c6dbc7368afa18c75be 100644 (file)
@@ -356,6 +356,7 @@ void maru_finger_processing_1(
 
         if (mts->finger_cnt == 0)
         { /* first finger touch input */
+            INFO("multi-touch mode 1 processing");
 
             if (add_finger_point(origin_x, origin_y, x, y) == -1) {
                 return;
@@ -386,7 +387,7 @@ void maru_finger_processing_1(
                 finger->x = x;
                 finger->y = y;
                 if (finger->id != 0) {
-                    INFO("%d finger touching\n", finger->id);
+                    INFO("id %d finger touching\n", finger->id);
                     virtio_touchscreen_event(x, y,
                         mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
                 }
@@ -394,7 +395,10 @@ void maru_finger_processing_1(
         }
         else /* one more finger */
         {
-            add_finger_point(origin_x, origin_y, x, y);
+            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
+                return;
+            }
+
             virtio_touchscreen_event(x, y,
                 mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
         }
@@ -475,6 +479,7 @@ void maru_finger_processing_2(
 
         if (mts->finger_cnt == 0)
         { /* first finger touch input */
+            INFO("multi-touch mode 2 processing");
 
             if (add_finger_point(origin_x, origin_y, x, y) == -1) {
                 return;
@@ -496,7 +501,10 @@ void maru_finger_processing_2(
         }
         else /* one more finger */
         {
-            add_finger_point(origin_x, origin_y, x, y);
+            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
+                return;
+            }
+
             virtio_touchscreen_event(x, y,
                 mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
         }
@@ -513,35 +521,14 @@ void maru_finger_processing_3(
     FingerPoint *finger = NULL;
 
     if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */
-        if (_grab_finger_id > 0 && _grab_finger_id <= 2) {
-            FingerPoint *finger1 = get_finger_point_from_slot(0);
-            FingerPoint *finger2 = get_finger_point_from_slot(1);
-            if (finger1 != NULL && finger2 != NULL) {
-                FingerPoint *co_finger = NULL;
-
-                if (_grab_finger_id == 2) {
-                    finger = finger2;
-                    co_finger = finger1;
-                } else {
-                    finger = finger1;
-                    co_finger = finger2;
-                }
-
+        if (_grab_finger_id > 0) {
+            finger = get_finger_point_from_slot(_grab_finger_id - 1);
+            if (finger != NULL && _grab_finger_id <= 2) {
                 const int origin_distance_x = origin_x - finger->origin_x;
                 const int origin_distance_y = origin_y - finger->origin_y;
                 const int distance_x = x - finger->x;
                 const int distance_y = y - finger->y;
 
-                /* bounds checking */
-                if ((co_finger->x - distance_x) >= get_emul_resolution_width() ||
-                    (co_finger->x - distance_x) < 0 ||
-                    (co_finger->y - distance_y) >= get_emul_resolution_height() ||
-                    (co_finger->y - distance_y) < 0) {
-                    TRACE("id %d finger is out of bounds (%d, %d)\n",
-                        co_finger->id, co_finger->x - distance_x, co_finger->y - distance_y);
-                    return;
-                }
-
                 /* move */
                 finger->origin_x += origin_distance_x;
                 finger->origin_y += origin_distance_y;
@@ -554,23 +541,41 @@ void maru_finger_processing_3(
                         finger->id, x, y);
                 }
 
-                co_finger->origin_x -= origin_distance_x;
-                co_finger->origin_y -= origin_distance_y;
-                co_finger->x -= distance_x;
-                co_finger->y -= distance_y;
-                if (co_finger->id != 0) {
-                    virtio_touchscreen_event(x, y,
-                        co_finger->id - 1, QEMU_MOUSE_PRESSED);
-                    TRACE("id %d finger multi-touch dragging : (%d, %d)\n",
-                        co_finger->id, x, y);
+                if (mts->finger_cnt > 1) {
+                    FingerPoint *co_finger = get_finger_point_from_slot(
+                         (_grab_finger_id == 2) ? 0 : 1);
+                    if (co_finger != NULL) {
+                        /* bounds checking */
+                        if ((co_finger->x - distance_x) >= get_emul_resolution_width() ||
+                            (co_finger->x - distance_x) < 0 ||
+                            (co_finger->y - distance_y) >= get_emul_resolution_height() ||
+                            (co_finger->y - distance_y) < 0) {
+                            TRACE("id %d finger is out of bounds (%d, %d)\n",
+                                co_finger->id, co_finger->x - distance_x, co_finger->y - distance_y);
+                            return;
+                        }
+
+                        /* move */
+                        co_finger->origin_x -= origin_distance_x;
+                        co_finger->origin_y -= origin_distance_y;
+                        co_finger->x -= distance_x;
+                        co_finger->y -= distance_y;
+                        if (co_finger->id != 0) {
+                            virtio_touchscreen_event(co_finger->x, co_finger->y,
+                                co_finger->id - 1, QEMU_MOUSE_PRESSED);
+                            TRACE("id %d finger multi-touch dragging : (%d, %d)\n",
+                                co_finger->id, co_finger->x, co_finger->y);
+                        }
+                    }
                 }
-
-                return;
             }
+
+            return;
         }
 
         if (mts->finger_cnt == 0)
         { /* first finger touch input */
+            INFO("multi-touch mode 3 processing");
 
             if (add_finger_point(origin_x, origin_y, x, y) == -1) {
                 return;
@@ -608,7 +613,10 @@ void maru_finger_processing_3(
         }
         else /* one more finger */
         {
-            add_finger_point(origin_x, origin_y, x, y);
+            if (add_finger_point(origin_x, origin_y, x, y) == -1) {
+                return;
+            }
+
             virtio_touchscreen_event(x, y,
                 mts->finger_cnt - 1, QEMU_MOUSE_PRESSED);
         }
index b3fc71e332f2050dbc23cd950b4398357dd95cdf..d55f85f2136c5300a045bc691597b2c2cfff9360 100644 (file)
@@ -217,8 +217,8 @@ static void multitouch_toggle_key_checking(int event_type,
             INFO("enable multi-touch mode 3\n");
         }
     }
-    else if ((keycode == JAVA_KEYCODE_BIT_SHIFT && state_mask == JAVA_KEYCODE_BIT_CTRL) ||
-        (keycode == JAVA_KEYCODE_BIT_CTRL && state_mask == JAVA_KEYCODE_BIT_SHIFT))
+    else if ((keycode == JAVA_KEYCODE_BIT_CTRL && state_mask == JAVA_KEYCODE_BIT_SHIFT) ||
+        (keycode == JAVA_KEYCODE_BIT_SHIFT && state_mask == JAVA_KEYCODE_BIT_CTRL))
     {
         if (KEY_PRESSED == event_type) {
             set_multi_touch_enable(2);
@@ -226,7 +226,7 @@ static void multitouch_toggle_key_checking(int event_type,
             /* Before the Emulator starts multi-touch processing,
              * add a first finger if user just switches on to the multi-touch mode
              * while display dragging. */
-            if (pressing_x != -1 && pressing_y != -1 &&
+            if (get_finger_cnt() == 0 && pressing_x != -1 && pressing_y != -1 &&
                 pressing_origin_x != -1 && pressing_origin_y != -1) {
                 add_finger_point(
                     pressing_origin_x, pressing_origin_y,
@@ -248,7 +248,7 @@ static void multitouch_toggle_key_checking(int event_type,
             /* Before the Emulator starts multi-touch processing,
              * add a first finger if user just switches on to the multi-touch mode
              * while display dragging. */
-            if (pressing_x != -1 && pressing_y != -1 &&
+            if (get_finger_cnt() == 0 && pressing_x != -1 && pressing_y != -1 &&
                 pressing_origin_x != -1 && pressing_origin_y != -1) {
                 add_finger_point(
                     pressing_origin_x, pressing_origin_y,
@@ -285,6 +285,15 @@ static void multitouch_toggle_key_checking(int event_type,
                 INFO("disable multi-touch\n");
             }
 
+            maru_display_update();
+        }
+    }
+    else
+    {
+        if (get_multi_touch_enable() != 0) {
+            clear_finger_slot(false);
+            INFO("disable multi-touch\n");
+
             maru_display_update();
         }
     }
@@ -639,6 +648,8 @@ void request_close(void)
 #endif
 
     do_hw_key_event(KEY_RELEASED, HARD_KEY_POWER);
+
+    maru_display_update();
 }
 
 void shutdown_qemu_gracefully(void)