From: Jihoon Kim Date: Tue, 20 Jul 2021 08:45:45 +0000 (+0900) Subject: Reduce cyclomatic complexity X-Git-Tag: accepted/tizen/6.5/unified/20211028.115952~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a92ebb81f3f8846c2fea55998721004bc201e1f8;p=platform%2Fcore%2Fuifw%2Fise-default.git Reduce cyclomatic complexity Change-Id: I12988dea0ada1006cf35e1dcd87b990f32d4b8e2 Signed-off-by: Jihoon Kim --- diff --git a/src/ise.cpp b/src/ise.cpp index 40ddfba..4f8f394 100644 --- a/src/ise.cpp +++ b/src/ise.cpp @@ -242,6 +242,13 @@ public : SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc); SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc); SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info); + +private: + void on_event_string_key(CSCLUI *ui, SclUIEventDesc event_desc); + void on_event_control_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state); + void on_event_character_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state); + void on_event_modechange_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state, SCLEventReturnType &ret); + void process_user_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state, SCLEventReturnType &ret); }; static CUIEventCallback callback; @@ -921,336 +928,363 @@ end: app_control_destroy(app_control); } -SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc) +void CUIEventCallback::on_event_string_key(CSCLUI *ui, SclUIEventDesc event_desc) { - SCLEventReturnType ret = SCL_EVENT_PASS_ON; - if (word_timer != NULL) { - ecore_timer_del(word_timer); - word_timer = NULL; + if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START && + event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) { + if (event_desc.key_event) { + ise_forward_key_event(event_desc.key_event); + } else { + ise_send_string(event_desc.key_value); + } } - KEYBOARD_STATE *keyboard_state = get_keyboard_state(); - if (!keyboard_state) return ret; - - if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) { - if (!keyboard_state->multitap_value.empty()) { - ise_send_string(keyboard_state->multitap_value.c_str()); + if (!g_popup_opened) { + const sclchar *input_mode = ui->get_input_mode(); + if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) { + update_recent_used_punctuation(event_desc.key_value); } - ise_update_preedit_string(event_desc.key_value); - keyboard_state->multitap_value = event_desc.key_value; - } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) { - ise_update_preedit_string(event_desc.key_value); - keyboard_state->multitap_value = event_desc.key_value; - } else { - _reset_multitap_state(); + } else if (g_punctuation_popup_opened) { + update_recent_used_punctuation(event_desc.key_value); } - keyboard_state->prev_modifier = event_desc.key_modifier; +} - CSCLUI *ui = get_ui(); - if (ui) { - switch (event_desc.key_type) { - case KEY_TYPE_STRING: { - if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START && - event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) { - if (event_desc.key_event) { - ise_forward_key_event(event_desc.key_event); - } else { - ise_send_string(event_desc.key_value); - } - } - if (!g_popup_opened) { - const sclchar *input_mode = ui->get_input_mode(); - if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) { - update_recent_used_punctuation(event_desc.key_value); - } - } else if (g_punctuation_popup_opened) { - update_recent_used_punctuation(event_desc.key_value); - } - break; +void CUIEventCallback::on_event_control_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state) +{ + commit_timeout(NULL); + + const char *long_shift = "LongShift"; + const char *caps_lock = "CapsLock"; + const char *delete_all = "DeleteAll"; + const char *hide_panel = "Hide"; + + if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) { + LOGD("shift key is longpress\n"); + ui->set_shift_state(SCL_SHIFT_STATE_ON); + g_need_send_shift_event = TRUE; + //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL); + } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) { + bool load_in_ime = false; + const sclchar *cur_lang = _language_manager.get_current_language(); + if (cur_lang) { + LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang); + if (info) + load_in_ime = info->load_in_ime; + } + + if (ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) { + ui->set_shift_state(SCL_SHIFT_STATE_LOCK); + if (load_in_ime) + ime_send_imengine_event(MVK_Shift_Lock, 0); + else + engine_loader_send_imengine_event(MVK_Shift_Lock, 0); + } else { + ui->set_shift_state(SCL_SHIFT_STATE_OFF); + if (load_in_ime) + ime_send_imengine_event(MVK_Shift_Off, 0); + else + engine_loader_send_imengine_event(MVK_Shift_Off, 0); + } + //g_need_send_shift_event = TRUE; + } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) { + ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX); + } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) { + ise_hide(); + ime_request_hide(); + } else if (event_desc.key_event) { + if (keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE) { + ise_stt_stop(); } - case KEY_TYPE_CHAR: { - sclboolean need_forward = FALSE; - // FIXME : Should decide when to forward key events - const sclchar *input_mode = ui->get_input_mode(); - if (input_mode) { - if (strcmp(input_mode, "SYM_QTY_1") == 0 || - strcmp(input_mode, "SYM_QTY_2") == 0 || - strcmp(input_mode, "PHONE_3X4") == 0 || - strcmp(input_mode, "IPv6_3X4_123") == 0 || - strcmp(input_mode, "IPv6_3X4_ABC") == 0 || - strcmp(input_mode, "NUMONLY_3X4") == 0 || - strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 || - strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 || - strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 || - strcmp(input_mode, "DATETIME_3X4") == 0) { - need_forward = TRUE; - } - } - if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 && - strcmp(event_desc.key_value, ".") == 0) { - ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL); - ime_show_preedit_string(); - delete_commit_timer(); - _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL); - _click_count++; - } else if (event_desc.key_event) { - commit_timeout(NULL); - if (need_forward) { - ise_forward_key_event(event_desc.key_event); - } else { - if (_cm_popup_opened) { - static sclchar current_cm_symbol[2] = {'\0'}; - sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = { - const_cast(" "), - const_cast(" "), - const_cast(" ")}; - if (event_desc.key_value) { - current_cm_symbol[0] = event_desc.key_value[0]; - current_cm_symbol[1] = '\0'; - } - ui->set_private_key("CM_KEY", - const_cast(current_cm_symbol), - imagelabel, NULL, 0, - const_cast(current_cm_symbol), TRUE); - - _cm_popup_opened = FALSE; - _current_cm_key_id = -1; - } #ifdef _WEARABLE - /* - * - *change the keyboard mode of GLM from QWERTY to KEYPAD - *ensure the Number keypad won't be affected - * - */ - if (keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBER) { - ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false); - } else { - Candidate *candidate = get_candidate(); - if (word_timer == NULL && (!candidate || !candidate->get_visible())) { - word_timer = ecore_timer_add(MULTITAP_TIMEOUT, _multi_tap_timer_cb, NULL); - } - ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false); - } + if (event_desc.key_event == MVK_Done) { + LOGD("ENTER"); + //commit the preedit string first + ise_send_event(event_desc.key_event, KEY_MASK_NULL); + } #endif - ise_send_event(event_desc.key_event, KEY_MASK_NULL); - } - } - if (input_mode) { - if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) { - update_recent_used_punctuation(event_desc.key_value); - } + ise_send_event(event_desc.key_event, KEY_MASK_NULL); + if (event_desc.key_event == MVK_Shift_L) { + g_need_send_shift_event = TRUE; + } + } +} + +void CUIEventCallback::on_event_character_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state) +{ + sclboolean need_forward = FALSE; + // FIXME : Should decide when to forward key events + const sclchar *input_mode = ui->get_input_mode(); + if (input_mode) { + if (strcmp(input_mode, "SYM_QTY_1") == 0 || + strcmp(input_mode, "SYM_QTY_2") == 0 || + strcmp(input_mode, "PHONE_3X4") == 0 || + strcmp(input_mode, "IPv6_3X4_123") == 0 || + strcmp(input_mode, "IPv6_3X4_ABC") == 0 || + strcmp(input_mode, "NUMONLY_3X4") == 0 || + strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 || + strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 || + strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 || + strcmp(input_mode, "DATETIME_3X4") == 0) { + need_forward = TRUE; + } + } + if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 && + strcmp(event_desc.key_value, ".") == 0) { + ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL); + ime_show_preedit_string(); + delete_commit_timer(); + _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL); + _click_count++; + } else if (event_desc.key_event) { + commit_timeout(NULL); + if (need_forward) { + ise_forward_key_event(event_desc.key_event); + } else { + if (_cm_popup_opened) { + static sclchar current_cm_symbol[2] = {'\0'}; + sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = { + const_cast(" "), + const_cast(" "), + const_cast(" ")}; + if (event_desc.key_value) { + current_cm_symbol[0] = event_desc.key_value[0]; + current_cm_symbol[1] = '\0'; } - break; - } - case KEY_TYPE_CONTROL: { - commit_timeout(NULL); - - const char *long_shift = "LongShift"; - const char *caps_lock = "CapsLock"; - const char *delete_all = "DeleteAll"; - const char *hide_panel = "Hide"; - if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) { - LOGD("shift key is longpress\n"); - ui->set_shift_state(SCL_SHIFT_STATE_ON); - g_need_send_shift_event = TRUE; - //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL); - } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) { - bool load_in_ime = false; - const sclchar *cur_lang = _language_manager.get_current_language(); - if (cur_lang) { - LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang); - if (info) - load_in_ime = info->load_in_ime; - } + ui->set_private_key("CM_KEY", + const_cast(current_cm_symbol), + imagelabel, NULL, 0, + const_cast(current_cm_symbol), TRUE); - if (ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) { - ui->set_shift_state(SCL_SHIFT_STATE_LOCK); - if (load_in_ime) - ime_send_imengine_event(MVK_Shift_Lock, 0); - else - engine_loader_send_imengine_event(MVK_Shift_Lock, 0); - } else { - ui->set_shift_state(SCL_SHIFT_STATE_OFF); - if (load_in_ime) - ime_send_imengine_event(MVK_Shift_Off, 0); - else - engine_loader_send_imengine_event(MVK_Shift_Off, 0); - } - //g_need_send_shift_event = TRUE; - } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) { - ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX); - } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) { - ise_hide(); - ime_request_hide(); - } else if (event_desc.key_event) { - if (keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE) { - ise_stt_stop(); - } + _cm_popup_opened = FALSE; + _current_cm_key_id = -1; + } #ifdef _WEARABLE - if (event_desc.key_event == MVK_Done) { - LOGD("ENTER"); - //commit the preedit string first - ise_send_event(event_desc.key_event, KEY_MASK_NULL); - } -#endif - ise_send_event(event_desc.key_event, KEY_MASK_NULL); - if (event_desc.key_event == MVK_Shift_L) { - g_need_send_shift_event = TRUE; - } + /* + * change the keyboard mode of GLM from QWERTY to KEYPAD + * ensure the Number keypad won't be affected + */ + if (keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBER) { + ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false); + } else { + Candidate *candidate = get_candidate(); + if (word_timer == NULL && (!candidate || !candidate->get_visible())) { + word_timer = ecore_timer_add(MULTITAP_TIMEOUT, _multi_tap_timer_cb, NULL); } - break; - } - case KEY_TYPE_MODECHANGE: -#if defined(_MOBILE) || defined(_COMMON) - if (guide_popup_get_visible()) {//popup is showing - break; + ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false); } #endif - if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) { - if (!get_setting_window_open_status()) { - ise_hide_stt_mode(); + ise_send_event(event_desc.key_event, KEY_MASK_NULL); + } + } + + if (input_mode) { + if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) { + update_recent_used_punctuation(event_desc.key_value); + } + } +} + +void CUIEventCallback::on_event_modechange_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state, SCLEventReturnType &ret) +{ +#if defined(_MOBILE) || defined(_COMMON) + if (guide_popup_get_visible()) {//popup is showing + return; + } +#endif + + if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) { + if (!get_setting_window_open_status()) { + ise_hide_stt_mode(); #ifdef _WEARABLE - hide_indicator_window(); + hide_indicator_window(); #endif - create_setting_window(); - } - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) { - keyboard_state->layout = ISE_LAYOUT_STYLE_VOICE; - ui->set_input_mode("STT_3X4"); + create_setting_window(); + } + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) { + keyboard_state->layout = ISE_LAYOUT_STYLE_VOICE; + ui->set_input_mode("STT_3X4"); - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) { - launch_option(); + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) { + launch_option(); - ret = SCL_EVENT_DONE; - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) { - clipboard_show(); + ret = SCL_EVENT_DONE; + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) { + clipboard_show(); - ret = SCL_EVENT_DONE; - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) { - CONFIG_VALUES *config_values = get_config_values(); + ret = SCL_EVENT_DONE; + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) { + CONFIG_VALUES *config_values = get_config_values(); - if (g_floating_mode) { - if (config_values) { - config_values->floating_mode = false; - } - } else { - if (config_values) { - config_values->floating_mode = true; - } - } - write_ise_config_values(); + if (g_floating_mode) { + if (config_values) { + config_values->floating_mode = false; + } + } else { + if (config_values) { + config_values->floating_mode = true; + } + } + write_ise_config_values(); - ret = SCL_EVENT_DONE; - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_STICKER) == 0) { - SCLRotation rotation = ui->get_rotation(); - ise_sticker_show_layout(STICKER_GROUP_RECENTLY_USED, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window()); - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_TRANSLATION) == 0) { - if (ise_sticker_is_show()) - ise_sticker_destroy_layout(); + ret = SCL_EVENT_DONE; + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_STICKER) == 0) { + SCLRotation rotation = ui->get_rotation(); + ise_sticker_show_layout(STICKER_GROUP_RECENTLY_USED, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window()); + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_TRANSLATION) == 0) { + if (ise_sticker_is_show()) + ise_sticker_destroy_layout(); - SCLRotation rotation = ui->get_rotation(); - ise_nmt_show_layout(ROTATION_TO_DEGREE(rotation), false, ime_get_main_window()); - } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) { - ret = SCL_EVENT_DONE; - } - if (_cm_popup_opened) { - if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_STICKER) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_TRANSLATION) == 0) { - scluint id = ise_get_cm_key_id(event_desc.key_value); - if (id != _current_cm_key_id) { - _current_cm_key_id = id; - ise_set_cm_private_key(_current_cm_key_id); - } - } - _cm_popup_opened = FALSE; + SCLRotation rotation = ui->get_rotation(); + ise_nmt_show_layout(ROTATION_TO_DEGREE(rotation), false, ime_get_main_window()); + } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) { + ret = SCL_EVENT_DONE; + } + + if (_cm_popup_opened) { + if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_STICKER) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_TRANSLATION) == 0) { + scluint id = ise_get_cm_key_id(event_desc.key_value); + if (id != _current_cm_key_id) { + _current_cm_key_id = id; + ise_set_cm_private_key(_current_cm_key_id); } - if (strlen(event_desc.key_value) == 1) { - const char allowed_chars_in_modechange[] = { - ',', '?', '!', '`', '~', '@', '-' - }; - const int allowed_chars_in_modechange_num = - sizeof(allowed_chars_in_modechange) / sizeof(char); - for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) { - if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) { - ise_send_string(event_desc.key_value); - } - } + } + _cm_popup_opened = FALSE; + } + + if (strlen(event_desc.key_value) == 1) { + const char allowed_chars_in_modechange[] = { + ',', '?', '!', '`', '~', '@', '-' + }; + const int allowed_chars_in_modechange_num = + sizeof(allowed_chars_in_modechange) / sizeof(char); + for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) { + if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) { + ise_send_string(event_desc.key_value); } - break; - case KEY_TYPE_USER: - if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) { - //open_option_window(NULL, ROTATION_TO_DEGREE(ui->get_rotation())); - launch_option(); - - ret = SCL_EVENT_DONE; - } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) { - clipboard_show(); - ret = SCL_EVENT_DONE; - } else if (strcmp(event_desc.key_value, "Cancel") == 0) { - ret = SCL_EVENT_DONE; - const sclchar *input_mode = ui->get_input_mode(); - if (input_mode && strcmp(input_mode, "STT_3X4") == 0 ) { - keyboard_state->need_reset = TRUE; - voice_result_string_flush(); - ise_set_layout(keyboard_state->layout, keyboard_state->layout_variation); - if (keyboard_state->visible_state) - ise_show(keyboard_state->ic); - } + } + } +} + +void CUIEventCallback::process_user_key(CSCLUI *ui, SclUIEventDesc event_desc, KEYBOARD_STATE *keyboard_state, SCLEventReturnType &ret) +{ + if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) { + //open_option_window(NULL, ROTATION_TO_DEGREE(ui->get_rotation())); + launch_option(); + + ret = SCL_EVENT_DONE; + } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) { + clipboard_show(); + ret = SCL_EVENT_DONE; + } else if (strcmp(event_desc.key_value, "Cancel") == 0) { + ret = SCL_EVENT_DONE; + const sclchar *input_mode = ui->get_input_mode(); + if (input_mode && strcmp(input_mode, "STT_3X4") == 0 ) { + keyboard_state->need_reset = TRUE; + voice_result_string_flush(); + ise_set_layout(keyboard_state->layout, keyboard_state->layout_variation); + if (keyboard_state->visible_state) + ise_show(keyboard_state->ic); + } #ifdef _TV - ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL); - ime_request_hide(); + ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL); + ime_request_hide(); #endif - } else if (strcmp(event_desc.key_value, "Done") == 0) { + } else if (strcmp(event_desc.key_value, "Done") == 0) { #ifdef _TV - ret = SCL_EVENT_DONE; - ise_send_event(IME_KEY_Return, KEY_MASK_NULL); - ime_request_hide(); + ret = SCL_EVENT_DONE; + ise_send_event(IME_KEY_Return, KEY_MASK_NULL); + ime_request_hide(); #endif - } else if (strcmp(event_desc.key_value, "Translate") == 0) { - ise_nmt_translate(); - } else { - const sclchar *input_mode = ui->get_input_mode(); - if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) { - if (ise_emoticon_is_show()) { - ise_emoticon_destroy_layout(); - } + } else if (strcmp(event_desc.key_value, "Translate") == 0) { + ise_nmt_translate(); + } else { + const sclchar *input_mode = ui->get_input_mode(); + if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) { + if (ise_emoticon_is_show()) { + ise_emoticon_destroy_layout(); + } #ifdef _WEARABLE - emoticon_group_t group_id = EMOTICON_GROUP_1; - if (ise_emoticon_get_current_group() < EMOTICON_GROUP_3) - group_id = (emoticon_group_t)(ise_emoticon_get_current_group() + 1); + emoticon_group_t group_id = EMOTICON_GROUP_1; + if (ise_emoticon_get_current_group() < EMOTICON_GROUP_3) + group_id = (emoticon_group_t)(ise_emoticon_get_current_group() + 1); - ise_set_emoticon_label(group_id); + ise_set_emoticon_label(group_id); #else - emoticon_group_t group_id = ise_emoticon_get_group_id(event_desc.key_value); + emoticon_group_t group_id = ise_emoticon_get_group_id(event_desc.key_value); #endif - if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) { - SCLRotation rotation = ui->get_rotation(); - ise_emoticon_show_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window()); - } - } - - if (input_mode && (!strcmp(input_mode, "STICKER_LAYOUT"))) { - if (ise_sticker_is_show()) - ise_sticker_change_group(ise_sticker_get_group_id(event_desc.key_value)); - } + if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) { + SCLRotation rotation = ui->get_rotation(); + ise_emoticon_show_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window()); } - if (_cm_popup_opened) { - if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_STICKER) == 0 || - strcmp(event_desc.key_value, USER_KEYSTRING_TRANSLATION) == 0) { - scluint id = ise_get_cm_key_id(event_desc.key_value); - if (id != _current_cm_key_id) { - _current_cm_key_id = id; - ise_set_cm_private_key(_current_cm_key_id); - } - } - _cm_popup_opened = FALSE; + } + + if (input_mode && (!strcmp(input_mode, "STICKER_LAYOUT"))) { + if (ise_sticker_is_show()) + ise_sticker_change_group(ise_sticker_get_group_id(event_desc.key_value)); + } + } + + if (_cm_popup_opened) { + if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_STICKER) == 0 || + strcmp(event_desc.key_value, USER_KEYSTRING_TRANSLATION) == 0) { + scluint id = ise_get_cm_key_id(event_desc.key_value); + if (id != _current_cm_key_id) { + _current_cm_key_id = id; + ise_set_cm_private_key(_current_cm_key_id); } + } + _cm_popup_opened = FALSE; + } +} + +SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc) +{ + SCLEventReturnType ret = SCL_EVENT_PASS_ON; + if (word_timer != NULL) { + ecore_timer_del(word_timer); + word_timer = NULL; + } + + KEYBOARD_STATE *keyboard_state = get_keyboard_state(); + if (!keyboard_state) return ret; + + if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) { + if (!keyboard_state->multitap_value.empty()) { + ise_send_string(keyboard_state->multitap_value.c_str()); + } + ise_update_preedit_string(event_desc.key_value); + keyboard_state->multitap_value = event_desc.key_value; + } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) { + ise_update_preedit_string(event_desc.key_value); + keyboard_state->multitap_value = event_desc.key_value; + } else { + _reset_multitap_state(); + } + keyboard_state->prev_modifier = event_desc.key_modifier; + + CSCLUI *ui = get_ui(); + if (ui) { + switch (event_desc.key_type) { + case KEY_TYPE_STRING: + on_event_string_key(ui, event_desc); + break; + case KEY_TYPE_CHAR: + on_event_character_key(ui, event_desc, keyboard_state); + break; + case KEY_TYPE_CONTROL: + on_event_control_key(ui, event_desc, keyboard_state); + break; + case KEY_TYPE_MODECHANGE: + on_event_modechange_key(ui, event_desc, keyboard_state, ret); + break; + case KEY_TYPE_USER: + process_user_key(ui, event_desc, keyboard_state, ret); break; default: break; @@ -2977,128 +3011,138 @@ static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data) } #ifdef _WEARABLE +static sclu32 get_rotate_layout(ime_input_device_rotary_direction_e direction) +{ + KEYBOARD_STATE *keyboard_state = get_keyboard_state(); + if (!keyboard_state) return ISE_LAYOUT_STYLE_NORMAL; + + sclu32 new_layout = keyboard_state->layout; + + if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) { + LOGD("CLOCKWISE\n"); + switch (keyboard_state->layout) { + case ISE_LAYOUT_STYLE_NORMAL: + case ISE_LAYOUT_STYLE_EMAIL: + case ISE_LAYOUT_STYLE_URL: + case ISE_LAYOUT_STYLE_PASSWORD: + if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD && + _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY) + ; // PASSWORD NUMBER ONLY, do nothing + else + new_layout = ISE_LAYOUT_STYLE_NUMBER; + break; + case ISE_LAYOUT_STYLE_NUMBER: + new_layout = ISE_LAYOUT_STYLE_HEX; + break; + case ISE_LAYOUT_STYLE_HEX: + if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || + _context_layout == ISE_LAYOUT_STYLE_URL) + new_layout = ISE_LAYOUT_STYLE_VOICE; + else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD) + new_layout = _context_layout; + else + new_layout = ISE_LAYOUT_STYLE_EMOTICON; + break; + case ISE_LAYOUT_STYLE_EMOTICON: + if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || + _context_layout == ISE_LAYOUT_STYLE_URL || + _context_layout == ISE_LAYOUT_STYLE_PASSWORD) + new_layout = _context_layout; + else + new_layout = ISE_LAYOUT_STYLE_VOICE; + break; + case ISE_LAYOUT_STYLE_VOICE: + new_layout = ISE_LAYOUT_STYLE_NORMAL; + break; + default: + ; + } + } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) { + LOGD("COUNTER_CLOCKWISE\n"); + switch (keyboard_state->layout) { + case ISE_LAYOUT_STYLE_NORMAL: + case ISE_LAYOUT_STYLE_EMAIL: + case ISE_LAYOUT_STYLE_URL: + case ISE_LAYOUT_STYLE_PASSWORD: + if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD && + _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY) + ; // PASSWORD NUMBER ONLY, do nothing + else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD) + new_layout = ISE_LAYOUT_STYLE_HEX; + else + new_layout = ISE_LAYOUT_STYLE_VOICE; + break; + case ISE_LAYOUT_STYLE_NUMBER: + if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || + _context_layout == ISE_LAYOUT_STYLE_URL || + _context_layout == ISE_LAYOUT_STYLE_PASSWORD) + new_layout = _context_layout; + else + new_layout = ISE_LAYOUT_STYLE_NORMAL; + break; + case ISE_LAYOUT_STYLE_HEX: + new_layout = ISE_LAYOUT_STYLE_NUMBER; + break; + case ISE_LAYOUT_STYLE_EMOTICON: + new_layout = ISE_LAYOUT_STYLE_HEX; + break; + case ISE_LAYOUT_STYLE_VOICE: + if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || + _context_layout == ISE_LAYOUT_STYLE_URL) + new_layout = ISE_LAYOUT_STYLE_HEX; + else + new_layout = ISE_LAYOUT_STYLE_EMOTICON; + break; + default: + ; + } + } + + return new_layout; +} + static void ime_app_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data) { KEYBOARD_STATE *keyboard_state = get_keyboard_state(); if (!keyboard_state) return; + if (device_type != IME_INPUT_DEVICE_TYPE_ROTARY) return; - if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) { - ime_input_device_rotary_direction_e direction; - if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) { - sclu32 new_layout = keyboard_state->layout; - if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) { - LOGD("CLOCKWISE\n"); - switch (keyboard_state->layout) { - case ISE_LAYOUT_STYLE_NORMAL: - case ISE_LAYOUT_STYLE_EMAIL: - case ISE_LAYOUT_STYLE_URL: - case ISE_LAYOUT_STYLE_PASSWORD: - if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD && - _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY) - ; // PASSWORD NUMBER ONLY, do nothing - else - new_layout = ISE_LAYOUT_STYLE_NUMBER; - break; - case ISE_LAYOUT_STYLE_NUMBER: - new_layout = ISE_LAYOUT_STYLE_HEX; - break; - case ISE_LAYOUT_STYLE_HEX: - if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || - _context_layout == ISE_LAYOUT_STYLE_URL) - new_layout = ISE_LAYOUT_STYLE_VOICE; - else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD) - new_layout = _context_layout; - else - new_layout = ISE_LAYOUT_STYLE_EMOTICON; - break; - case ISE_LAYOUT_STYLE_EMOTICON: - if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || - _context_layout == ISE_LAYOUT_STYLE_URL || - _context_layout == ISE_LAYOUT_STYLE_PASSWORD) - new_layout = _context_layout; - else - new_layout = ISE_LAYOUT_STYLE_VOICE; - break; - case ISE_LAYOUT_STYLE_VOICE: - new_layout = ISE_LAYOUT_STYLE_NORMAL; - break; - default: - ; - } - } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) { - LOGD("COUNTER_CLOCKWISE\n"); - switch (keyboard_state->layout) { - case ISE_LAYOUT_STYLE_NORMAL: - case ISE_LAYOUT_STYLE_EMAIL: - case ISE_LAYOUT_STYLE_URL: - case ISE_LAYOUT_STYLE_PASSWORD: - if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD && - _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY) - ; // PASSWORD NUMBER ONLY, do nothing - else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD) - new_layout = ISE_LAYOUT_STYLE_HEX; - else - new_layout = ISE_LAYOUT_STYLE_VOICE; - break; - case ISE_LAYOUT_STYLE_NUMBER: - if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || - _context_layout == ISE_LAYOUT_STYLE_URL || - _context_layout == ISE_LAYOUT_STYLE_PASSWORD) - new_layout = _context_layout; - else - new_layout = ISE_LAYOUT_STYLE_NORMAL; - break; - case ISE_LAYOUT_STYLE_HEX: - new_layout = ISE_LAYOUT_STYLE_NUMBER; - break; - case ISE_LAYOUT_STYLE_EMOTICON: - new_layout = ISE_LAYOUT_STYLE_HEX; - break; - case ISE_LAYOUT_STYLE_VOICE: - if (_context_layout == ISE_LAYOUT_STYLE_EMAIL || - _context_layout == ISE_LAYOUT_STYLE_URL) - new_layout = ISE_LAYOUT_STYLE_HEX; - else - new_layout = ISE_LAYOUT_STYLE_EMOTICON; - break; - default: - ; - } - } + ime_input_device_rotary_direction_e direction; + if (IME_ERROR_NONE != ime_input_device_rotary_get_direction(device_event, &direction)) return; - CONFIG_VALUES *config_values = get_config_values(); - if (check_is_tutorial_show() && config_values) { - read_ise_config_values(); - if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && !config_values->number_tutorial_enable && !config_values->symbol_tutorial_enable) || - (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && config_values->symbol_tutorial_enable)) { - new_layout = keyboard_state->layout; - } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && config_values->symbol_tutorial_enable) { - ise_destroy_tutorial_mode_popup(); - config_values->symbol_tutorial_enable = false; - write_ise_config_values(); - } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && !config_values->number_tutorial_enable) { - ise_destroy_tutorial_mode_popup(); - new_layout = ISE_LAYOUT_STYLE_NUMBER; - if (!config_values->symbol_tutorial_enable) { - ise_show_tutorial_mode_popup(new_layout); - config_values->symbol_tutorial_enable = true; - write_ise_config_values(); - } - } + sclu32 new_layout = get_rotate_layout(direction); + + CONFIG_VALUES *config_values = get_config_values(); + if (check_is_tutorial_show() && config_values) { + read_ise_config_values(); + if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && !config_values->number_tutorial_enable && !config_values->symbol_tutorial_enable) || + (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && config_values->symbol_tutorial_enable)) { + new_layout = keyboard_state->layout; + } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && config_values->symbol_tutorial_enable) { + ise_destroy_tutorial_mode_popup(); + config_values->symbol_tutorial_enable = false; + write_ise_config_values(); + } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && !config_values->number_tutorial_enable) { + ise_destroy_tutorial_mode_popup(); + new_layout = ISE_LAYOUT_STYLE_NUMBER; + if (!config_values->symbol_tutorial_enable) { + ise_show_tutorial_mode_popup(new_layout); + config_values->symbol_tutorial_enable = true; + write_ise_config_values(); } + } + } - if (new_layout != keyboard_state->layout && new_layout < ISE_LAYOUT_STYLE_MAX) { - keyboard_state->need_reset = TRUE; - keyboard_state->layout = new_layout; + if (new_layout != keyboard_state->layout && new_layout < ISE_LAYOUT_STYLE_MAX) { + keyboard_state->need_reset = TRUE; + keyboard_state->layout = new_layout; - if (keyboard_state->visible_state) { - _reset_multitap_state(); - if (config_values) { - _language_manager.reset_language(config_values->selected_language.c_str()); - } - ise_show(keyboard_state->ic); - } + if (keyboard_state->visible_state) { + _reset_multitap_state(); + if (config_values) { + _language_manager.reset_language(config_values->selected_language.c_str()); } + ise_show(keyboard_state->ic); } } }