From: GiWoong Kim Date: Wed, 7 Jan 2015 05:22:43 +0000 (+0900) Subject: touch: refactoring for multi-touch processing on maru_sdl X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~564 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=966e9c93571ef4d39b634481fef872dc13327328;p=sdk%2Femulator%2Fqemu.git touch: refactoring for multi-touch processing on maru_sdl On maru_sdl, the multi-touch processing logic had been moved to Java side. Now, SDL just manage a multi-touch point drawing only. Change-Id: I8cbecc205bd269ba98c2c9a35e0ca3b6b5e72f4e Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/maru_finger.c b/tizen/src/display/maru_finger.c index 2087b2c31d..9d851d4887 100644 --- a/tizen/src/display/maru_finger.c +++ b/tizen/src/display/maru_finger.c @@ -1,12 +1,11 @@ /* - * Multi-touch processing + * Multi-touch point drawing * - * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim - * YeongKyoon Lee - * HyunJun Son + * SangHo Park * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +32,6 @@ #include #include "maru_finger.h" #include "emul_state.h" -#include "hw/virtio/maru_virtio_touchscreen.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(qemu, finger); @@ -64,7 +62,8 @@ static void sdl_set_pixel(SDL_Surface *surface, int x, int y, Uint32 pixel) * The algorithm elegantly draws a circle quickly, using a * set_pixel function for clarity. */ -static void sdl_draw_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel) +static void sdl_draw_circle(SDL_Surface *surface, + int cx, int cy, int radius, Uint32 pixel) { int error = -radius; int x = radius; @@ -118,7 +117,8 @@ static void sdl_draw_circle(SDL_Surface *surface, int cx, int cy, int radius, Ui * WARNING: This function does not lock surfaces before altering, so * use SDL_LockSurface in any release situation. */ -static void sdl_fill_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel) +static void sdl_fill_circle(SDL_Surface *surface, + int cx, int cy, int radius, Uint32 pixel) { /* Note that there is more to altering the bitrate of this * method than just changing this value. See how pixels are @@ -161,10 +161,6 @@ static void sdl_fill_circle(SDL_Surface *surface, int cx, int cy, int radius, Ui /* ==================================================================================================== */ -static int _grab_finger_id = 0; -#define QEMU_MOUSE_PRESSED 1 -#define QEMU_MOUSE_RELEASEED 0 - void init_multi_touch_state(void) { int i; @@ -238,380 +234,69 @@ int get_finger_cnt(void) return get_emul_multi_touch_state()->finger_cnt; } -int add_finger_point(int origin_x, int origin_y, int x, int y) -{ - MultiTouchState *mts = get_emul_multi_touch_state(); - - if (mts->finger_cnt == mts->finger_cnt_max) { - WARN("supports up to %d fingers\n", mts->finger_cnt_max); - return -1; - } - - mts->finger_cnt += 1; - - mts->finger_slot[mts->finger_cnt - 1].id = mts->finger_cnt; - mts->finger_slot[mts->finger_cnt - 1].origin_x = origin_x; - mts->finger_slot[mts->finger_cnt - 1].origin_y = origin_y; - mts->finger_slot[mts->finger_cnt - 1].x = x; - mts->finger_slot[mts->finger_cnt - 1].y = y; - - INFO("id %d finger touching\n", mts->finger_cnt); - - return mts->finger_cnt; -} - -int remove_finger_point_from_slot(int index) +int update_finger_point(int index, int origin_x, int origin_y, int x, int y) { - _grab_finger_id = 0; - - MultiTouchState *mts = get_emul_multi_touch_state(); - FingerPoint *finger = get_finger_point_from_slot(index); if (finger != NULL) { - INFO("id %d finger releasing\n", finger->id); - - if (finger->id > 0) { - virtio_touchscreen_event(finger->x, finger->y, - finger->id - 1, QEMU_MOUSE_RELEASEED); + if (finger->id == 0) { + /* add new finger point */ + add_new_finger_point(index, origin_x, origin_y, x, y); + } else { + /* update */ + finger->origin_x = origin_x; + finger->origin_y = origin_y; + finger->x = x; + finger->y = y; } - - finger->id = 0; - finger->origin_x = finger->origin_y = finger->x = finger->y = -1; - - mts->finger_cnt--; - } - - return mts->finger_cnt; -} - -FingerPoint *get_finger_point_from_slot(int index) -{ - MultiTouchState *mts = get_emul_multi_touch_state(); - - if (index < 0 || index > mts->finger_cnt_max) { - return NULL; } - return &(mts->finger_slot[index]); + return get_finger_cnt(); } -FingerPoint *get_finger_point_search(int x, int y) +int add_new_finger_point(int index, int origin_x, int origin_y, int x, int y) { - int i; - MultiTouchState *mts = get_emul_multi_touch_state(); - FingerPoint *finger = NULL; - int finger_area = (mts->finger_point_size / 2) + - 2 + (int)((1 - get_emul_win_scale()) * 4); + FingerPoint *finger = get_finger_point_from_slot(index); + if (finger != NULL) { + finger->id = index + 1; + finger->origin_x = origin_x; + finger->origin_y = origin_y; + finger->x = x; + finger->y = y; - for (i = mts->finger_cnt - 1; i >= 0; i--) { - finger = get_finger_point_from_slot(i); + get_emul_multi_touch_state()->finger_cnt++; - if (finger != NULL) { - if (x >= (finger->x - finger_area) && - x < (finger->x + finger_area) && - y >= (finger->y - finger_area) && - y < (finger->y + finger_area)) { - return finger; - } - } + INFO("id %d finger point added\n", finger->id); } - return NULL; + return get_finger_cnt(); } -void maru_finger_processing_1( - int touch_type, int origin_x, int origin_y, int x, int y) +int remove_finger_point(int index) { - MultiTouchState *mts = get_emul_multi_touch_state(); - FingerPoint *finger = NULL; - - if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */ - if (_grab_finger_id > 0) { - finger = get_finger_point_from_slot(_grab_finger_id - 1); - if (finger != NULL) { - finger->origin_x = origin_x; - finger->origin_y = origin_y; - finger->x = x; - finger->y = y; - - if (finger->id != 0) { - virtio_touchscreen_event(x, y, - _grab_finger_id - 1, QEMU_MOUSE_PRESSED); - TRACE("id %d finger multi-touch dragging : (%d, %d)\n", - _grab_finger_id, x, y); - } - } - return; - } - - if (mts->finger_cnt == 0) - { /* first finger touch input */ - INFO("multi-touch mode 1 processing\n"); - - if (add_finger_point(origin_x, origin_y, x, y) == -1) { - return; - } - - virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED); - } - else if ((finger = get_finger_point_search(x, y)) != NULL) - { /* check the position of previous touch event */ - - /* finger point is selected */ - _grab_finger_id = finger->id; - TRACE("id %d finger is grabbed\n", _grab_finger_id); - } - else if (mts->finger_cnt == mts->finger_cnt_max) - { /* Let's assume that this event is last finger touch input */ - - finger = get_finger_point_from_slot(mts->finger_cnt - 1); - if (finger != NULL) { -#if 1 /* send release event */ - virtio_touchscreen_event(finger->x, finger->y, - mts->finger_cnt - 1, QEMU_MOUSE_RELEASEED); -#endif + FingerPoint *finger = get_finger_point_from_slot(index); + if (finger != NULL && finger->id != 0) { + INFO("id %d finger point removed\n", finger->id); - /* update position */ - finger->origin_x = origin_x; - finger->origin_y = origin_y; - finger->x = x; - finger->y = y; - if (finger->id != 0) { - INFO("id %d finger touching\n", finger->id); - virtio_touchscreen_event(x, y, - mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); - } - } - } - else /* one more finger */ - { - if (add_finger_point(origin_x, origin_y, x, y) == -1) { - return; - } + get_emul_multi_touch_state()->finger_cnt--; - virtio_touchscreen_event(x, y, - mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); - } - - } else if (touch_type == MOUSE_UP) { /* released */ - _grab_finger_id = 0; + finger->id = 0; + finger->origin_x = finger->origin_y = finger->x = finger->y = -1; } -} - -void maru_finger_processing_2( - int touch_type, int origin_x, int origin_y, int x, int y) -{ - MultiTouchState *mts = get_emul_multi_touch_state(); - FingerPoint *finger = NULL; - - if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */ - if (_grab_finger_id > 0) { - finger = get_finger_point_from_slot(_grab_finger_id - 1); - if (finger != NULL) { - 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; - - int i = 0; - - /* bounds checking */ - const int current_screen_w = get_emul_resolution_width(); - const int current_screen_h = get_emul_resolution_height(); - - for (i = 0; i < get_emul_multi_touch_state()->finger_cnt; i++) { - finger = get_finger_point_from_slot(i); - 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) { - 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); -#else - usleep(1000); -#endif - } - } - } - - return; - } - if (mts->finger_cnt == 0) - { /* first finger touch input */ - INFO("multi-touch mode 2 processing\n"); - - if (add_finger_point(origin_x, origin_y, x, y) == -1) { - return; - } - - virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED); - } - else if ((finger = get_finger_point_search(x, y)) != NULL) - { /* check the position of previous touch event */ - - /* finger point is selected */ - _grab_finger_id = finger->id; - TRACE("id %d finger is grabbed\n", _grab_finger_id); - } - else if (mts->finger_cnt == mts->finger_cnt_max) - { - /* do nothing */ - return; - } - else /* one more finger */ - { - if (add_finger_point(origin_x, origin_y, x, y) == -1) { - return; - } - - virtio_touchscreen_event(x, y, - mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); - } - - } else if (touch_type == MOUSE_UP) { /* released */ - _grab_finger_id = 0; - } + return get_finger_cnt(); } -void maru_finger_processing_3( - int touch_type, int origin_x, int origin_y, int x, int y) +FingerPoint *get_finger_point_from_slot(int index) { MultiTouchState *mts = get_emul_multi_touch_state(); - FingerPoint *finger = NULL; - if (touch_type == MOUSE_DOWN || touch_type == MOUSE_DRAG) { /* pressed */ - 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; - - /* move */ - 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(x, y, - finger->id - 1, QEMU_MOUSE_PRESSED); - TRACE("id %d finger multi-touch dragging : (%d, %d)\n", - 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); - /* do nothing */ - 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; - } - - if (mts->finger_cnt == 0) - { /* first finger touch input */ - INFO("multi-touch mode 3 processing\n"); - - if (add_finger_point(origin_x, origin_y, x, y) == -1) { - return; - } - - virtio_touchscreen_event(x, y, 0, QEMU_MOUSE_PRESSED); - } - else if ((finger = get_finger_point_search(x, y)) != NULL) - { /* check the position of previous touch event */ - - /* finger point is selected */ - _grab_finger_id = finger->id; - INFO("id %d finger is grabbed\n", _grab_finger_id); - } - else if (mts->finger_cnt >= 2) /* supports up to 2 fingers */ - { /* Let's assume that this event is last finger touch input */ - - finger = get_finger_point_from_slot(1); - if (finger != NULL) { -#if 1 /* send release event */ - virtio_touchscreen_event(finger->x, finger->y, - 1, QEMU_MOUSE_RELEASEED); -#endif - - /* update position */ - finger->origin_x = origin_x; - finger->origin_y = origin_y; - finger->x = x; - finger->y = y; - if (finger->id != 0) { - INFO("id %d finger touching\n", finger->id); - virtio_touchscreen_event(x, y, 1, QEMU_MOUSE_PRESSED); - } - }; - } - else /* one more finger */ - { - if (add_finger_point(origin_x, origin_y, x, y) == -1) { - return; - } - - virtio_touchscreen_event(x, y, - mts->finger_cnt - 1, QEMU_MOUSE_PRESSED); - } - - } else if (touch_type == MOUSE_UP) { /* released */ - if (_grab_finger_id != 0) { - INFO("id %d finger releasing\n", _grab_finger_id); - } - _grab_finger_id = 0; + /* validation for slot index */ + if (index < 0 || index >= mts->finger_cnt_max) { + WARN("invalid index : %d\n", index); + return NULL; } + + return &(mts->finger_slot[index]); } static bool _calculate_origin_coordinates( @@ -652,8 +337,8 @@ static bool _calculate_origin_coordinates( return false; } -int rearrange_finger_points( - int lcd_w, int lcd_h, double scale_factor, int rotaton_type) +int rearrange_finger_points(int resolution_w, int resolution_h, + double scale_factor, int rotaton_type) { int i = 0; int count = 0; @@ -664,52 +349,39 @@ int rearrange_finger_points( return 0; } - lcd_w *= scale_factor; - lcd_h *= scale_factor; + resolution_w *= scale_factor; + resolution_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, + if (_calculate_origin_coordinates(resolution_w, resolution_h, scale_factor, rotaton_type, finger) == true) { count++; } } } - if (count != 0) { - _grab_finger_id = 0; - } - return count; } -void clear_finger_slot(bool keep_enable) +void clear_finger_slot(void) { int i = 0; MultiTouchState *mts = get_emul_multi_touch_state(); FingerPoint *finger = NULL; - if (keep_enable == false) { - set_multi_touch_enable(0); - } - - INFO("clear multi-touch : %d\n", get_multi_touch_enable()); + set_multi_touch_enable(0); + INFO("clear multi-touch\n"); for (i = 0; i < mts->finger_cnt; i++) { finger = get_finger_point_from_slot(i); if (finger != NULL) { - if (finger->id > 0) { - virtio_touchscreen_event(finger->x, finger->y, - finger->id - 1, QEMU_MOUSE_RELEASEED); - } - finger->id = 0; finger->origin_x = finger->origin_y = finger->x = finger->y = -1; } } - _grab_finger_id = 0; mts->finger_cnt = 0; } @@ -718,7 +390,7 @@ void cleanup_multi_touch_state(void) MultiTouchState *mts = get_emul_multi_touch_state(); SDL_Surface *point = (SDL_Surface *)mts->finger_point_surface; - clear_finger_slot(false); + clear_finger_slot(); g_free(mts->finger_slot); mts->finger_point_surface = NULL; diff --git a/tizen/src/display/maru_finger.h b/tizen/src/display/maru_finger.h index 6495779478..e588257f39 100644 --- a/tizen/src/display/maru_finger.h +++ b/tizen/src/display/maru_finger.h @@ -1,12 +1,11 @@ /* - * Multi-touch processing + * Multi-touch point drawing * - * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim - * YeongKyoon Lee - * HyunJun Son + * SangHo Park * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -63,17 +62,15 @@ typedef struct MultiTouchState { void init_multi_touch_state(void); int get_finger_cnt(void); -int remove_finger_point_from_slot(int index); + +int update_finger_point(int index, int origin_x, int origin_y, int x, int y); +int add_new_finger_point(int index, int origin_x, int origin_y, int x, int y); +int remove_finger_point(int index); + FingerPoint *get_finger_point_from_slot(int index); -FingerPoint *get_finger_point_search(int x, int y); -int add_finger_point(int origin_x, int origin_y, int x, int y); -void maru_finger_processing_1(int touch_type, int origin_x, int origin_y, int x, int y); -void maru_finger_processing_2(int touch_type, int origin_x, int origin_y, int x, int y); -void maru_finger_processing_3(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(bool keep_enable); +void clear_finger_slot(void); void cleanup_multi_touch_state(void); - #endif /* __MARU_FINGER_H__ */ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java index da978e8fe3..98ee4d9e3f 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java @@ -1,7 +1,7 @@ /** * Emulator Skin Process * - * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim @@ -33,11 +33,16 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.PaletteData; +import org.tizen.emulator.skin.comm.ICommunicator.MouseButtonType; +import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType; import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; import org.tizen.emulator.skin.comm.sock.data.DisplayStateData; +import org.tizen.emulator.skin.comm.sock.data.MouseEventData; import org.tizen.emulator.skin.comm.sock.data.StartData; import org.tizen.emulator.skin.config.EmulatorConfig; +import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.dbi.OptionType; import org.tizen.emulator.skin.exception.ScreenShotException; import org.tizen.emulator.skin.image.ImageRegistry.IconName; @@ -55,6 +60,15 @@ public class EmulatorSdlSkin extends EmulatorSkin { private PaletteData palette; + /* touch values */ + protected static int pressingX = -1, pressingY = -1; + protected static int pressingOriginX = -1, pressingOriginY = -1; + + private EmulatorFingers fingers; + private int multiTouchKey; + private int multiTouchKeySub1; + private int multiTouchKeySub2; + /** * Constructor */ @@ -66,10 +80,28 @@ public class EmulatorSdlSkin extends EmulatorSkin { this.palette = new PaletteData(0x0000FF00, 0x00FF0000, 0xFF000000); } + @Override + protected void skinFinalize() { + /* remove multi-touch points */ + if (fingers != null) { + fingers.cleanupMultiTouchState(); + } + + super.skinFinalize(); + } + @Override public StartData initSkin() { initLayout(); + /* multi-touch toggle key */ + multiTouchKey = SWT.CTRL; + multiTouchKeySub1 = SWT.SHIFT; + multiTouchKeySub2 = SWT.ALT; + + fingers = new EmulatorFingers(this, palette, + config.getArgInt(ArgsConstants.INPUT_TOUCH_MAXPOINT)); + /* maru_sdl uses this handle ID */ long id = getDisplayHandleId(); @@ -163,6 +195,186 @@ public class EmulatorSdlSkin extends EmulatorSkin { super.displayOff(); } + /* mouse event */ + @Override + protected void mouseMoveDelivery(MouseEvent e, int eventType) { + int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y, + currentState.getCurrentResolutionWidth(), + currentState.getCurrentResolutionHeight(), + currentState.getCurrentScale(), + currentState.getCurrentRotationId()); + + /* filtering for multi-touch */ + if (fingers.getMultiTouchEnable() == 1) { + /* Ctrl or Shift */ + fingers.maruFingerProcessing1(eventType, + e.x, e.y, geometry[0], geometry[1]); + return; + } else if (fingers.getMultiTouchEnable() == 2) { + /* Ctrl + Shift */ + fingers.maruFingerProcessing2(eventType, + e.x, e.y, geometry[0], geometry[1]); + return; + } else if (fingers.getMultiTouchEnable() == 3) { + /* Ctrl + Alt */ + fingers.maruFingerProcessing3(eventType, + e.x, e.y, geometry[0], geometry[1]); + return; + } + + MouseEventData mouseEventData = new MouseEventData( + MouseButtonType.LEFT.value(), eventType, + e.x, e.y, geometry[0], geometry[1], 0); + + communicator.sendToQEMU( + SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); + } + + @Override + protected void mouseUpDelivery(MouseEvent e) { + int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y, + currentState.getCurrentResolutionWidth(), + currentState.getCurrentResolutionHeight(), + currentState.getCurrentScale(), + currentState.getCurrentRotationId()); + logger.info("mouseUp in display" + + " x:" + geometry[0] + " y:" + geometry[1]); + + pressingX = pressingY = -1; + pressingOriginX = pressingOriginY = -1; + + /* filtering for multi-touch */ + if (fingers.getMultiTouchEnable() == 1) { + fingers.maruFingerProcessing1(MouseEventType.RELEASE.value(), + e.x, e.y, geometry[0], geometry[1]); + return; + } else if (fingers.getMultiTouchEnable() == 2) { + fingers.maruFingerProcessing2(MouseEventType.RELEASE.value(), + e.x, e.y, geometry[0], geometry[1]); + return; + } else if (fingers.getMultiTouchEnable() == 3) { + fingers.maruFingerProcessing3(MouseEventType.RELEASE.value(), + e.x, e.y, geometry[0], geometry[1]); + return; + } + + MouseEventData mouseEventData = new MouseEventData( + MouseButtonType.LEFT.value(), MouseEventType.RELEASE.value(), + e.x, e.y, geometry[0], geometry[1], 0); + + communicator.sendToQEMU( + SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); + } + + @Override + protected void mouseDownDelivery(MouseEvent e) { + int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y, + currentState.getCurrentResolutionWidth(), + currentState.getCurrentResolutionHeight(), + currentState.getCurrentScale(), + currentState.getCurrentRotationId()); + logger.info("mouseDown in display" + + " x:" + geometry[0] + " y:" + geometry[1]); + + pressingX = geometry[0]; + pressingY = geometry[1]; + pressingOriginX = e.x; + pressingOriginY = e.y; + + /* filtering for multi-touch */ + if (fingers.getMultiTouchEnable() == 1) { + fingers.maruFingerProcessing1(MouseEventType.PRESS.value(), + e.x, e.y, geometry[0], geometry[1]); + return; + } else if (fingers.getMultiTouchEnable() == 2) { + fingers.maruFingerProcessing2(MouseEventType.PRESS.value(), + e.x, e.y, geometry[0], geometry[1]); + return; + } else if (fingers.getMultiTouchEnable() == 3) { + fingers.maruFingerProcessing3(MouseEventType.PRESS.value(), + e.x, e.y, geometry[0], geometry[1]); + return; + } + + MouseEventData mouseEventData = new MouseEventData( + MouseButtonType.LEFT.value(), MouseEventType.PRESS.value(), + e.x, e.y, geometry[0], geometry[1], 0); + + communicator.sendToQEMU( + SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); + } + + /* keyboard event */ + @Override + protected void keyReleasedDelivery(int keyCode, + int stateMask, int keyLocation, boolean remove) { + if (fingers.getMaxTouchPoint() > 1) { + /* multi-touch checking */ + final int tempStateMask = stateMask & ~SWT.BUTTON1; + + if (keyCode == multiTouchKey || keyCode == multiTouchKeySub1) { + if (tempStateMask == (multiTouchKeySub1 | multiTouchKey)) { + fingers.setMultiTouchEnable(1); + logger.info("enable multi-touch mode 2->1"); + } else { + fingers.clearFingerSlot(false); + logger.info("disable multi-touch"); + } + } else if (keyCode == multiTouchKeySub2) { + if (tempStateMask == (multiTouchKey | multiTouchKeySub2)) { + fingers.setMultiTouchEnable(1); + logger.info("enable multi-touch mode 3->1"); + } else { + fingers.clearFingerSlot(false); + logger.info("disable multi-touch"); + } + } + } + + super.keyReleasedDelivery(keyCode, stateMask, keyLocation, remove); + } + + @Override + protected void keyPressedDelivery(int keyCode, + int stateMask, int keyLocation, boolean add) { + if (fingers.getMaxTouchPoint() > 1) { + /* multi-touch checking */ + final int tempStateMask = stateMask & ~SWT.BUTTON1; + + if ((keyCode == multiTouchKey && tempStateMask == multiTouchKeySub2) || + (keyCode == multiTouchKeySub2 && tempStateMask == multiTouchKey)) + { + /* multi-touch mode 3 supports up to 2 fingers */ + int i = fingers.getFingerCnt(); + for ( ; i > 2; i--) { + fingers.removeFingerPointFromSlot(i - 1); + } + + fingers.setMultiTouchEnable(3); + + logger.info("enable multi-touch mode 3"); + } + else if ((keyCode == multiTouchKey && tempStateMask == multiTouchKeySub1) || + (keyCode == multiTouchKeySub1 && tempStateMask == multiTouchKey)) + { + fingers.setMultiTouchEnable(2); + + logger.info("enable multi-touch mode 2"); + } else if (keyCode == multiTouchKeySub1 || keyCode == multiTouchKey) { + fingers.setMultiTouchEnable(1); + + logger.info("enable multi-touch mode 1"); + } else { + if (fingers.getMultiTouchEnable() != 0) { + fingers.clearFingerSlot(false); + logger.info("disable multi-touch"); + } + } + } + + super.keyPressedDelivery(keyCode, stateMask, keyLocation, add); + } + @Override protected void openScreenShotWindow() { if (screenShotDialog != null) { diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 7b889650a7..3f470c98a7 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -106,6 +106,7 @@ void do_mouse_event(int button_type, int event_type, if (display_off) { if (button_type == 0) { INFO("auto mouse release\n"); + // TODO: virtio_touchscreen_event(0, 0, 0, 0); return; @@ -122,25 +123,15 @@ void do_mouse_event(int button_type, int event_type, button_type, event_type, origin_x, origin_y, x, y, z); #if !defined(CONFIG_USE_SHM) && defined(CONFIG_SDL) - /* multi-touch */ - if (get_multi_touch_enable() == 1) { - /* Ctrl or Shift */ - maru_finger_processing_1(event_type, origin_x, origin_y, x, y); - - maru_display_update(); - return; - } else if (get_multi_touch_enable() == 2) { - /* Ctrl + Shift */ - maru_finger_processing_2(event_type, origin_x, origin_y, x, y); - - maru_display_update(); - return; - } else if (get_multi_touch_enable() == 3) { - /* Ctrl + Alt */ - maru_finger_processing_3(event_type, origin_x, origin_y, x, y); + /* draw multi-touch points */ + if (get_multi_touch_enable() != 0) { + if (event_type == MOUSE_DOWN || event_type == MOUSE_DRAG) { + update_finger_point(z, origin_x, origin_y, x, y); + } else if (event_type == MOUSE_UP) { + remove_finger_point(z); + } maru_display_update(); - return; } #endif @@ -219,15 +210,7 @@ static void multitouch_toggle_key_checking(int event_type, (keycode == JAVA_KEYCODE_BIT_ALT && state_mask == JAVA_KEYCODE_BIT_CTRL)) { if (KEY_PRESSED == event_type) { - /* multi-touch mode 3 supports up to 2 fingers */ - int i = get_finger_cnt(); - for ( ; i > 2; i--) { - remove_finger_point_from_slot(i - 1); - } - maru_display_update(); - set_multi_touch_enable(3); - INFO("enable multi-touch mode 3\n"); } } @@ -236,21 +219,6 @@ static void multitouch_toggle_key_checking(int event_type, { if (KEY_PRESSED == event_type) { set_multi_touch_enable(2); - - /* 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 (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, - pressing_x, pressing_y); - pressing_x = pressing_y = -1; - pressing_origin_x = pressing_origin_y = -1; - - maru_display_update(); - } - INFO("enable multi-touch mode 2\n"); } } @@ -258,34 +226,15 @@ static void multitouch_toggle_key_checking(int event_type, { if (KEY_PRESSED == event_type) { set_multi_touch_enable(1); - - /* 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 (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, - pressing_x, pressing_y); - pressing_x = pressing_y = -1; - pressing_origin_x = pressing_origin_y = -1; - - maru_display_update(); - } - INFO("enable multi-touch mode 1\n"); } else if (KEY_RELEASED == event_type) { if (state_mask == (JAVA_KEYCODE_BIT_CTRL | JAVA_KEYCODE_BIT_SHIFT)) { set_multi_touch_enable(1); INFO("enable multi-touch mode 2->1\n"); } else { - clear_finger_slot(false); - INFO("disable multi-touch\n"); + set_multi_touch_enable(0); + INFO("disable multi-touch : %d\n", get_finger_cnt()); } - - maru_display_update(); - } else { - WARN("invalid event type : %d\n", event_type); } } else if (keycode == JAVA_KEYCODE_BIT_ALT) @@ -295,22 +244,20 @@ static void multitouch_toggle_key_checking(int event_type, set_multi_touch_enable(1); INFO("enable multi-touch mode 3->1\n"); } else { - clear_finger_slot(false); - INFO("disable multi-touch\n"); + set_multi_touch_enable(0); + INFO("disable multi-touch : %d\n", get_finger_cnt()); } - - maru_display_update(); } } else { if (get_multi_touch_enable() != 0) { - clear_finger_slot(false); - INFO("disable multi-touch\n"); - - maru_display_update(); + set_multi_touch_enable(0); + INFO("disable multi-touch : %d\n", get_finger_cnt()); } } + + maru_display_update(); } #endif