From: GiWoong Kim Date: Mon, 5 Jan 2015 05:38:34 +0000 (+0900) Subject: touch: multi-touch bounds checking on maru_shm X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~149 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43191065ed40a7d1471e92ae96095ff88ba89cc7;p=sdk%2Femulator%2Fqemu.git touch: multi-touch bounds checking on maru_shm Emulator need to consider the display mask while multi-touch bounds checking. Change-Id: Ic483f422b4df913b3a1985ad61163e3f6c8c812c Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/maru_finger.c b/tizen/src/display/maru_finger.c index 979e1ee0d5..640a945bf7 100644 --- a/tizen/src/display/maru_finger.c +++ b/tizen/src/display/maru_finger.c @@ -310,17 +310,17 @@ FingerPoint *get_finger_point_search(int x, int y) int i; MultiTouchState *mts = get_emul_multi_touch_state(); FingerPoint *finger = NULL; - int finger_region = (mts->finger_point_size / 2) + + int finger_area = (mts->finger_point_size / 2) + 2 + (int)((1 - get_emul_win_scale()) * 4); for (i = mts->finger_cnt - 1; i >= 0; i--) { finger = get_finger_point_from_slot(i); if (finger != NULL) { - if (x >= (finger->x - finger_region) && - x < (finger->x + finger_region) && - y >= (finger->y - finger_region) && - y < (finger->y + finger_region)) { + if (x >= (finger->x - finger_area) && + x < (finger->x + finger_area) && + y >= (finger->y - finger_area) && + y < (finger->y + finger_area)) { return finger; } } @@ -356,7 +356,7 @@ void maru_finger_processing_1( if (mts->finger_cnt == 0) { /* first finger touch input */ - INFO("multi-touch mode 1 processing"); + INFO("multi-touch mode 1 processing\n"); if (add_finger_point(origin_x, origin_y, x, y) == -1) { return; @@ -428,49 +428,43 @@ void maru_finger_processing_2( /* bounds checking */ const int current_screen_w = get_emul_resolution_width(); const int current_screen_h = get_emul_resolution_height(); - int temp_finger_x, temp_finger_y; for (i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) { finger = get_finger_point_from_slot(i); - if (finger == NULL) { - continue; - } - - temp_finger_x = finger->x + distance_x; - temp_finger_y = finger->y + distance_y; - - if (temp_finger_x >= current_screen_w || temp_finger_x < 0 - || temp_finger_y >= current_screen_h || temp_finger_y < 0) { - TRACE("id %d finger is out of bounds : (%d, %d)\n", - i + 1, temp_finger_x, temp_finger_y); - return; + if (finger != NULL) { + if (finger->x + distance_x >= current_screen_w || + finger->x + distance_x < 0 || + finger->y + distance_y >= current_screen_h || + finger->y + distance_y < 0) { + TRACE("id %d finger is out of bounds : (%d, %d)\n", + i + 1, finger->x + distance_x, finger->y + distance_y); + /* do nothing */ + return; + } } } /* move */ for (i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) { finger = get_finger_point_from_slot(i); - if (finger == NULL) { - continue; - } - - finger->origin_x += origin_distance_x; - finger->origin_y += origin_distance_y; - finger->x += distance_x; - finger->y += distance_y; - - if (finger->id != 0) { - virtio_touchscreen_event(finger->x, finger->y, - i, QEMU_MOUSE_PRESSED); - TRACE("id %d finger multi-touch dragging : (%d, %d)\n", - i + 1, finger->x, finger->y); - } + if (finger != NULL) { + finger->origin_x += origin_distance_x; + finger->origin_y += origin_distance_y; + finger->x += distance_x; + finger->y += distance_y; + + if (finger->id != 0) { + virtio_touchscreen_event(finger->x, finger->y, + i, QEMU_MOUSE_PRESSED); + TRACE("id %d finger multi-touch dragging : (%d, %d)\n", + i + 1, finger->x, finger->y); + } #ifdef CONFIG_WIN32 - Sleep(1); + Sleep(1); #else - usleep(1000); + usleep(1000); #endif - + } } } @@ -479,7 +473,7 @@ void maru_finger_processing_2( if (mts->finger_cnt == 0) { /* first finger touch input */ - INFO("multi-touch mode 2 processing"); + INFO("multi-touch mode 2 processing\n"); if (add_finger_point(origin_x, origin_y, x, y) == -1) { return; @@ -552,6 +546,7 @@ void maru_finger_processing_3( (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); + /* do nothing */ return; } @@ -575,7 +570,7 @@ void maru_finger_processing_3( if (mts->finger_cnt == 0) { /* first finger touch input */ - INFO("multi-touch mode 3 processing"); + INFO("multi-touch mode 3 processing\n"); if (add_finger_point(origin_x, origin_y, x, y) == -1) { return; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java index 0ad8b1fd08..71a0798fc4 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java @@ -37,6 +37,7 @@ import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.Region; import org.eclipse.swt.widgets.Display; import org.tizen.emulator.skin.comm.ICommunicator.MouseButtonType; import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType; @@ -55,6 +56,10 @@ public class EmulatorFingers { private Logger logger = SkinLogger.getSkinLogger(EmulatorFingers.class).getLogger(); + private EmulatorShmSkin skin; + protected SocketCommunicator communicator; + private EmulatorSkinState currentState; + private int multiTouchEnable; private int maxTouchPoint; protected int fingerCnt; @@ -66,16 +71,13 @@ public class EmulatorFingers { protected int fingerPointSizeHalf; protected Image fingerPointImage; - protected SocketCommunicator communicator; - private EmulatorSkinState currentState; - /** * Constructor */ - EmulatorFingers(int maximum, EmulatorSkinState currentState, - SocketCommunicator communicator, PaletteData palette) { - this.currentState = currentState; - this.communicator = communicator; + EmulatorFingers(EmulatorShmSkin skin, PaletteData palette, int maximum) { + this.skin = skin; + this.currentState = skin.currentState; + this.communicator = skin.communicator; initMultiTouchState(maximum, palette); } @@ -138,17 +140,17 @@ public class EmulatorFingers { public FingerPoint getFingerPointSearch(int x, int y) { FingerPoint finger = null; - int fingerRegion = fingerPointSize + 2; - //logger.info("x: "+x+ "y: "+ y + " fingerRegion: " + fingerRegion); + int fingerArea = (fingerPointSize / 2) + + 2 + ((100 - skin.currentState.getCurrentScale()) * 4 / 100); for (int i = fingerCnt - 1; i >= 0; i--) { finger = getFingerPointFromSlot(i); if (finger != null) { - if (x >= (finger.x - fingerRegion) && - x < (finger.x + fingerRegion) && - y >= (finger.y - fingerRegion) && - y < (finger.y + fingerRegion)) { + if (x >= (finger.x - fingerArea) && + x < (finger.x + fingerArea) && + y >= (finger.y - fingerArea) && + y < (finger.y + fingerArea)) { return finger; } } @@ -362,22 +364,38 @@ public class EmulatorFingers { int i = 0; /* bounds checking */ - final int currrntScreenW = currentState.getCurrentResolutionWidth(); - final int currrntScreenH = currentState.getCurrentResolutionHeight(); - int tempFingerX = 0, tempFingerY = 0; - - for (i = 0; i < fingerCnt; i++) { - finger = getFingerPointFromSlot(i); - if (finger != null) { - tempFingerX = finger.x + distanceX; - tempFingerY = finger.y + distanceY; - - if (tempFingerX >= currrntScreenW || tempFingerX < 0 || - tempFingerY >= currrntScreenH || tempFingerY < 0) { - logger.info("id " + (i + 1) + " finger is out of bounds : (" - + tempFingerX + ", " + tempFingerY + ")"); - - return; + Region maskRegion = skin.getDisplayCanvas().getRegion(); + if (maskRegion == null) { + final int currrntScreenW = currentState.getCurrentResolutionWidth(); + final int currrntScreenH = currentState.getCurrentResolutionHeight(); + + for (i = 0; i < fingerCnt; i++) { + finger = getFingerPointFromSlot(i); + if (finger != null) { + if (finger.x + distanceX >= currrntScreenW || + finger.x + distanceX < 0 || + finger.y + distanceY >= currrntScreenH || + finger.y + distanceY < 0) { + logger.info("id " + (i + 1) + " finger is out of bounds : (" + + (finger.x + distanceX) + ", " + + (finger.y + distanceY) + ")"); + /* do nothing */ + return; + } + } + } + } else { + for (i = 0; i < fingerCnt; i++) { + finger = getFingerPointFromSlot(i); + if (finger != null) { + if (maskRegion.contains(finger.x + distanceX, + finger.y + distanceY) == false) { + logger.info("id " + (i + 1) + " finger is out of bounds : (" + + (finger.x + distanceX) + ", " + + (finger.y + distanceY) + ")"); + /* do nothing */ + return; + } } } } @@ -496,16 +514,30 @@ public class EmulatorFingers { (grabFingerID == 2) ? 0 : 1); if (coFinger != null) { /* bounds checking */ - final int currrntScreenW = currentState.getCurrentResolutionWidth(); - final int currrntScreenH = currentState.getCurrentResolutionHeight(); - - if (coFinger.x - distanceX >= currrntScreenW || - coFinger.x - distanceX < 0 || - coFinger.y - distanceY >= currrntScreenH || - coFinger.y - distanceY < 0) { - logger.info("id " + coFinger.id + " finger is out of bounds : (" - + (coFinger.x - distanceX) + ", " + (coFinger.y - distanceY) + ")"); - return; + Region maskRegion = skin.getDisplayCanvas().getRegion(); + if (maskRegion == null) { + final int currrntScreenW = currentState.getCurrentResolutionWidth(); + final int currrntScreenH = currentState.getCurrentResolutionHeight(); + + if (coFinger.x - distanceX >= currrntScreenW || + coFinger.x - distanceX < 0 || + coFinger.y - distanceY >= currrntScreenH || + coFinger.y - distanceY < 0) { + logger.info("id " + coFinger.id + " finger is out of bounds : (" + + (coFinger.x - distanceX) + ", " + + (coFinger.y - distanceY) + ")"); + /* do nothing */ + return; + } + } else { + if (maskRegion.contains(coFinger.x - distanceX, + coFinger.y - distanceY) == false) { + logger.info("id " + coFinger.id + " finger is out of bounds : (" + + (coFinger.x - distanceX) + ", " + + (coFinger.y - distanceY) + ")"); + /* do nothing */ + return; + } } /* move */ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index b43ae81975..52ee75ffca 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -245,8 +245,7 @@ public class EmulatorShmSkin extends EmulatorSkin { public StartData initSkin() { initLayout(); - fingers = new EmulatorFingers(maxTouchPoint, - currentState, communicator, palette); + fingers = new EmulatorFingers(this, palette, maxTouchPoint); /* multi-touch toggle key */ if (SwtUtil.isMacPlatform() == true) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index 1440a9337a..1690eb94b4 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -267,7 +267,7 @@ public class SkinUtil { } ImageData maskData = new ImageData(srcImageData.width, srcImageData.height, 1, - new PaletteData(new RGB[] { new RGB(0, 0, 0) , new RGB(255, 255, 255) })); + new PaletteData(new RGB[] { new RGB(0, 0, 0), new RGB(255, 255, 255) })); maskData.setPixels(0, 0, srcImageData.width * srcImageData.height, maskArray, 0); return maskData;