e_input, e_comp_wl, e_devicemgr: enable setting the maximum touch count using configu... 57/249257/8 submit/tizen/20201216.054340
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 9 Dec 2020 09:01:46 +0000 (18:01 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 16 Dec 2020 04:57:00 +0000 (04:57 +0000)
Change-Id: Id4c941d5154acdb97e4df1618c9f9830d997dd21
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
13 files changed:
src/bin/e_comp_wl.c
src/bin/e_comp_wl.h
src/bin/e_config.c
src/bin/e_config.h
src/bin/e_devicemgr.h
src/bin/e_devicemgr_input.c
src/bin/e_devicemgr_inputgen.c
src/bin/e_devicemgr_private.h
src/bin/e_info_server_input.c
src/bin/e_input.c
src/bin/e_input.h
src/bin/e_input_evdev.c
src/bin/e_input_private.h

index 61b1cdf..d194d5e 100644 (file)
@@ -970,6 +970,8 @@ _e_comp_wl_device_send_axis(const char *dev_name, Evas_Device_Class dev_class, E
 static void
 _e_comp_wl_device_renew_axis(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
 {
+   if (idx >= e_input_touch_max_count_get()) return;
+
    _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
    e_devicemgr->multi[idx].radius_x = radius_x;
    _e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
@@ -983,7 +985,7 @@ _e_comp_wl_device_renew_axis(const char *dev_name, Evas_Device_Class dev_class,
 static void
 _e_comp_wl_device_handle_axes(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
 {
-   if (idx >= E_COMP_WL_TOUCH_MAX) return;
+   if (idx >= e_input_touch_max_count_get()) return;
 
    if (e_devicemgr->multi[idx].radius_x != radius_x)
      {
index 745f4b5..33f9b04 100644 (file)
@@ -34,8 +34,6 @@ typedef struct _E_Comp_Wl_Pid_Hook E_Comp_Wl_Pid_Hook;
 
 #include <tbm_surface.h>
 
-#define E_COMP_WL_TOUCH_MAX 10
-
 typedef struct _E_Comp_Wl_Aux_Hint  E_Comp_Wl_Aux_Hint;
 typedef struct _E_Comp_Wl_Buffer E_Comp_Wl_Buffer;
 typedef struct _E_Comp_Wl_Buffer_Ref E_Comp_Wl_Buffer_Ref;
index 1f439f5..aa2ff91 100644 (file)
@@ -312,6 +312,8 @@ _e_config_edd_init(Eina_Bool old)
    E_CONFIG_VAL(D, T, fake_output_resolution.w, INT);
    E_CONFIG_VAL(D, T, fake_output_resolution.h, INT);
    E_CONFIG_VAL(D, T, raise_before_show, UCHAR);
+   E_CONFIG_VAL(D, T, configured_max_touch.use, UCHAR);
+   E_CONFIG_VAL(D, T, configured_max_touch.count, UINT);
 }
 
 static Eina_Bool
@@ -554,6 +556,9 @@ e_config_load(void)
    E_CONFIG_LIMIT(e_config->desk_zoom_effect.duration, 0.0, 10.0);
    E_CONFIG_LIMIT(e_config->fake_output_resolution.use, 0, 1);
    E_CONFIG_LIMIT(e_config->raise_before_show, 0, 1);
+   E_CONFIG_LIMIT(e_config->configured_max_touch.use, 0, 1);
+   // FIXME : What's the proper maximum value for 'configured_max_touch.count' ?
+   E_CONFIG_LIMIT(e_config->configured_max_touch.count, 1, 20);
 }
 
 E_API int
index 2e9d266..b4d88cd 100644 (file)
@@ -248,6 +248,13 @@ struct _E_Config
       int h;             // height of the configured output resolution.
    } configured_output_resolution;
 
+   // Configured for maximum touch count
+   struct
+   {
+      unsigned char use; // use the configured maximum touch count
+      int count;             // value of the configured maximum touch count
+   } configured_max_touch;
+
    //specific global object( client not to bind )
    struct
    {
index f0767da..9c83a29 100644 (file)
@@ -51,7 +51,7 @@ struct _E_Devicemgr
    E_Devicemgr_Input_Device *last_device_ptr;
    E_Devicemgr_Input_Device *last_device_touch;
    E_Devicemgr_Input_Device *last_device_kbd;
-   E_Devicemgr_Input_Device_Multi multi[E_COMP_WL_TOUCH_MAX];
+   E_Devicemgr_Input_Device_Multi *multi;
 
    struct
      {
index 8bc8712..a5f40e2 100644 (file)
@@ -211,7 +211,20 @@ _e_devicemgr_input_device_add(const char *name, const char *identifier, const ch
      e_devicemgr->last_device_ptr = dev;
 
    if (!e_devicemgr->last_device_touch && dev->clas == ECORE_DEVICE_CLASS_TOUCH)
-     e_devicemgr->last_device_touch = dev;
+     {
+        e_devicemgr->last_device_touch = dev;
+
+        if (e_devicemgr->multi)
+          {
+             ELOGF("DEVMGR_TOUCH", "Multi pointer is NOT NULL. It'll be updated.\n", NULL);
+             free (e_devicemgr->multi);
+          }
+
+        e_devicemgr->multi = calloc(1, sizeof(E_Devicemgr_Input_Device_Multi)*e_input_touch_max_count_get());
+
+        if (!e_devicemgr->multi)
+          ELOGF("DEVMGR_TOUCH", "Failed to allocate memory for multi ptr. (finger=%d)\n", NULL, e_input_touch_max_count_get());
+     }
 
    if (!e_devicemgr->last_device_kbd && dev->clas == ECORE_DEVICE_CLASS_KEYBOARD)
      e_devicemgr->last_device_kbd = dev;
@@ -461,4 +474,7 @@ e_devicemgr_input_shutdown(void)
         e_devicemgr_destroy_virtual_device(e_devicemgr->virtual_mouse_device_fd);
         e_devicemgr->virtual_mouse_device_fd = -1;
      }
+
+   if (e_devicemgr->multi)
+     free(e_devicemgr->multi);
 }
index a844a0c..4cb4275 100644 (file)
@@ -482,7 +482,17 @@ _e_devicemgr_inputgen_remove_device(E_Devicemgr_Inputgen_Device_Data *device)
                     device->touch.pressed &= ~(1 << i);
                  }
                i++;
-               if (i >= INPUTGEN_MAX_TOUCH) break;
+               if (i >= e_input_touch_max_count_get()) break;
+            }
+          if (device->touch.coords)
+            {
+               free(device->touch.coords);
+               device->touch.coords = NULL;
+            }
+          if (device->touch.axis)
+            {
+               free(device->touch.axis);
+               device->touch.axis = NULL;
             }
           break;
         case ECORE_DEVICE_CLASS_MOUSE:
@@ -741,6 +751,33 @@ _e_devicemgr_inputgen_hw_device_check(E_Devicemgr_Inputgen_Device_Data *device)
    return EINA_FALSE;
 }
 
+static Eina_Bool
+_e_devicemgr_init_touch_coords_and_axis(E_Devicemgr_Inputgen_Device_Data *device)
+{
+   if (device->touch.coords)
+     free(device->touch.coords);
+
+   device->touch.coords = calloc(1, sizeof(E_Devicemgr_Coords)*e_input_touch_max_count_get());
+   if (!device->touch.coords)
+     {
+        DMWRN("Failed to allocate memory for coords ptr ! (finger=%d)\n", e_input_touch_max_count_get());
+        return EINA_FALSE;
+     }
+
+   if (device->touch.axis)
+     free(device->touch.axis);
+
+   device->touch.axis = calloc(1, sizeof(E_Devicemgr_Inputgen_Touch_Axis)*e_input_touch_max_count_get());
+   if (!device->touch.axis)
+     {
+        DMWRN("Failed to allocate memory for axis ptr ! (finger=%d)\n", e_input_touch_max_count_get());
+        free(device->touch.coords);
+        return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
+
 int
 _e_devicemgr_inputgen_create_device(Ecore_Device_Class clas, struct wl_client *client, const char *device_name)
 {
@@ -807,7 +844,13 @@ _e_devicemgr_inputgen_create_device(Ecore_Device_Class clas, struct wl_client *c
    device->uinp_fd = uinp_fd;
    *dev_list = eina_list_append(*dev_list, device);
 
-   for (i = 0; i < INPUTGEN_MAX_TOUCH; i++)
+   if (!_e_devicemgr_init_touch_coords_and_axis(device))
+     {
+        DMERR("DEVMGR_TOUCH Failed to init touch coords and axis !\n");
+        goto fail_create_device;
+     }
+
+   for (i = 0; i < e_input_touch_max_count_get(); i++)
      {
         device->touch.coords[i].x = -1;
         device->touch.coords[i].y = -1;
@@ -1033,7 +1076,7 @@ e_devicemgr_inputgen_generate_touch(struct wl_client *client, struct wl_resource
 
    name = _e_devicemgr_inputgen_name_get(resource);
 
-   if (finger >= INPUTGEN_MAX_TOUCH)
+   if (finger >= e_input_touch_max_count_get())
      {
         DMWRN("Invalid fingers: %d\n", finger);
         return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER;
@@ -1215,7 +1258,7 @@ e_devicemgr_create_virtual_device(Ecore_Device_Class clas, const char *name)
        uinp.absmin[ABS_Y] = 0;
        uinp.absmax[ABS_Y] = 1000;
        uinp.absmin[ABS_MT_SLOT] = 0;
-       uinp.absmax[ABS_MT_SLOT] = INPUTGEN_MAX_TOUCH - 1;
+       uinp.absmax[ABS_MT_SLOT] = e_input_touch_max_count_get() - 1;
        uinp.absmin[ABS_MT_TOUCH_MAJOR] = 0;
        uinp.absmax[ABS_MT_TOUCH_MAJOR] = 255;
        uinp.absmin[ABS_MT_TOUCH_MINOR] = 0;
index e9013e3..bbaba75 100644 (file)
@@ -39,7 +39,6 @@
 
 #define INPUT_GENERATOR_DEVICE "Input Generator"
 #define DETENT_DEVICE_NAME "tizen_detent"
-#define INPUTGEN_MAX_TOUCH 10
 #define INPUTGEN_MAX_BTN 16
 
 typedef struct _E_Devicemgr_Input_Device_User_Data E_Devicemgr_Input_Device_User_Data;
@@ -92,8 +91,8 @@ struct _E_Devicemgr_Inputgen_Device_Data
    struct
      {
         unsigned int pressed;
-        E_Devicemgr_Coords coords[INPUTGEN_MAX_TOUCH];
-        E_Devicemgr_Inputgen_Touch_Axis axis[INPUTGEN_MAX_TOUCH];
+        E_Devicemgr_Coords *coords;
+        E_Devicemgr_Inputgen_Touch_Axis *axis;
         E_Devicemgr_Inputgen_Touch_Axis axis_tmp;
      } touch;
    struct
index 74eb6e6..ca61790 100644 (file)
@@ -50,6 +50,7 @@ _e_info_input_set_touch(struct uinput_user_dev *uinput_dev, int uinput_fd)
 {
    E_Output *output;
    int w = 0, h = 0;
+   int max_mt_slot = 9;//set touch max count 10 by default
 
    output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
    e_output_size_get(output, &w, &h);
@@ -60,6 +61,14 @@ _e_info_input_set_touch(struct uinput_user_dev *uinput_dev, int uinput_fd)
    if (w <= 0) w = 4096;
    if (h <= 0) h = 4096;
 
+   if (e_config->configured_max_touch.use)
+     {
+        max_mt_slot = e_input_touch_max_count_get() - 1;
+
+        if (max_mt_slot < 0)
+          max_mt_slot = 9;//set touch max count 10 by default
+     }
+
    ioctl(uinput_fd, UI_SET_EVBIT, EV_ABS);
 
    ioctl(uinput_fd, UI_SET_KEYBIT, BTN_TOUCH);
@@ -78,7 +87,7 @@ _e_info_input_set_touch(struct uinput_user_dev *uinput_dev, int uinput_fd)
    uinput_dev->absmin[ABS_Y] = 0;
    uinput_dev->absmax[ABS_Y] = h - 1;
    uinput_dev->absmin[ABS_MT_SLOT] = 0;
-   uinput_dev->absmax[ABS_MT_SLOT] = 9;
+   uinput_dev->absmax[ABS_MT_SLOT] = max_mt_slot;
    uinput_dev->absmin[ABS_MT_TOUCH_MAJOR] = 0;
    uinput_dev->absmax[ABS_MT_TOUCH_MAJOR] = 255;
    uinput_dev->absmin[ABS_MT_TOUCH_MINOR] = 0;
index ac084bd..6108eb7 100644 (file)
@@ -89,6 +89,9 @@ e_input_init(Ecore_Evas *ee)
    e_input->input_base_dir = eina_stringshare_add("/dev/input");
    e_input->use_thread = EINA_FALSE;
 
+   e_input->touch_device_count = 0;
+   e_input->touch_max_count = 1;//This is going to updated when a touch device is attached.
+
    dev = e_input_device_open();
 
    e_input->ee = ee;
@@ -241,3 +244,12 @@ e_input_ecore_evas_get(E_Input *ei)
    if (ei) return ei->ee;
    return NULL;
 }
+
+E_API unsigned int
+e_input_touch_max_count_get()
+{
+   if (e_input)
+     return e_input->touch_max_count;
+   else
+     return 0;
+}
\ No newline at end of file
index 1743976..d82833f 100644 (file)
@@ -34,6 +34,7 @@ typedef struct _E_Input_Device E_Input_Device;
 typedef struct _E_Input_Backend E_Input_Backend;
 typedef struct _E_Input_Evdev E_Input_Evdev;
 typedef struct _E_Input_Seat E_Input_Seat;
+typedef struct _E_Input_Coord E_Input_Coord;
 
 struct _E_Input
 {
@@ -44,6 +45,8 @@ struct _E_Input
    Eina_List *handlers;
 
    Eina_Bool use_thread : 1;
+   unsigned int touch_max_count;
+   unsigned int touch_device_count;
 };
 
 struct _E_Input_Device
@@ -108,6 +111,8 @@ E_API Ecore_Device *e_input_evdev_get_ecore_device(const char *path, Ecore_Devic
 E_API unsigned int e_input_device_touch_pressed_get(E_Input_Device *dev);
 E_API Eina_Bool e_input_device_keyboard_remap_set(E_Input_Device *dev, int *from_keys, int *to_keys, int num);
 
+E_API unsigned int e_input_touch_max_count_get();
+
 EINTERN Eina_Bool e_input_device_block(E_Input_Device *dev, unsigned int type, void *client);
 EINTERN Eina_Bool e_input_device_unblock(E_Input_Device *dev, void *client);
 
index ade7f20..c183257 100644 (file)
@@ -88,6 +88,52 @@ cont:
 }
 
 static void
+_device_touch_count_update(E_Input_Evdev *edev)
+{
+   unsigned int device_touch_count = 0;
+   static unsigned int _max_device_touch_count = 0;
+
+   E_Input *ei = e_input_get();
+   EINA_SAFETY_ON_NULL_RETURN(ei);
+
+   device_touch_count = libinput_device_touch_get_touch_count(edev->device);
+
+   if (_max_device_touch_count < device_touch_count)
+     _max_device_touch_count = device_touch_count;
+
+   if (e_config->configured_max_touch.use)
+     {
+        if (_max_device_touch_count > 0 && e_config->configured_max_touch.count > _max_device_touch_count)
+          {
+             ELOGF("E_INPUT_EVDEV_TOUCH", "Touch max count(%d) must be less or equal to device's touch count(%d) !\nTouch max count has been shrinken to %d.\n",
+                         NULL, e_config->configured_max_touch.count, _max_device_touch_count, _max_device_touch_count);
+             ei->touch_max_count = _max_device_touch_count;
+          }
+        else
+          {
+             if (ei->touch_max_count != e_config->configured_max_touch.count)
+             {
+                ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n",
+                           NULL, ei->touch_max_count, e_config->configured_max_touch.count);
+                ei->touch_max_count = e_config->configured_max_touch.count;
+             }
+          }
+     }
+   else
+     {
+        if (ei->touch_max_count < _max_device_touch_count)
+          {
+             ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n", NULL,
+                   ei->touch_max_count, _max_device_touch_count);
+             ei->touch_max_count = _max_device_touch_count;
+          }
+     }
+
+   ei->touch_device_count++;
+   ELOGF("E_INPUT_EVDEV_TOUCH", "Touch device count is %d.\n", NULL, ei->touch_device_count);
+}
+
+static void
 _device_configure(E_Input_Evdev *edev)
 {
    if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
@@ -1276,7 +1322,7 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_
           }
      }
 
-   if (edev->mt_slot < E_INPUT_MAX_SLOTS)
+   if (edev->mt_slot < e_input_touch_max_count_get())
      {
         edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
         edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
@@ -1344,7 +1390,7 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even
           }
      }
 
-   if (edev->mt_slot < E_INPUT_MAX_SLOTS)
+   if (edev->mt_slot < e_input_touch_max_count_get())
      {
         edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
         edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
@@ -1389,7 +1435,7 @@ _device_handle_touch_up(struct libinput_device *device, struct libinput_event_to
           }
      }
 
-   if (edev->mt_slot < E_INPUT_MAX_SLOTS)
+   if (edev->mt_slot < e_input_touch_max_count_get())
      {
         edev->mouse.dx = edev->seat->ptr.dx = edev->seat->ptr.ix =
           edev->touch.coords[edev->mt_slot].x;
@@ -1556,6 +1602,13 @@ _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
           {
              libinput_device_touch_set_aux_data(device, palm_code);
           }
+
+        _device_touch_count_update(edev);
+
+        edev->touch.coords = calloc(1, sizeof(E_Input_Coord)*e_input_touch_max_count_get());
+
+        if  (!edev->touch.coords)
+          ERR("Failed to allocate memory for touch coords !\n");
      }
 
    libinput_device_set_user_data(device, edev);
@@ -1589,6 +1642,11 @@ _e_input_evdev_device_destroy(E_Input_Evdev *edev)
    if (edev->path) eina_stringshare_del(edev->path);
    if (edev->device) libinput_device_unref(edev->device);
    if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
+   if (edev->touch.coords)
+     {
+        free(edev->touch.coords);
+        edev->touch.coords = NULL;
+     }
 
    free(edev);
 }
index 1c6323f..9e0192b 100644 (file)
@@ -16,7 +16,11 @@ extern struct xkb_context *cached_context;
 #define E_INPUT_ENV_LIBINPUT_LOG_DISABLE "E_INPUT_LIBINPUT_LOG_DISABLE"
 #define E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG "E_INPUT_LIBINPUT_LOG_EINA_LOG"
 
-#define E_INPUT_MAX_SLOTS 10
+struct _E_Input_Coord
+{
+   int x;
+   int y;
+};
 
 struct _E_Input_Seat
 {
@@ -112,12 +116,8 @@ struct _E_Input_Evdev
              int x, y;
              int w, h;
           } transform;
-        struct
-          {
-             int x;
-             int y;
-          } coords[E_INPUT_MAX_SLOTS];
 
+        E_Input_Coord *coords;
         unsigned int pressed;
         unsigned int raw_pressed;
         Eina_Bool blocked;