Added support for multitap buttons 31/65431/3
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 8 Apr 2016 12:57:06 +0000 (21:57 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 11 Apr 2016 04:33:49 +0000 (13:33 +0900)
Change-Id: Ia4e4167ac504ea48400f9ba5ecac9d8f7ab902da

scl/include/sclconfig.h
scl/include/sclcontroller.h
scl/include/sclresourcecache.h
scl/sclcontroller.cpp
scl/scluibuilder.cpp

index f1609b8..77159c6 100644 (file)
@@ -108,6 +108,7 @@ typedef enum _SCLKeyModifier {
     KEY_MODIFIER_LONGKEY,                                              /**< longkey event */
     KEY_MODIFIER_MULTITAP_START,                               /**< multitap started */
     KEY_MODIFIER_MULTITAP_REPEAT,                              /**< multitap repeated */
+    KEY_MODIFIER_MULTITAP_RELEASE,                             /**< multitap released */
 
     KEY_MODIFIER_DIRECTION_LEFT,                               /**< drag left */
     KEY_MODIFIER_DIRECTION_RIGHT,                              /**< drag right */
@@ -286,6 +287,7 @@ typedef enum _SCLTimer {
     SCL_TIMER_POPUP_TIMEOUT,
     SCL_TIMER_ANIMATION,
     SCL_TIMER_AUTOTEST,
+    SCL_TIMER_MULTITAP,
 }SCLTimer;
 
 /**@brief  Feedback style */
@@ -425,6 +427,7 @@ typedef enum _SCLStartingCoordinatesOption {
 #define SCL_REPEATKEY_MIN_DURATION 50
 
 #define SCL_BUTTON_MIN_DURATION 100
+#define SCL_MULTITAP_DEFAULT_DURATION 3000
 
 #define SCL_DIRECTION_RECOG_DIST 60
 #define SCL_DIRECTION_RECOG_DIST_SIDE 20
index 8f2246d..77b2d1f 100644 (file)
@@ -111,6 +111,7 @@ protected:
     scllong m_autopopup_key_duration;
 
     scllong m_button_delay_duration;
+    scllong m_multitap_delay_duration;
 
     SCLDebugMode m_debug_mode;
     sclint m_debug_variable;
index 3c6e034..dcad2d1 100644 (file)
@@ -29,7 +29,7 @@ namespace scl
 
 typedef struct _SclButtonContext {
     sclboolean used;
-    sclbyte multikeyIdx;
+    sclbyte multitap_index;
     sclboolean toggled;
     SCLButtonState state;
 } SclButtonContext;
index 219dcdc..f601c66 100644 (file)
@@ -87,6 +87,7 @@ CSCLController::CSCLController()
     m_autopopup_key_duration = SCL_AUTOPOPUP_KEY_DURATION;
 
     m_button_delay_duration = SCL_BUTTON_MIN_DURATION;
+    m_multitap_delay_duration = SCL_MULTITAP_DEFAULT_DURATION;
 
     m_key_repeated_num = 0;
 
@@ -355,11 +356,11 @@ CSCLController::check_magnifier_available(sclwindow window, sclbyte key_index, s
                     }
                     if (!custom_label) {
                         //if (coordinate->key_value[shift_index][button_context->multikeyIdx] == NULL) {
-                        if (coordinate->label[shift_index][button_context->multikeyIdx] == NULL) {
+                        if (coordinate->label[shift_index][button_context->multitap_index] == NULL) {
                             //utils->log("show_magnifier coordinate->key_value[shift][button_context->multikeyIdx] == NULL \n");
                             ret = FALSE;
                             //} else if (strlen(coordinate->key_value[shift_index][button_context->multikeyIdx]) == 0) {
-                        } else if (strlen(coordinate->label[shift_index][button_context->multikeyIdx]) == 0) {
+                        } else if (strlen(coordinate->label[shift_index][button_context->multitap_index]) == 0) {
                             //utils->log("show_magnifier coordinate->key_value[shift][button_context->multikeyIdx]) == 0 \n");
                             ret = FALSE;
                         }
@@ -713,7 +714,7 @@ CSCLController::process_button_pressed_event(sclwindow window, sclint x, sclint
             //}
             /* BUTTON_TYPE_MULTITAP type button should restore its multikey index when another button is clicked */
             if (coordinate->button_type & BUTTON_TYPE_MULTITAP) {
-                button_context->multikeyIdx = 0;
+                button_context->multitap_index = 0;
             }
         }
 
@@ -756,6 +757,7 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
     assert(sclres_layout != NULL);
     if (context && cache && handler && windows && state) {
         const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
+        SclButtonContext *button_context = cache->get_cur_button_context(window, key_index);
 
         /* Should return FALSE if this key does not have any longkey related property */
         if (coordinate) {
@@ -957,6 +959,9 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
         }
         if (ret) {
             context->set_cur_key_modifier(touch_id, KEY_MODIFIER_LONGKEY);
+            if (coordinate->button_type & BUTTON_TYPE_MULTITAP) {
+                button_context->multitap_index = 0;
+            }
         }
     }
     /* Longkey processing in here */
@@ -1400,12 +1405,12 @@ CSCLController::process_button_over_event(sclwindow window, sclint x, sclint y,
                 if (layout) {
                     if (coordinate->key_type != KEY_TYPE_NONE) {
                         if (context->get_tts_enabled()) {
-                            const sclchar *targetstr = coordinate->hint_string[shift_index][button_context->multikeyIdx];
+                            const sclchar *targetstr = coordinate->hint_string[shift_index][button_context->multitap_index];
                             if (targetstr == NULL) {
                                 targetstr = coordinate->label[shift_index][0];
                             }
                             if (targetstr == NULL) {
-                                targetstr = coordinate->key_value[shift_index][button_context->multikeyIdx];
+                                targetstr = coordinate->key_value[shift_index][button_context->multitap_index];
                             }
                             /*if(state->get_cur_action_state() == ACTION_STATE_BASE_LONGKEY ||
                                 state->get_cur_action_state() == ACTION_STATE_POPUP_LONGKEY ) {
@@ -1764,21 +1769,25 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                         } else {
                             key_modifier = KEY_MODIFIER_NONE;
                         }
-                        if (button_context->multikeyIdx < MAX_SIZE_OF_MULTITAP_CHAR) {
-                            key_event_desc.key_value = coordinate->key_value[shift_index][button_context->multikeyIdx];
-                            key_event_desc.key_event = coordinate->key_event[shift_index][button_context->multikeyIdx];
+                        if (button_context->multitap_index < MAX_SIZE_OF_MULTITAP_CHAR) {
+                            key_event_desc.key_value = coordinate->key_value[shift_index][button_context->multitap_index];
+                            key_event_desc.key_event = coordinate->key_event[shift_index][button_context->multitap_index];
                             key_event_desc.key_modifier = key_modifier;
-                            handler->on_event_key_clicked(key_event_desc);
+                            if (SCL_EVENT_PASS_ON == handler->on_event_key_clicked(key_event_desc)) {
+                                CSCLEvents *events = CSCLEvents::get_instance();
+                                events->destroy_timer(SCL_TIMER_MULTITAP);
+                                events->create_timer(SCL_TIMER_MULTITAP, m_multitap_delay_duration, 0);
+                            }
                         }
                         /* Check if the multikey index is in valid range, and increase by one */
-                        if (button_context->multikeyIdx >= MAX_SIZE_OF_MULTITAP_CHAR - 1) {
-                            button_context->multikeyIdx = 0;
+                        if (button_context->multitap_index >= MAX_SIZE_OF_MULTITAP_CHAR - 1) {
+                            button_context->multitap_index = 0;
                         } else {
-                            sclbyte orgindex = button_context->multikeyIdx;
-                            button_context->multikeyIdx = 0;
+                            sclbyte orgindex = button_context->multitap_index;
+                            button_context->multitap_index = 0;
                             if (targetCoordinate->key_value[shift_index][orgindex + 1]) {
                                 if (strlen(targetCoordinate->key_value[shift_index][orgindex + 1]) > 0) {
-                                    button_context->multikeyIdx = orgindex + 1;
+                                    button_context->multitap_index = orgindex + 1;
                                 }
                             }
                         }
@@ -1923,8 +1932,8 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                 SclUIEventDesc key_event_desc;
                 key_event_desc.key_type = targetCoordinate->key_type;
 
-                key_event_desc.key_value = targetCoordinate->key_value[shift_index][button_context->multikeyIdx];
-                key_event_desc.key_event = targetCoordinate->key_event[shift_index][button_context->multikeyIdx];
+                key_event_desc.key_value = targetCoordinate->key_value[shift_index][button_context->multitap_index];
+                key_event_desc.key_event = targetCoordinate->key_event[shift_index][button_context->multitap_index];
                 key_event_desc.key_modifier = key_modifier;
 
                 key_event_desc.event_type = EVENT_TYPE_RELEASE;
@@ -2082,6 +2091,7 @@ CSCLController::mouse_press(sclwindow window, sclint x, sclint y, scltouchdevice
         events->destroy_timer(SCL_TIMER_SHORT_LONGKEY);
         events->destroy_timer(SCL_TIMER_LONGKEY);
         events->destroy_timer(SCL_TIMER_REPEATKEY);
+        events->destroy_timer(SCL_TIMER_MULTITAP);
 
         /* Do what has to be done when mouse gets pressed */
         handle_engine_signal(SCL_SIG_MOUSE_PRESS, window);
@@ -3513,6 +3523,16 @@ CSCLController::timer_event(const scl32 data)
         return FALSE;
     }
     break;
+    case SCL_TIMER_MULTITAP: {
+        SclUIEventDesc key_event_desc;
+        key_event_desc.event_type = EVENT_TYPE_RELEASE;
+        key_event_desc.key_modifier = KEY_MODIFIER_MULTITAP_RELEASE;
+        handler->on_event_key_clicked(key_event_desc);
+
+        events->destroy_timer(id);
+        return FALSE;
+    }
+    break;
     case SCL_TIMER_AUTOTEST: {
         srand(time(NULL));
 
index 41dbac5..0d27b47 100644 (file)
@@ -561,8 +561,8 @@ CSCLUIBuilder::draw_button_label(const sclwindow window, const scldrawctx draw_c
                     if (coordinate->button_type == BUTTON_TYPE_ROTATION) {
                         SclButtonContext* button_context = cache->get_cur_button_context(window, key_index);
                         if (button_context) {
-                            if (button_context->multikeyIdx < MAX_SIZE_OF_MULTITAP_CHAR) {
-                                label = coordinate->key_value[shift][button_context->multikeyIdx];
+                            if (button_context->multitap_index < MAX_SIZE_OF_MULTITAP_CHAR) {
+                                label = coordinate->key_value[shift][button_context->multitap_index];
                             }
                         }
                     }
@@ -1117,7 +1117,7 @@ CSCLUIBuilder::show_magnifier(const sclwindow window, scldrawctx draw_ctx)
                         } else if (loop == 0) {
                             /* Don't display sublabels of each buttons in magnifier window - this policy can be changed, but for now */
                             if (button_context) {
-                                targetstr = coordinate->label[shift_index][button_context->multikeyIdx];
+                                targetstr = coordinate->label[shift_index][button_context->multitap_index];
                                 targetstr = cache->find_substituted_string(targetstr);
                             }
                         }