e_input: fix not to do unnecessary udev-lookups and loops 17/162917/4
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 6 Dec 2017 07:34:10 +0000 (16:34 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Wed, 6 Dec 2017 07:49:12 +0000 (07:49 +0000)
Change-Id: Ibc99b5886327deebc5efa338c7bd6210404106e9
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/bin/e_input.c
src/bin/e_input.h
src/bin/e_input_device.c
src/bin/e_input_evdev.c

index 4cb7c57..57020b5 100644 (file)
@@ -13,6 +13,12 @@ E_API int E_EVENT_INPUT_DISABLED = -1;
 
 E_API E_Input *e_input = NULL;
 
+EINTERN const char *
+e_input_base_dir_get(void)
+{
+   return e_input->input_base_dir;
+}
+
 EINTERN int
 e_input_init(Ecore_Evas *ee)
 {
@@ -57,6 +63,9 @@ e_input_init(Ecore_Evas *ee)
         goto log_err;
      }
 
+   // TODO : make this variable configurable e.g. e.cfg
+   e_input->input_base_dir = eina_stringshare_add("/dev/input");
+
    dev = e_input_device_open();
 
    if (!dev)
@@ -93,6 +102,11 @@ device_create_err:
    e_input_device_close(dev);
 
 log_err:
+   if (e_input->input_base_dir)
+     {
+        eina_stringshare_del(e_input->input_base_dir);
+        e_input->input_base_dir = NULL;
+     }
    ecore_event_evas_shutdown();
 
 ecore_event_evas_err:
@@ -128,6 +142,8 @@ e_input_shutdown(void)
    E_EVENT_INPUT_ENABLED = -1;
    E_EVENT_INPUT_DISABLED = -1;
 
+   if (e_input->input_base_dir)
+     eina_stringshare_del(e_input->input_base_dir);
    e_input_device_close(e_input->dev);
    free(e_input);
 
index 881e85f..e57f6ea 100644 (file)
@@ -58,6 +58,7 @@ struct _E_Input
 {
    Ecore_Window window;
    E_Input_Device *dev;
+   const char *input_base_dir;
 };
 
 struct _E_Input_Device
@@ -75,6 +76,7 @@ struct _E_Input_Device
 
 EINTERN int e_input_init(Ecore_Evas *ee);
 EINTERN int e_input_shutdown(void);
+EINTERN const char *e_input_base_dir_get(void);
 
 EINTERN E_Input_Device *e_input_device_open(void);
 EINTERN Eina_Bool e_input_device_close(E_Input_Device *dev);
index 23c305a..e342a2e 100644 (file)
@@ -57,28 +57,6 @@ _e_input_device_cb_open_restricted(const char *path, int flags, void *data)
 static void
 _e_input_device_cb_close_restricted(int fd, void *data)
 {
-   E_Input_Backend *input;
-   E_Input_Seat *seat;
-   E_Input_Evdev *edev;
-   Eina_List *l, *ll;
-
-   if (!(input = data)) return;
-
-   EINA_LIST_FOREACH(input->dev->seats, l, seat)
-     {
-        EINA_LIST_FOREACH(seat->devices, ll, edev)
-          {
-             if (edev->fd == fd)
-               {
-                  _device_close(edev->path, fd);
-
-                  /* re-initialize fd after closing */
-                  edev->fd = -1;
-                  return;
-               }
-          }
-     }
-
    if (fd >= 0) close(fd);
 }
 
index ed0b934..1919a63 100644 (file)
@@ -47,6 +47,8 @@ _device_calibration_set(E_Input_Evdev *edev)
           }
      }
 
+//LCOV_EXCL_START
+#ifdef _F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
    if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
        (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
      return;
@@ -56,10 +58,11 @@ _device_calibration_set(E_Input_Evdev *edev)
    devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
    if (eina_list_count(devices) < 1) return;
 
+#ifdef _F_E_INPUT_USE_WL_CALIBRATION_
    EINA_LIST_FREE(devices, device)
      {
         vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
-       if ((!vals) ||
+        if ((!vals) ||
             (sscanf(vals, "%f %f %f %f %f %f",
                     &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
           goto cont;
@@ -77,6 +80,9 @@ cont:
         eina_stringshare_del(device);
         continue;
      }
+#endif//_F_E_INPUT_USE_WL_CALIBRATION_
+#endif//_F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
+//LCOV_EXCL_STOP
 }
 
 static void
@@ -951,32 +957,9 @@ _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
 
    edev->seat = seat;
    edev->device = device;
-   edev->path = eina_stringshare_add(libinput_device_get_sysname(device));
+   edev->path = eina_stringshare_printf("%s/%s", e_input_base_dir_get(), libinput_device_get_sysname(device));
    edev->fd = -1;
 
-   if (edev->path)
-     {
-        devices = eeze_udev_find_by_filter("input", NULL, edev->path);
-        if (eina_list_count(devices) >= 1)
-          {
-             Eina_List *l;
-             const char *dev, *name;
-
-             EINA_LIST_FOREACH(devices, l, dev)
-               {
-                  name = eeze_udev_syspath_get_devname(dev);
-                  if (name && strstr(name, edev->path))
-                    {
-                       eina_stringshare_replace(&edev->path, eeze_udev_syspath_get_devpath(dev));
-                       break;
-                    }
-               }
-
-             EINA_LIST_FREE(devices, dev)
-               eina_stringshare_del(dev);
-          }
-     }
-
    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
      {
         edev->caps |= E_INPUT_SEAT_KEYBOARD;