From: InHong Han Date: Thu, 12 Jan 2023 09:21:56 +0000 (+0900) Subject: Add the new APIs for Chinese/Japanese text input X-Git-Tag: accepted/tizen/unified/20230710.154001~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec1a3e523ea6067d654a7a0006108f69fe46df20;p=platform%2Fcore%2Fuifw%2Flibscl-ui-nui.git Add the new APIs for Chinese/Japanese text input Change-Id: I96e9567929596053dba0f8ad2770590c9a78305d --- diff --git a/capi/include/cscl-ui-inputmethod.h b/capi/include/cscl-ui-inputmethod.h index 1279d9c..3252e27 100644 --- a/capi/include/cscl-ui-inputmethod.h +++ b/capi/include/cscl-ui-inputmethod.h @@ -21,7 +21,16 @@ extern "C" { #endif +typedef enum _LookupTableEventType { + CANDIDATE_EVENT_START, + CANDIDATE_EVENT_END, +} LookupTableEventType; + typedef void (*scl_process_key_event_with_imengine_cb)(uint32_t code, uint32_t mask, uint32_t layout, uint32_t dev_class, uint32_t dev_subclass, const char *dev_name, uint32_t serial, void* user_data); +typedef void (*scl_candidate_show_cb)(void* user_data); +typedef void (*scl_candidate_hide_cb)(void* user_data); +typedef void (*scl_lookup_table_changed_cb)(LookupTableEventType type, void* user_data); +typedef void (*scl_candidate_string_foreach_cb)(const char *item, void* user_data); int scl_set_imengine(const char *engine_id); int scl_flush_imengine(); @@ -29,6 +38,11 @@ int scl_reset_imengine(); int scl_send_imengine_event(int command, uint32_t value); int scl_set_engine_loader_flag(bool flag); int scl_set_process_key_event_with_imengine_cb(scl_process_key_event_with_imengine_cb callback, void *user_data); +int scl_set_candidate_show_cb(scl_candidate_show_cb callback, void *user_data); +int scl_set_candidate_hide_cb(scl_candidate_hide_cb callback, void *user_data); +int scl_set_lookup_table_changed_cb(scl_lookup_table_changed_cb callback, void *user_data); +int scl_set_candidate_string_foreach_cb(scl_candidate_string_foreach_cb callback, void *user_data); +int scl_select_candidate(uint32_t index); #ifdef __cplusplus } diff --git a/capi/include/cscl-ui-nui.h b/capi/include/cscl-ui-nui.h index 8222653..3090ee6 100644 --- a/capi/include/cscl-ui-nui.h +++ b/capi/include/cscl-ui-nui.h @@ -103,6 +103,7 @@ int scl_nui_get_shift_state(unsigned int *state); int scl_nui_set_shift_state(unsigned int state); int scl_nui_set_autocapital_shift_state(bool state); int scl_nui_disable_input_event(bool disable); +int scl_nui_set_custom_starting_coordinates(int x, int y); #ifdef __cplusplus } diff --git a/capi/src/cscl-ui-inputmethod.cpp b/capi/src/cscl-ui-inputmethod.cpp index 2bfb421..4d28a96 100644 --- a/capi/src/cscl-ui-inputmethod.cpp +++ b/capi/src/cscl-ui-inputmethod.cpp @@ -26,7 +26,15 @@ #define LOG_TAG "CSCLUINUI" static scl_process_key_event_with_imengine_cb g_process_key_event_with_imengine_cb = NULL; +static scl_candidate_show_cb g_candidate_show_cb = NULL; +static scl_candidate_hide_cb g_candidate_hide_cb = NULL; +static scl_lookup_table_changed_cb g_lookup_table_changed_cb = NULL; +static scl_candidate_string_foreach_cb g_candidate_string_foreach_cb = NULL; static void *g_process_key_event_with_imengine_cb_data = NULL; +static void *g_candidate_show_cb_data = NULL; +static void *g_candidate_hide_cb_data = NULL; +static void *g_lookup_table_changed_cb_data = NULL; +static void *g_candidate_string_foreach_cb_data = NULL; EXPORT_API int scl_set_imengine(const char *engine_id) { @@ -89,6 +97,113 @@ EXPORT_API int scl_set_process_key_event_with_imengine_cb(scl_process_key_event_ g_process_key_event_with_imengine_cb_data = user_data; ret = ime_event_set_process_key_event_with_imengine_cb(ime_app_process_key_event_with_imengine_cb, user_data); + if (ret != IME_ERROR_NONE) + LOGE("Failed to set ime_app_process_key_event_with_imengine_cb(), ret : %d", ret); return ret; } + +static void ime_app_candidate_show_cb(int context_id, void *user_data) +{ + LOGD("candidate_show_cb()"); + if (g_candidate_show_cb) { + g_candidate_show_cb(user_data); + } +} + +EXPORT_API int scl_set_candidate_show_cb(scl_candidate_show_cb callback, void *user_data) +{ + int ret = IME_ERROR_NONE; + + g_candidate_show_cb = callback; + g_candidate_show_cb_data = user_data; + + ret = ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, user_data); + if (ret != IME_ERROR_NONE) + LOGE("Failed to set ime_app_candidate_show_cb(), ret : %d", ret); + + return ret; +} + +static void ime_app_candidate_hide_cb(int context_id, void *user_data) +{ + LOGD("candidate_hide_cb()"); + if (g_candidate_hide_cb) { + g_candidate_hide_cb(user_data); + } +} + +EXPORT_API int scl_set_candidate_hide_cb(scl_candidate_hide_cb callback, void *user_data) +{ + int ret = IME_ERROR_NONE; + + g_candidate_hide_cb = callback; + g_candidate_hide_cb_data = user_data; + + ret = ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, user_data); + if (ret != IME_ERROR_NONE) + LOGE("Failed to set ime_app_candidate_hide_cb(), ret : %d", ret); + + return ret; +} + +static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data) +{ + LOGD("lookup_table_changed_cb()"); + if (g_lookup_table_changed_cb) { + char *candidate; + void *data; + Eina_List *l; + + g_lookup_table_changed_cb(CANDIDATE_EVENT_START, g_lookup_table_changed_cb_data); + + if (list) { + EINA_LIST_FOREACH(list, l, data) { + candidate = (char *)data; + if (candidate && g_candidate_string_foreach_cb) { + g_candidate_string_foreach_cb(candidate, g_candidate_string_foreach_cb_data); + } + } + } + + g_lookup_table_changed_cb(CANDIDATE_EVENT_END, g_lookup_table_changed_cb_data); + } +} + +EXPORT_API int scl_set_lookup_table_changed_cb(scl_lookup_table_changed_cb callback, void *user_data) +{ + int ret = IME_ERROR_NONE; + + g_lookup_table_changed_cb = callback; + g_lookup_table_changed_cb_data = user_data; + + ret = ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, user_data); + if (ret != IME_ERROR_NONE) + LOGE("Failed to set ime_app_lookup_table_changed_cb(), ret : %d", ret); + + return ret; +} + +EXPORT_API int scl_set_candidate_string_foreach_cb(scl_candidate_string_foreach_cb callback, void *user_data) +{ + int ret = IME_ERROR_NONE; + + if (!callback) { + LOGE("Invalid parameter"); + ret = IME_ERROR_INVALID_PARAMETER; + } + + g_candidate_string_foreach_cb = callback; + g_candidate_string_foreach_cb_data = user_data; + + return ret; +} + +EXPORT_API int scl_select_candidate(uint32_t index) +{ + int ret = IME_ERROR_NONE; + ret = ime_select_candidate(index); + + LOGD("index : %d, ret : %d", index, ret); + return ret; +} \ No newline at end of file diff --git a/capi/src/cscl-ui-nui.cpp b/capi/src/cscl-ui-nui.cpp index 0a547aa..d23cde3 100644 --- a/capi/src/cscl-ui-nui.cpp +++ b/capi/src/cscl-ui-nui.cpp @@ -511,5 +511,17 @@ EXPORT_API int scl_nui_disable_input_event(bool disable) g_ui->disable_input_events(disable); + return 0; +} + +EXPORT_API int scl_nui_set_custom_starting_coordinates(int x, int y) +{ + if (!g_ui) + return 1; + + LOGD("x : %d, y : %d", x, y); + + g_ui->set_custom_starting_coordinates(x, y); + return 0; } \ No newline at end of file