Add new APIs to support Korean input 21/282921/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 6 Oct 2022 09:54:24 +0000 (18:54 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 13 Oct 2022 06:36:49 +0000 (15:36 +0900)
Change-Id: Ib339a261c9a9280459acf0d8ff5986648dfd0cfe

CMakeLists.txt
capi/CMakeLists.txt
capi/include/cscl-ui-inputmethod.h [new file with mode: 0644]
capi/src/cscl-ui-inputmethod.cpp [new file with mode: 0644]

index d2b22e7abdcb4dd6216c9305af4e57e267c8232b..897ccab32747703bb06afb49780e92f6d38b595b 100644 (file)
@@ -95,9 +95,6 @@ SET(PKGS_CHECK_MODULES
         vconf
         eldbus
         libscl-common
-        dbus-1
-        gio-2.0
-        capi-ui-inputmethod
         )
 
 IF (with_wayland)
index f7beb667159e73f7c2baf57cd4ea5709e04bda8c..6d0c207f612f32421b1f99893f6b77aa367c9057 100644 (file)
@@ -14,6 +14,9 @@ pkg_check_modules(pkgs REQUIRED
     eldbus
     libscl-common
     ecore-wl2
+    dbus-1
+    gio-2.0
+    capi-ui-inputmethod
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
@@ -40,7 +43,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
 AUX_SOURCE_DIRECTORY(src SOURCES)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../scl LIBSCL_SOURCES)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../res LIBSCL_RES_SOURCES)
-ADD_LIBRARY(${fw_name} SHARED 
+ADD_LIBRARY(${fw_name} SHARED
         ${SOURCES}
         ${LIBSCL_SOURCES}
         ${LIBSCL_RES_SOURCES}
diff --git a/capi/include/cscl-ui-inputmethod.h b/capi/include/cscl-ui-inputmethod.h
new file mode 100644 (file)
index 0000000..1279d9c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SCL_CAPI_INPUTMETHOD_H__
+#define __SCL_CAPI_INPUTMETHOD_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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);
+
+int scl_set_imengine(const char *engine_id);
+int scl_flush_imengine();
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SCL_CAPI_INPUTMETHOD_H__ */
diff --git a/capi/src/cscl-ui-inputmethod.cpp b/capi/src/cscl-ui-inputmethod.cpp
new file mode 100644 (file)
index 0000000..2bfb421
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+#include <tizen.h>
+#include <inputmethod.h>
+#include <inputmethod_internal.h>
+#include "cscl-ui-inputmethod.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CSCLUINUI"
+
+static scl_process_key_event_with_imengine_cb g_process_key_event_with_imengine_cb = NULL;
+static void *g_process_key_event_with_imengine_cb_data = NULL;
+
+EXPORT_API int scl_set_imengine(const char *engine_id)
+{
+    int ret = IME_ERROR_NONE;
+    ret = ime_set_imengine(engine_id);
+
+    LOGD("engine_id : %s, ret : %d", engine_id, ret);
+    return ret;
+}
+
+EXPORT_API int scl_flush_imengine()
+{
+    int ret = IME_ERROR_NONE;
+    ret = ime_flush_imengine();
+
+    LOGD("ret : %d", ret);
+    return ret;
+}
+
+EXPORT_API int scl_reset_imengine()
+{
+    int ret = IME_ERROR_NONE;
+    ret = ime_reset_imengine();
+
+    LOGD("ret : %d", ret);
+    return ret;
+}
+
+EXPORT_API int scl_send_imengine_event(int command, uint32_t value)
+{
+    int ret = IME_ERROR_NONE;
+    ret = ime_send_imengine_event(command, value);
+
+    LOGD("command : %d, value : %d, ret : %d", command, value, ret);
+    return ret;
+}
+
+EXPORT_API int scl_set_engine_loader_flag(bool flag)
+{
+    int ret = IME_ERROR_NONE;
+    ret = ime_set_engine_loader_flag(flag);
+
+    LOGD("flag : %d, ret : %d", flag, ret);
+    return ret;
+}
+
+static void ime_app_process_key_event_with_imengine_cb(scim::KeyEvent &key, uint32_t serial, void *user_data)
+{
+    LOGD("process_key_event_with_imengine = key : %p, serial : %d", &key, serial);
+    if (g_process_key_event_with_imengine_cb) {
+        g_process_key_event_with_imengine_cb(key.code, key.mask, key.layout, key.dev_class, key.dev_subclass, (key.dev_name).c_str(), serial, user_data);
+    }
+}
+
+EXPORT_API int scl_set_process_key_event_with_imengine_cb(scl_process_key_event_with_imengine_cb callback, void *user_data)
+{
+    int ret = IME_ERROR_NONE;
+
+    g_process_key_event_with_imengine_cb = callback;
+    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);
+
+    return ret;
+}