input_generator: add a API to set touch count 96/250596/3 accepted/tizen/unified/20210115.004626 submit/tizen/20210113.113637
authorjeon <jhyuni.kang@samsung.com>
Wed, 30 Dec 2020 04:54:16 +0000 (13:54 +0900)
committerjeon <jhyuni.kang@samsung.com>
Wed, 13 Jan 2021 08:55:54 +0000 (17:55 +0900)
Change-Id: I97b885e2f9549f5e826bf4d84b75259e0556e37c

include/efl_util.h
src/efl_util.c

index 981c4e4..a4d902f 100644 (file)
@@ -341,6 +341,25 @@ API efl_util_inputgen_h efl_util_input_initialize_generator_with_sync(unsigned i
 
 /**
    * @platform
+   * @brief Requests to set the maximum touch count.
+   * @since_tizen 6.5
+   * @privlevel platform
+   * @privilege %http://tizen.org/privilege/inputgenerator
+   * @remarks If you would like to generate more touch count supported than the display server supports,
+              you can use this API to increase the maximum touch count.
+              Note that this API returns success only when there is no configuration enabled
+              about maximum touch count in the display server.
+   * @param[in] max_count The maximum number of touches want to generate.
+   * @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 deinitialize input generator
+   * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available
+   */
+API int efl_util_input_set_touch_count(int max_count);
+
+/**
+   * @platform
    * @brief Deinitializes system and close opened devices.
    * @since_tizen @if WEARABLE 3.0 @else 2.4 @endif
    * @privlevel platform
index b031ba0..22c6e56 100644 (file)
@@ -216,6 +216,8 @@ typedef struct _Efl_Util_Data
          Eina_List *devices;
          Eina_List *wait_devices;
          struct wl_event_source *wait_timer;
+         int max_touch_count;
+         int request_touch_count;
       } devmgr;
       struct
       {
@@ -253,7 +255,7 @@ static Efl_Util_Data _eflutil =
       NULL, NULL, NULL,
       { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
       { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
-      { NULL, -1, NULL, NULL, NULL }, /* tizen_input_device_manager protocol */
+      { NULL, -1, NULL, NULL, NULL, 0, 0 }, /* tizen_input_device_manager protocol */
       { 0, NULL, NULL } /* display_policy protocol */
    },
 };
@@ -1402,10 +1404,10 @@ static void
 _cb_max_touch_count(void *data EINA_UNUSED,
                     struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
                     uint32_t serial EINA_UNUSED,
-                    int32_t max_count EINA_UNUSED,
+                    int32_t max_count,
                     struct wl_seat *seat EINA_UNUSED)
 {
-   ;
+   _eflutil.wl.devmgr.max_touch_count = max_count;
 }
 
 static efl_util_error_e
@@ -1421,6 +1423,8 @@ _efl_util_input_convert_input_generator_error(int ret)
            return EFL_UTIL_ERROR_OUT_OF_MEMORY;
         case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
            return EFL_UTIL_ERROR_INVALID_PARAMETER;
+        case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED:
+           return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
         default :
            return EFL_UTIL_ERROR_NONE;
      }
@@ -1718,6 +1722,39 @@ out:
 }
 
 API int
+efl_util_input_set_touch_count(int max_count)
+{
+   int ret = EFL_UTIL_ERROR_NONE;
+
+   ret = _wl_init();
+   if (ret == (int)EINA_FALSE)
+     {
+        return EFL_UTIL_ERROR_INVALID_PARAMETER;
+     }
+
+   while (!_eflutil.wl.devmgr.devicemgr)
+     wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+
+   if (_eflutil.wl.devmgr.max_touch_count >= max_count)
+     return EFL_UTIL_ERROR_NONE;
+
+   tizen_input_device_manager_set_touch_count(_eflutil.wl.devmgr.devicemgr, max_count);
+
+   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;
+
+   if (ret == EFL_UTIL_ERROR_NONE)
+     {
+        _eflutil.wl.devmgr.request_touch_count = max_count;
+     }
+
+   return ret;
+}
+
+API int
 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
 {
    int ret = EFL_UTIL_ERROR_NONE;
@@ -1785,6 +1822,9 @@ efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
    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_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
 
+   if (idx >= _eflutil.wl.devmgr.request_touch_count)
+     return EFL_UTIL_ERROR_INVALID_PARAMETER;
+
    EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
    switch(touch_type)