inputgenerator: Add a new API to generate pointer events 57/85757/14
authorJengHyun Kang <jhyuni.kang@samsung.com>
Mon, 26 Sep 2016 08:33:07 +0000 (17:33 +0900)
committerJengHyun Kang <jhyuni.kang@samsung.com>
Wed, 28 Sep 2016 01:25:09 +0000 (10:25 +0900)
Change-Id: I065a4b55f1d0c5ddbbccd83e609b43e85989afbb

include/efl_util.h.in
src/efl_util.c

index 80acd47..5f07701 100644 (file)
@@ -320,12 +320,13 @@ API int efl_util_get_window_brightness(Evas_Object *window, int *brightness);
  */
 typedef enum
 {
-   EFL_UTIL_INPUT_DEVTYPE_NONE = 0x0,
+   EFL_UTIL_INPUT_DEVTYPE_NONE = 0x0, /**< (Deprecated since 3.0.) */
    EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN = (1 << 0), /**< Touch Screen device */
    EFL_UTIL_INPUT_DEVTYPE_KEYBOARD = (1 << 1), /**< Keyboard device */
+   EFL_UTIL_INPUT_DEVTYPE_POINTER = (1 << 2), /**< Mouse device (Since 3.0) */
    EFL_UTIL_INPUT_DEVTYPE_ALL = EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN |
-                                EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, /**< Both of touch screen and keyboard device */
-   EFL_UTIL_INPUT_DEVTYPE_MAX = (1 << 10)
+                                EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, /**< Both of touch screen and keyboard device (Deprecated since 3.0. Check all enumerations using OR operand instead) */
+   EFL_UTIL_INPUT_DEVTYPE_MAX = (1 << 10) /**< (Deprecated since 3.0.) */
 } efl_util_input_device_type_e;
 
 /**
@@ -335,21 +336,34 @@ typedef enum
  */
 typedef enum
 {
-   EFL_UTIL_INPUT_TOUCH_NONE,
+   EFL_UTIL_INPUT_TOUCH_NONE, /**< (Deprecated since 3.0.) */
    EFL_UTIL_INPUT_TOUCH_BEGIN, /**< Finger press. It is same a behavior put your finger on touch screen */
    EFL_UTIL_INPUT_TOUCH_UPDATE, /**< Finger move. It is same a behavior move your finger on touch screen */
    EFL_UTIL_INPUT_TOUCH_END, /**< Finger release. It is same a behavior release your finger on touch screen */
-   EFL_UTIL_INPUT_TOUCH_MAX = 10
+   EFL_UTIL_INPUT_TOUCH_MAX = 10 /**< (Deprecated since 3.0.) */
 } efl_util_input_touch_type_e;
 
 /**
+ * @platform
+ * @brief Enumeration of pointer event types.
+ * @since_tizen 3.0
+ */
+typedef enum
+{
+   EFL_UTIL_INPUT_POINTER_BUTTON_DOWN, /**< Mouse button press. */
+   EFL_UTIL_INPUT_POINTER_BUTTON_UP, /**< Mouse move. */
+   EFL_UTIL_INPUT_POINTER_MOVE, /**< Mouse button release. */
+} efl_util_input_pointer_type_e;
+
+/**
    * @platform
    * @brief Initializes system and check input generate functions are supported, open devices generated events.
    * @since_tizen $TZ_CFG_VER_24_OR_30$
    * @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.
-   * @param[in] dev_type The device type want to generate events (ex> #EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, #EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, #EFL_UTIL_INPUT_DEVTYPE_ALL)
+   * @remarks The dev_type is changed into the unsigned int to perform bitwise operations. (Since 3.0)
+   * @param[in] dev_type The device type want to generate events (ex> #EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN | #EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
    * @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
@@ -359,7 +373,7 @@ typedef enum
    * @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(efl_util_input_device_type_e dev_type);
+API efl_util_inputgen_h efl_util_input_initialize_generator(unsigned int dev_type);
 
 /**
    * @platform
@@ -410,6 +424,25 @@ API int efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *
 API int efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx, efl_util_input_touch_type_e touch_type, int x, int y);
 
 /**
+   * @platform
+   * @brief Generate a pointer event using a opened device.
+   * @since_tizen 3.0
+   * @privlevel platform
+   * @privilege %http://tizen.org/privilege/inputgenerator
+   * @param[in] buttons The number of button
+   * @param[in] efl_util_input_pointer_type_e The pointer type (ex> EFL_UTIL_INPUT_POINTER_BUTTON_PRESS, EFL_UTIL_INPUT_POINTER_BUTTON_UP, EFL_UTIL_INPUT_POINTER_MOVE)
+   * @param[in] x x coordination to move
+   * @param[in] y y coordination to move
+   * @return @c 0 on success, otherwise a negative error value
+   * @retval #EFL_UTIL_ERROR_NONE Successful
+   * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+   * @retval #EFL_UTIL_ERROR_PERMISSION_DENIED Has no permission to generate pointer
+   * @retval #EFL_UTIL_ERROR_NO_SUCH_DEVICE No such device or address
+   * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure
+   */
+API int efl_util_input_generate_pointer(efl_util_inputgen_h inputgen_h, int buttons, efl_util_input_pointer_type_e pointer_type, int x, int y);
+
+/**
  * @}
  */
 
index fd15f7e..4ad4c79 100644 (file)
@@ -1204,13 +1204,15 @@ _efl_util_input_convert_input_generator_error(int ret)
 }
 
 API efl_util_inputgen_h
-efl_util_input_initialize_generator(efl_util_input_device_type_e dev_type)
+efl_util_input_initialize_generator(unsigned int dev_type)
 {
    int ret = EFL_UTIL_ERROR_NONE;
    efl_util_inputgen_h inputgen_h = NULL;
 
-   if ((dev_type <= EFL_UTIL_INPUT_DEVTYPE_NONE) ||
-       (dev_type >= EFL_UTIL_INPUT_DEVTYPE_MAX))
+   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;
@@ -1343,6 +1345,46 @@ efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
    return ret;
 }
 
+API int
+efl_util_input_generate_pointer(efl_util_inputgen_h inputgen_h, int buttons, efl_util_input_pointer_type_e pointer_type, int x, int y)
+{
+   int ret;
+   enum tizen_input_device_manager_pointer_event_type type;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   switch(pointer_type)
+     {
+        case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
+           type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
+           break;
+        case EFL_UTIL_INPUT_POINTER_MOVE:
+           type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
+           break;
+        case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
+           type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
+           break;
+        default:
+           return EFL_UTIL_ERROR_INVALID_PARAMETER;
+     }
+
+   tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
+
+   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;
+
+   return ret;
+}
+
+
 struct _efl_util_screenshot_h
 {
    int width;