From 2fb1c98ace5632e54715cb44979cdf5f7289b3fc Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Mon, 13 Mar 2017 15:31:55 +0900 Subject: [PATCH] input_generator: Add a new API for initialize - New API: efl_util_input_initialize_generator_with_name : Initialize input generator with specified name Change-Id: I790515db43bfffde1f801dd350b9d4d94c996bba --- include/efl_util.h.in | 21 ++++++++++++++++ src/efl_util.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/include/efl_util.h.in b/include/efl_util.h.in index 0fbaa14..258648f 100644 --- a/include/efl_util.h.in +++ b/include/efl_util.h.in @@ -372,6 +372,27 @@ API efl_util_inputgen_h efl_util_input_initialize_generator(unsigned int dev_typ /** * @platform + * @brief Initializes system, check input generate functions are supported and then open events generator devices with given name. + * @since_tizen 4.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/inputgenerator + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section. + * @remarks The dev_type is changed into the unsigned int to perform bitwise operations. + * @param[in] dev_type The device type want to generate events (ex> #EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN | #EFL_UTIL_INPUT_DEVTYPE_KEYBOARD) + * @param[in] name The device name (maximum 31 characters) + * @return #efl_util_inputgen_h on success, otherwise @c NULL + * @retval #efl_util_inputgen_h The input generator handle + * @exception #EFL_UTIL_ERROR_NONE Successful + * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #EFL_UTIL_ERROR_NO_SUCH_DEVICE No such device or address + * @exception #EFL_UTIL_ERROR_INVALID_OPERATION Function not implemented + * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @see efl_util_input_deinitialize_generator() + */ +API efl_util_inputgen_h efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name); + +/** + * @platform * @brief Deinitializes system and close opened devices. * @since_tizen $TZ_CFG_VER_24_OR_30$ * @privlevel platform diff --git a/src/efl_util.c b/src/efl_util.c index 170f0dc..0fc661e 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -1261,6 +1261,7 @@ efl_util_get_window_brightness(Evas_Object *window, int *brightness) struct _efl_util_inputgen_h { unsigned int init_type; + char name[32]; }; static void @@ -1387,6 +1388,73 @@ out: return NULL; } +API efl_util_inputgen_h +efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name) +{ + int ret = EFL_UTIL_ERROR_NONE; + efl_util_inputgen_h inputgen_h = NULL; + unsigned int clas = 0x0; + + if (!dev_type || + dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN + | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD + | EFL_UTIL_INPUT_DEVTYPE_POINTER)) + { + set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE); + goto out; + } + + inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h)); + if (!inputgen_h) + { + set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); + goto out; + } + + inputgen_h->init_type |= dev_type; + strncpy(inputgen_h->name, name, 31); + + ret = _wl_init(); + if (ret == (int)EINA_FALSE) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + goto out; + } + + if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN) + clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN; + if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD) + clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD; + if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER) + clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE; + + while (!_eflutil.wl.devmgr.devicemgr) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name); + + while (_eflutil.wl.devmgr.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified); + _eflutil.wl.devmgr.request_notified = -1; + + set_last_result(ret); + if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE) + goto out; + + return inputgen_h; + +out: + if (inputgen_h) + { + free(inputgen_h); + inputgen_h = NULL; + } + return NULL; +} + + API int efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h) { -- 2.7.4