From 1a234517f7e127c1de68aca1b96464532063ee74 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 14:31:55 +0900 Subject: [PATCH] plugin-api: common: Add SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin module Add SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT for input plugin module. [Detailed description] 1. Newly added SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin module - module : SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT - library_name : "/usr/lib/system/plugin/libplugin-backend-deviced-input.so" - library_name_64bit : "/usr/lib64/system/plugin/libplugin-backend-deviced-input.so" - symbol_name : "system_plugin_backend_deviced_input_data" 2. Newly added SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin api - int syscommon_plugin_deviced_input_get_backend(void) : Load Deviced input plugin-backend from above library_name/library_name_64bit path - int syscommon_plugin_deviced_input_put_backend(void); : Unload Deviced input plugin-backend - void syscommon_plugin_deviced_input_event_cb(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue); : Callback function to handle the key event when input key event happen Change-Id: I0194c88da69abff226c92846637c0e000d58e019 Signed-off-by: Chanwoo Choi --- .../common/include/syscommon-plugin-common.h | 1 + .../common/src/syscommon-plugin-api-list.h | 18 ++++ src/plugin-api/deviced/CMakeLists.txt | 1 + .../syscommon-plugin-deviced-input-interface.h | 47 +++++++++++ .../include/syscommon-plugin-deviced-input.h | 57 +++++++++++++ .../deviced/src/syscommon-plugin-deviced-input.c | 96 ++++++++++++++++++++++ 6 files changed, 220 insertions(+) create mode 100644 src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h create mode 100644 src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h create mode 100644 src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c diff --git a/src/plugin-api/common/include/syscommon-plugin-common.h b/src/plugin-api/common/include/syscommon-plugin-common.h index c644453..8caccbb 100644 --- a/src/plugin-api/common/include/syscommon-plugin-common.h +++ b/src/plugin-api/common/include/syscommon-plugin-common.h @@ -35,6 +35,7 @@ enum syscommon_plugin_module { SYSCOMMON_PLUGIN_MODULE_UNKNOWN = 0, SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK, SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY, + SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, SYSCOMMON_PLUGIN_MODULE_END, }; diff --git a/src/plugin-api/common/src/syscommon-plugin-api-list.h b/src/plugin-api/common/src/syscommon-plugin-api-list.h index 66a6c01..7d61902 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-list.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-list.h @@ -48,6 +48,12 @@ static struct plugin_abi_version_match abi_version_match_data[SYSCOMMON_PLUGIN_M .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, }, }, + [SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT] = { + [0] = { + .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, + .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, + }, + }, }; static struct __plugin_module_info g_plugin_module_info[] = { @@ -75,6 +81,18 @@ static struct __plugin_module_info g_plugin_module_info[] = { .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY]), .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY], }, + [SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT] = { + .group = PLUGIN_GROUP_DEVICED, + .module = SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + .license = PLUGIN_LICENSE_APACHE_2_0, + .module_name = "SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT", + .backend_module_name = "deviced-input", + .library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-input.so", + .library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-input.so", + .symbol_name = "system_plugin_backend_deviced_input_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT]), + .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT], + }, }; #endif /* __PLUGIN_API_LIST_H__ */ diff --git a/src/plugin-api/deviced/CMakeLists.txt b/src/plugin-api/deviced/CMakeLists.txt index a82642b..644c594 100644 --- a/src/plugin-api/deviced/CMakeLists.txt +++ b/src/plugin-api/deviced/CMakeLists.txt @@ -41,6 +41,7 @@ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") # to PKG_MODULES. SET(SRCS src/syscommon-plugin-deviced-display.c src/syscommon-plugin-deviced-battery.c + src/syscommon-plugin-deviced-input.c ../common/src/syscommon-plugin-api-common.c ../common/src/syscommon-plugin-api-conf.c) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h new file mode 100644 index 0000000..b777152 --- /dev/null +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h @@ -0,0 +1,47 @@ +/** + * MIT License + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __SYSCOMMON_PLUGIN_DEVICED_INPUT_INTERFACE_H__ +#define __SYSCOMMON_PLUGIN_DEVICED_INPUT_INTERFACE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SYSCOMMON_DEVICED_INPUT_KEY_RELEASED 0 +#define SYSCOMMON_DEVICED_INPUT_KEY_PRESSED 1 +#define SYSCOMMON_DEVICED_INPUT_KEY_BEING_PRESSED 2 + +typedef struct _syscommon_plugin_backend_deviced_input_funcs { + void (*input_event_cb)(struct timeval time, unsigned short type, + unsigned short keycode, unsigned int keyvalue); +} syscommon_plugin_backend_deviced_input_funcs; + +#ifdef __cplusplus +} +#endif + +#endif //__SYSCOMMON_PLUGIN_DEVICED_input_INTERFACE_H__ diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h new file mode 100644 index 0000000..9dda045 --- /dev/null +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h @@ -0,0 +1,57 @@ +/** + * MIT License + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __SYSCOMMON_PLUGIN_DEVICED_INPUT_H__ +#define __SYSCOMMON_PLUGIN_DEVICED_INPUT_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the backend data of deviced-input module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_input_get_backend(void); + +/** + * @brief Put the backend data of deviced-input module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_input_put_backend(void); + +/** + * @brief Input event callback function + */ +void syscommon_plugin_deviced_input_event_cb(struct timeval time, unsigned short type, + unsigned short keycode, unsigned int keyvalue); + + +#ifdef __cplusplus +} +#endif + +#endif //__SYSCOMMON_PLUGIN_DEVICED_INPUT_H__ diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c new file mode 100644 index 0000000..350e574 --- /dev/null +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c @@ -0,0 +1,96 @@ +/** + * MIT License + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include + +#include "syscommon-plugin-common.h" + +#include "common.h" +#include "syscommon-plugin-deviced-input.h" +#include "syscommon-plugin-deviced-input-interface.h" + +#ifndef EXPORT +#define EXPORT __attribute__((visibility("default"))) +#endif + +static syscommon_plugin_backend_deviced_input_funcs *g_input_funcs = NULL; + +EXPORT +int syscommon_plugin_deviced_input_get_backend(void) +{ + int ret = 0; + + if (g_input_funcs) + return 0; + + ret = syscommon_plugin_common_get_backend( + SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + (void **)&g_input_funcs); + if (ret < 0) { + _E("Failed to get deviced_input backend: %d", ret); + return ret; + } + + _I("Success to get deviced_input backend: %d", ret); + + return 0; +} + +EXPORT +int syscommon_plugin_deviced_input_put_backend(void) +{ + int ret = 0; + + if (!g_input_funcs) + return 0; + + ret = syscommon_plugin_common_put_backend( + SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + (void *)g_input_funcs); + if (ret < 0) { + _E("Failed to put deviced_input backend: %d", ret); + return ret; + } + g_input_funcs = NULL; + + _I("Success to put deviced_input backend: %d", ret); + + return 0; +} + +EXPORT +void syscommon_plugin_deviced_input_event_cb(struct timeval time, unsigned short type, + unsigned short keycode, unsigned int keyvalue) +{ + if (!g_input_funcs) { + _E("Failed to get device_input backend : -ENOTSUP\n"); + return; + } + + if (!g_input_funcs->input_event_cb) { + _E("Failed to execute (*input_event_cb) : -ENOTSUP\n"); + return; + } + + g_input_funcs->input_event_cb(time, type, keycode, keyvalue); +} -- 2.7.4