From 40650702fe7c17cdf686f47bad5eb975aeb916d1 Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Wed, 21 Mar 2012 01:37:40 +0900 Subject: [PATCH] [Title] prepare for the multitouch [Type] [Module] Emulator [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- tizen/src/Makefile.tizen | 8 +-- tizen/src/emul_state.c | 10 +++- tizen/src/emul_state.h | 14 +++-- tizen/src/maru_finger.c | 116 ++++++++++++++++++++++++++++++++++++ tizen/src/maru_finger.h | 68 +++++++++++++++++++++ tizen/src/maru_sdl.c | 4 +- tizen/src/skin/maruskin_keymap.c | 29 --------- tizen/src/skin/maruskin_keymap.h | 30 ++++++++++ tizen/src/skin/maruskin_operation.c | 17 ++++++ 9 files changed, 256 insertions(+), 40 deletions(-) create mode 100644 tizen/src/maru_finger.c create mode 100644 tizen/src/maru_finger.h diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index 440437f..053fe97 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -57,18 +57,18 @@ endif #CONFIG_WIN32 obj-y += emulator.o emul_state.o process.o option.o maru_signal.o # display -obj-y += maru_sdl.o sdl_rotate.o sdl_zoom.o +obj-y += maru_sdl.o sdl_rotate.o sdl_zoom.o maru_finger.o # sdb obj-y += sdb.o -# mloop_event +# mloop event obj-y += mloop_event.o -# debugch +# debug channel obj-y += debug_ch.o -# maru hw +# maru hardware obj-i386-y += maru_board.o obj-i386-y += maru_overlay.o obj-i386-y += maru_codec.o diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 7af32ab..31b355a 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -36,8 +36,8 @@ MULTI_DEBUG_CHANNEL(qemu, emul_state); -static emulator_config_info _emul_info; -static emulator_config_state _emul_state; +static EmulatorConfigInfo _emul_info; +static EmulatorConfigState _emul_state; /* lcd screen size */ void set_emul_lcd_size(int width, int height) @@ -91,3 +91,9 @@ short get_emul_rotation(void) { return _emul_state.rotation_type; } + +/* emulator multi-touch */ +MultiTouchState *get_emul_multi_touch_state(void) +{ + return &(_emul_state.qemu_mts); +} diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index e534b11..a4ee98a 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -33,6 +33,9 @@ #ifndef __EMUL_STATE_H__ #define __EMUL_STATE_H__ +#include "maru_common.h" +#include "maru_finger.h" + enum { ROTATION_PORTRAIT = 0, ROTATION_LANDSCAPE = 1, @@ -41,18 +44,20 @@ enum { }; -typedef struct emulator_config_info { +typedef struct EmulatorConfigInfo { char emulator_name[256]; int lcd_size_w; int lcd_size_h; + int dpi; //TODO: -} emulator_config_info; +} EmulatorConfigInfo; -typedef struct emulator_config_state { +typedef struct EmulatorConfigState { double scale_factor; short rotation_type; + MultiTouchState qemu_mts; //TODO: -} emulator_config_state; +} EmulatorConfigState; /* setter */ @@ -65,6 +70,7 @@ int get_emul_lcd_width(void); int get_emul_lcd_height(void); double get_emul_win_scale(void); short get_emul_rotation(void); +MultiTouchState *get_emul_multi_touch_state(void); #endif /* __EMUL_STATE_H__ */ diff --git a/tizen/src/maru_finger.c b/tizen/src/maru_finger.c new file mode 100644 index 0000000..9eaea7e --- /dev/null +++ b/tizen/src/maru_finger.c @@ -0,0 +1,116 @@ +/* + * Multi-touch processing + * + * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * HyunJun Son + * GiWoong Kim + * YeongKyoon Lee + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +#include +#include "maru_finger.h" +#include "emul_state.h" +#include "debug_ch.h" + +MULTI_DEBUG_CHANNEL(qemu, maru_finger); + + +void init_multi_touch_state(void) +{ + int i; + MultiTouchState* mts = get_emul_multi_touch_state(); + FingerPoint *finger = NULL; + INFO("multi-touch state initailize\n"); + + mts->multitouch_enable = 0; + mts->finger_cnt_max = MAX_FINGER_CNT; //temp + mts->finger_cnt = 0; + + if (mts->finger_slot != NULL) { + g_free(mts->finger_slot); + mts->finger_slot = NULL; + } + mts->finger_slot = (FingerPoint *)g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max); + for (i = 0; i < mts->finger_cnt; i++) { + finger = get_finger_point_from_slot(i); + //finger->id = 0; + finger->x = finger->y = -1; + } + + mts->finger_point_size = DEFAULT_FINGER_POINT_SIZE; //temp + mts->finger_point_color = DEFAULT_FINGER_POINT_COLOR; //temp + mts->finger_point_outline_color = DEFAULT_FINGER_POINT_OUTLINE_COLOR; //temp +} + +void set_multi_touch_enable(int enable) +{ + get_emul_multi_touch_state()->multitouch_enable = enable; +} + +int get_multi_touch_enable(void) +{ + return get_emul_multi_touch_state()->multitouch_enable; +} + +int add_finger_point(int x, int y) +{ + MultiTouchState *mts = get_emul_multi_touch_state(); + + if (mts->finger_cnt == mts->finger_cnt_max) { + return -1; + } + + mts->finger_cnt++; + + mts->finger_slot[mts->finger_cnt - 1].id = mts->finger_cnt; + mts->finger_slot[mts->finger_cnt - 1].x = x; + mts->finger_slot[mts->finger_cnt - 1].y = y; + INFO("%d finger touching\n", 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]); +} + +void clear_finger_slot(void) +{ + int i; + MultiTouchState *mts = get_emul_multi_touch_state(); + FingerPoint *finger = NULL; + + for (i = 0; i < mts->finger_cnt; i++) { + finger = get_finger_point_from_slot(i); + finger->id = 0; + finger->x = finger->y = -1; + } +} diff --git a/tizen/src/maru_finger.h b/tizen/src/maru_finger.h new file mode 100644 index 0000000..8aaaaef --- /dev/null +++ b/tizen/src/maru_finger.h @@ -0,0 +1,68 @@ +/* + * Multi-touch processing + * + * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * HyunJun Son + * GiWoong Kim + * YeongKyoon Lee + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +#ifndef __MARU_FINGER_H__ +#define __MARU_FINGER_H__ + + +/* multi-touch related definitions */ +//TODO : from arg +#define MAX_FINGER_CNT 2 +#define DEFAULT_FINGER_POINT_SIZE 32 +#define DEFAULT_FINGER_POINT_COLOR 0x7E0f0f0f +#define DEFAULT_FINGER_POINT_OUTLINE_COLOR 0xDDDDDDDD + +typedef struct FingerPoint { + int id; + int x; + int y; +} FingerPoint; + +typedef struct MultiTouchState { + int multitouch_enable; + int finger_cnt; + int finger_cnt_max; + FingerPoint *finger_slot; + + int finger_point_size; + int finger_point_color; + int finger_point_outline_color; + void *finger_point; //SDL_Surface +} MultiTouchState; + + +void init_multi_touch_state(void); +void set_multi_touch_enable(int enable); +int get_multi_touch_enable(void); +int add_finger_point(int x, int y); +FingerPoint *get_finger_point_from_slot(int index); +void clear_finger_slot(void); + +#endif /* __MARU_FINGER_H__ */ diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 151181a..8454dac 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -32,6 +32,7 @@ #include "maru_sdl.h" #include "emul_state.h" #include "sdl_rotate.h" +#include "maru_finger.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(tizen, maru_sdl); @@ -262,9 +263,10 @@ void maruskin_sdl_init(int swt_handle, int lcd_size_width, int lcd_size_height) #endif sdl_initialized = 1; + init_multi_touch_state(); } -void maruskin_sdl_resize() +void maruskin_sdl_resize(void) { SDL_Event ev; diff --git a/tizen/src/skin/maruskin_keymap.c b/tizen/src/skin/maruskin_keymap.c index e5bd326..7bea867 100644 --- a/tizen/src/skin/maruskin_keymap.c +++ b/tizen/src/skin/maruskin_keymap.c @@ -31,35 +31,6 @@ #include "maruskin_keymap.h" -/* keep it consistent with java virtual keycode */ -#define JAVA_KEYCODE_BIT (1 << 24) -#define JAVA_KEYCODE_BIT_CTRL (1 << 18) -#define JAVA_KEYCODE_BIT_SHIFT (1 << 17) -#define JAVA_KEYCODE_BIT_ALT (1 << 16) - -#define JAVA_KEY_MASK 0xFFFF; - -enum JAVA_KEYCODE { - JAVA_KEY_ARROW_UP = 1, - JAVA_KEY_ARROW_DOWN, - JAVA_KEY_ARROW_LEFT, - JAVA_KEY_ARROW_RIGHT, - JAVA_KEY_PAGE_UP, - JAVA_KEY_PAGE_DOWN, - JAVA_KEY_HOME, - JAVA_KEY_END, - JAVA_KEY_INSERT, - JAVA_KEY_F1 = 10, - JAVA_KEY_F20 = 29, - JAVA_KEY_CAPS_LOCK = 82, - JAVA_KEY_NUM_LOCK, - JAVA_KEY_SCROLL_LOCK, - JAVA_KEY_PAUSE, - JAVA_KEY_BREAK, - JAVA_KEY_PRINT_SCREEN -}; - - int javakeycode_to_scancode(int java_keycode) { int state_mask = java_keycode & JAVA_KEYCODE_BIT; diff --git a/tizen/src/skin/maruskin_keymap.h b/tizen/src/skin/maruskin_keymap.h index 198b706..69d8b14 100644 --- a/tizen/src/skin/maruskin_keymap.h +++ b/tizen/src/skin/maruskin_keymap.h @@ -31,6 +31,36 @@ #ifndef MARUSKIN_KEYMAP_H_ #define MARUSKIN_KEYMAP_H_ + +/* keep it consistent with java virtual keycode */ +#define JAVA_KEYCODE_BIT (1 << 24) +#define JAVA_KEYCODE_BIT_CTRL (1 << 18) +#define JAVA_KEYCODE_BIT_SHIFT (1 << 17) +#define JAVA_KEYCODE_BIT_ALT (1 << 16) + +#define JAVA_KEY_MASK 0xFFFF; + +enum JAVA_KEYCODE { + JAVA_KEY_ARROW_UP = 1, + JAVA_KEY_ARROW_DOWN, + JAVA_KEY_ARROW_LEFT, + JAVA_KEY_ARROW_RIGHT, + JAVA_KEY_PAGE_UP, + JAVA_KEY_PAGE_DOWN, + JAVA_KEY_HOME, + JAVA_KEY_END, + JAVA_KEY_INSERT, + JAVA_KEY_F1 = 10, + JAVA_KEY_F20 = 29, + JAVA_KEY_CAPS_LOCK = 82, + JAVA_KEY_NUM_LOCK, + JAVA_KEY_SCROLL_LOCK, + JAVA_KEY_PAUSE, + JAVA_KEY_BREAK, + JAVA_KEY_PRINT_SCREEN +}; + + /*#include #define SCANCODE_GREY 0x80 diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 9d46da1..a53144a 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -71,6 +71,11 @@ void start_display( int handle_id, int lcd_size_width, int lcd_size_height, doub void do_mouse_event( int event_type, int x, int y, int z ) { TRACE( "mouse_event event_type:%d, x:%d, y:%d, z:%d\n", event_type, x, y, z ); + if (get_emul_multi_touch_state()->multitouch_enable == 1 && MOUSE_DOWN == event_type) { + int finger_cnt = add_finger_point(x, y); + //TODO: + } + if ( MOUSE_DOWN == event_type || MOUSE_DRAG == event_type) { kbd_mouse_event(x, y, z, 1); } else if (MOUSE_UP == event_type) { @@ -85,6 +90,18 @@ void do_mouse_event( int event_type, int x, int y, int z ) { void do_key_event( int event_type, int keycode ) { TRACE( "key_event event_type:%d, keycode:%d\n", event_type, keycode ); + //check for multi-touch + if (keycode == JAVA_KEYCODE_BIT_CTRL) { + if (KEY_PRESSED == event_type) { + get_emul_multi_touch_state()->multitouch_enable = 1; + INFO("multi-touch enabled\n"); + } else if (KEY_RELEASED == event_type) { + get_emul_multi_touch_state()->multitouch_enable = 0; + clear_finger_slot(); + INFO("multi-touch disabled\n"); + } + } + if (!mloop_evcmd_get_usbkbd_status()) { return; } -- 2.7.4