e_input_backend: move the e_input_backend functions to e_input_backend.c 87/314287/3
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 9 Jul 2024 02:06:07 +0000 (11:06 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Wed, 10 Jul 2024 04:30:04 +0000 (04:30 +0000)
EINTERN E_Input_Backend *e_input_backend_create_libinput_udev(void);
EINTERN E_Input_Backend *e_input_backend_create_libinput_path(int ndevices);
EINTERN Eina_Bool        e_input_backend_libinput_context_create(E_Input_Backend *input);

Change-Id: Ie1ce7e014409ef1485a9809871fcc8742587fd3e

src/bin/inputmgr/e_input_backend.c
src/bin/inputmgr/e_input_backend_intern.h
src/bin/inputmgr/e_input_device.c
src/bin/inputmgr/e_input_device_intern.h
src/bin/inputmgr/e_input_evdev_intern.h

index ee388b12237127895010d6b144317dc36f3725f7..dbe6e47761293aa5c9add94afc4b4376d3fb4244 100644 (file)
 #include "e_comp_wl_input_intern.h"
 #include "e_main_intern.h"
 #include "e_comp_input_intern.h"
-#include <libudev.h>
+#include "e_utils_intern.h"
 
+#include <libudev.h>
 #include <glib.h>
 #include <fcntl.h>
-
 #ifdef HAVE_SYSTEMD
 # include <systemd/sd-daemon.h>
 #endif
 
+#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"
+
 typedef struct {
     E_Input_Thread_Safe_Call_Cb safe_call_cb;
     unsigned int data_length;
@@ -1259,3 +1262,525 @@ e_input_backend_thread_safe_call(E_Input_Thread_Safe_Call_Cb cb, void *data, siz
         return;
      }
 }
+
+
+static int
+_device_open_no_pending(const char *device, int flags)
+{
+   int fd = -1;
+   struct stat s;
+
+   fd = open(device, flags | O_CLOEXEC);
+
+   if (fd < 0) return fd;
+   if (fstat(fd, &s) == -1)
+     {
+        close(fd);
+        return -1;
+     }
+
+   return fd;
+}
+
+/* local functions */
+static int
+_e_input_device_cb_open_restricted(const char *path, int flags, void *data)
+{
+   E_Input_Backend *input = (E_Input_Backend *)data;
+   int fd = -1;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, -1);
+
+   /* try to open the device */
+   fd = _device_open_no_pending(path, flags);
+
+   if (fd < 0)
+     {
+        ERR("Could not open device");
+        return -1;
+     }
+
+   return fd;
+}
+
+static void
+_e_input_device_cb_close_restricted(int fd, void *data)
+{
+   if (fd >= 0) close(fd);
+}
+
+const struct libinput_interface _input_interface =
+{
+   _e_input_device_cb_open_restricted,
+   _e_input_device_cb_close_restricted,
+};
+
+static void
+_e_input_backend_input_thread_name_set(void)
+{
+   eina_thread_name_set(eina_thread_self(), "input-device-thread");
+}
+
+static void
+_e_input_backend_libinput_log_handler(struct libinput *libinput EINA_UNUSED,
+                               enum libinput_log_priority priority,
+                               const char *format, va_list args)
+{
+   char buf[1024] = {0,};
+
+   vsnprintf(buf, 1024, format, args);
+   switch (priority)
+     {
+        case LIBINPUT_LOG_PRIORITY_DEBUG:
+           EIDBG("%s", buf);
+           break;
+        case LIBINPUT_LOG_PRIORITY_INFO:
+           EIINF("%s", buf);
+           break;
+        case LIBINPUT_LOG_PRIORITY_ERROR:
+           EIERR("%s", buf);
+           break;
+        default:
+           break;
+     }
+}
+
+static void
+_einput_device_input_thread_udev_backend_heavy(void *data, Ecore_Thread *th, void *msg_data)
+{
+   E_Input_Backend *input = (E_Input_Backend *)data;
+
+   EINA_SAFETY_ON_NULL_RETURN(input);
+   EINA_SAFETY_ON_NULL_RETURN(input->dev);
+   EINA_SAFETY_ON_NULL_RETURN(input->dev->seat);
+
+   /* try to create libinput context */
+   struct udev *udev = udev_new();
+
+   input->libinput =
+     libinput_udev_create_context(&_input_interface, input, udev);
+   udev_unref(udev);
+
+   if (!input->libinput)
+     {
+        free(input);
+
+        ERR("Could not create libinput context: %m");
+        return;
+     }
+
+   _e_input_backend_input_thread_name_set();
+
+   if (input->log_disable)
+     libinput_log_set_handler(input->libinput, NULL);
+   else
+     {
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, _e_input_backend_libinput_log_handler);
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
+     }
+
+   TRACE_INPUT_BEGIN(libinput_udev_assign_seat);
+   /* assign udev seat */
+   if (libinput_udev_assign_seat(input->libinput, input->dev->seat) != 0)
+     {
+        ERR("Failed to assign seat: %m");
+        TRACE_INPUT_END();
+        return;
+     }
+   TRACE_INPUT_END();
+
+   return;
+}
+
+static void
+_einput_device_input_thread_udev_backend_notify(void *data, Ecore_Thread *th, void *msg_data)
+{
+   //TODO : do if there is something to do in main thread
+}
+
+static void
+_einput_device_input_thread_udev_backend_end(void *data, Ecore_Thread *th, void *msg_data)
+{
+   E_Input_Backend *input = (E_Input_Backend *)data;
+   E_Input_Device *dev = NULL;
+
+   EINA_SAFETY_ON_NULL_RETURN(input);
+   EINA_SAFETY_ON_NULL_RETURN(input->dev);
+
+   input->thread = NULL;
+
+   /* enable this input */
+   if (!e_input_backend_enable_input(input))
+     {
+        ERR("Failed to enable input");
+        return;
+     }
+
+   /* append this input */
+   dev = input->dev;
+   dev->inputs = eina_list_append(dev->inputs, input);
+
+   /* process pending events */
+   e_input_backend_events_process(input);
+}
+
+static void
+_einput_device_input_thread_udev_backend_cancel(void *data, Ecore_Thread *th, void *msg_data)
+{
+   E_Input_Backend *input = (E_Input_Backend *)data;
+
+   EINA_SAFETY_ON_NULL_RETURN(input);
+
+   input->thread = NULL;
+}
+
+static Eina_Bool
+_e_input_device_input_thread_init_udev_backend(E_Input_Backend *input)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+
+   input->thread = ecore_thread_feedback_run((Ecore_Thread_Cb)_einput_device_input_thread_udev_backend_heavy,
+                                             (Ecore_Thread_Notify_Cb)_einput_device_input_thread_udev_backend_notify,
+                                             (Ecore_Thread_Cb)_einput_device_input_thread_udev_backend_end,
+                                             (Ecore_Thread_Cb)_einput_device_input_thread_udev_backend_cancel, input, 1);
+   return !!(input->thread);
+}
+
+EINTERN E_Input_Backend *
+e_input_backend_create_libinput_udev()
+{
+   E_Input_Backend *input;
+   char *env = NULL;
+   int buf_size = 0;
+   int res = 0;
+
+   /* try to allocate space for new input structure */
+   if (!(input = calloc(1, sizeof(E_Input_Backend))))
+     {
+        return NULL;
+     }
+
+   input->backend = E_INPUT_LIBINPUT_BACKEND_UDEV;
+   input->log_disable = EINA_FALSE;
+   input->log_use_eina = EINA_FALSE;
+
+   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
+   if ((env) && (atoi(env) == 1))
+     input->log_disable = EINA_TRUE;
+   else
+     {
+        if (env) E_FREE(env);
+
+        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
+        if ((env) && (atoi(env) == 1))
+          input->log_use_eina = EINA_TRUE;
+     }
+   E_FREE(env);
+
+   env = e_util_env_get("UDEV_MONITOR_EVENT_SOURCE");
+
+   if (env)
+     {
+        libinput_udev_set_udev_monitor_event_source(env);
+     }
+   E_FREE(env);
+
+   env = e_util_env_get("UDEV_MONITOR_BUFFER_SIZE");
+
+   if ((env) && (buf_size = atoi(env)))
+     {
+        res = libinput_udev_set_udev_monitor_buffer_size(buf_size);
+        if (res)
+          ERR("Wrong buffer size for udev monitor : %d\n", buf_size);
+     }
+   E_FREE(env);
+
+   if (e_input_thread_mode_get())
+     {
+        e_input_backend_thread_input_backend_set(input);
+        return input;
+     }
+
+   if (e_input_thread_enabled_get())
+     {
+        /* initialize libinput udev backend within an ecore thread */
+        if (!_e_input_device_input_thread_init_udev_backend(input))
+          {
+             ERR("Failed to initialize e_input backend (libinput udev backend) !");
+             goto err;
+        }
+
+        return input;
+     }
+
+   if (!e_input_backend_libinput_context_create(input))
+     goto err;
+
+   /* enable this input */
+   if (!e_input_backend_enable_input(input))
+     {
+        ERR("Failed to enable input");
+        goto err;
+     }
+
+   /* process pending events */
+   e_input_backend_events_process(input);
+
+   return input;
+
+err:
+   if (input->libinput) libinput_unref(input->libinput);
+   free(input);
+
+   return NULL;
+}
+
+static void
+_einput_device_input_thread_path_backend_heavy(void *data, Ecore_Thread *th, void *msg_data)
+{
+   char *env = NULL;
+   struct libinput_device *device;
+   E_Input_Backend *input = (E_Input_Backend *)data;
+
+   EINA_SAFETY_ON_NULL_RETURN(input);
+   EINA_SAFETY_ON_NULL_RETURN(input->dev);
+   EINA_SAFETY_ON_NULL_RETURN(input->dev->seat);
+
+   /* try to create libinput context */
+   input->libinput =
+     libinput_path_create_context(&_input_interface, input);
+   if (!input->libinput)
+     {
+        free(input);
+
+        ERR("Could not create libinput path context: %m");
+        return;
+     }
+
+   _e_input_backend_input_thread_name_set();
+
+   if (input->log_disable)
+     libinput_log_set_handler(input->libinput, NULL);
+   else
+     {
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, _e_input_backend_libinput_log_handler);
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
+     }
+
+   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
+   for (int i = 0; i < input->path_ndevices; i++)
+     {
+        char buf[1024] = "PATH_DEVICE_";
+        eina_convert_itoa(i + 1, buf + 12);
+        env = e_util_env_get(buf);
+
+        if (env)
+          {
+             device = libinput_path_add_device(input->libinput, env);
+             if (!device)
+               ERR("Failed to initialized device %s", env);
+             else
+               INF("libinput_path created input device %s", env);
+             E_FREE(env);
+          }
+     }
+   TRACE_INPUT_END();
+
+   return;
+}
+
+static void
+_einput_device_input_thread_path_backend_notify(void *data, Ecore_Thread *th, void *msg_data)
+{
+   //TODO : do if there is something to do in main thread
+}
+
+static void
+_einput_device_input_thread_path_backend_end(void *data, Ecore_Thread *th, void *msg_data)
+{
+   E_Input_Backend *input = (E_Input_Backend *)data;
+   E_Input_Device *dev = NULL;
+
+   EINA_SAFETY_ON_NULL_RETURN(input);
+   EINA_SAFETY_ON_NULL_RETURN(input->dev);
+
+   input->thread = NULL;
+
+   /* enable this input */
+   if (!e_input_backend_enable_input(input))
+     {
+        ERR("Failed to enable input");
+        return;
+     }
+
+   /* append this input */
+   dev = input->dev;
+   dev->inputs = eina_list_append(dev->inputs, input);
+
+   /* process pending events */
+   e_input_backend_events_process(input);
+}
+
+static void
+_einput_device_input_thread_path_backend_cancel(void *data, Ecore_Thread *th, void *msg_data)
+{
+   E_Input_Backend *input = (E_Input_Backend *)data;
+
+   EINA_SAFETY_ON_NULL_RETURN(input);
+
+   input->thread = NULL;
+}
+
+static Eina_Bool
+_e_input_device_input_thread_init_path_backend(E_Input_Backend *input)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+
+   input->thread = ecore_thread_feedback_run((Ecore_Thread_Cb)_einput_device_input_thread_path_backend_heavy,
+                                             (Ecore_Thread_Notify_Cb)_einput_device_input_thread_path_backend_notify,
+                                             (Ecore_Thread_Cb)_einput_device_input_thread_path_backend_end,
+                                             (Ecore_Thread_Cb)_einput_device_input_thread_path_backend_cancel, input, 1);
+   return !!(input->thread);
+}
+
+EINTERN E_Input_Backend *
+e_input_backend_create_libinput_path(int ndevices)
+{
+   E_Input_Backend *input;
+   struct libinput_device *device;
+   char *env;
+
+   /* try to allocate space for new input structure */
+   if (!(input = calloc(1, sizeof(E_Input_Backend))))
+     {
+        return NULL;
+     }
+
+   input->backend = E_INPUT_LIBINPUT_BACKEND_PATH;
+   input->path_ndevices = ndevices;
+   input->log_disable = EINA_FALSE;
+   input->log_use_eina = EINA_FALSE;
+
+   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
+   if ((env) && (atoi(env) == 1))
+     input->log_disable = EINA_TRUE;
+   else
+     {
+        if (env) E_FREE(env);
+
+        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
+        if ((env) && (atoi(env) == 1))
+          input->log_use_eina = EINA_TRUE;
+     }
+   E_FREE(env);
+
+   if (e_input_thread_enabled_get())
+     {
+        /* initialize libinput path backend within an ecore thread */
+        if (!_e_input_device_input_thread_init_path_backend(input))
+          {
+             ERR("Failed to initialize e_input backend (libinput path backend) !");
+             goto err;
+        }
+
+        return input;
+     }
+
+   /* try to create libinput context */
+   input->libinput =
+     libinput_path_create_context(&_input_interface, input);
+   if (!input->libinput)
+     {
+        ERR("Could not create libinput path context: %m");
+        goto err;
+     }
+
+   if (input->log_disable)
+     libinput_log_set_handler(input->libinput, NULL);
+   else
+     {
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, _e_input_backend_libinput_log_handler);
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
+     }
+
+   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
+   for (int i = 0; i < ndevices; i++)
+     {
+        char buf[1024] = "PATH_DEVICE_";
+        eina_convert_itoa(i + 1, buf + 12);
+        env = e_util_env_get(buf);
+        if (env)
+          {
+             device = libinput_path_add_device(input->libinput, env);
+             if (!device)
+               ERR("Failed to initialized device %s", env);
+             else
+               INF("libinput_path created input device %s", env);
+             E_FREE(env);
+          }
+     }
+   TRACE_INPUT_END();
+
+   /* enable this input */
+   if (!e_input_backend_enable_input(input))
+     {
+        ERR("Failed to enable input");
+        goto err;
+     }
+
+   /* process pending events */
+   e_input_backend_events_process(input);
+
+   return input;
+
+err:
+   if (input->libinput) libinput_unref(input->libinput);
+   free(input);
+
+   return NULL;
+}
+
+EINTERN Eina_Bool
+e_input_backend_libinput_context_create(E_Input_Backend *input)
+{
+   /* try to create libinput context */
+   struct udev *udev = udev_new();
+
+   input->libinput =
+     libinput_udev_create_context(&_input_interface, input, udev);
+   udev_unref(udev);
+
+   if (!input->libinput)
+     {
+        ERR("Could not create libinput context: %m");
+        return EINA_FALSE;
+     }
+
+   if (!input->dev)
+     return EINA_FALSE;
+
+   if (input->log_disable)
+     libinput_log_set_handler(input->libinput, NULL);
+   else
+     {
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, _e_input_backend_libinput_log_handler);
+
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
+     }
+
+   /* assign udev seat */
+   TRACE_INPUT_BEGIN(libinput_udev_assign_seat);
+   if (libinput_udev_assign_seat(input->libinput, input->dev->seat) != 0)
+     {
+        ERR("Failed to assign seat: %m");
+        TRACE_INPUT_END();
+        return EINA_FALSE;
+     }
+   TRACE_INPUT_END();
+
+   return EINA_TRUE;
+}
index d6bbfabe6f76e79cfd80ebdd8bd83617a9971dc4..3181c664e1d88146c7b5bd89d35855667351ecff 100644 (file)
@@ -45,4 +45,8 @@ EINTERN void      e_input_backend_thread_safe_call(E_Input_Thread_Safe_Call_Cb c
 EINTERN void      e_input_backend_events_process(E_Input_Backend *input);
 EINTERN void      e_input_backend_key_event_list_add(Ecore_Event_Key *key);
 
+EINTERN E_Input_Backend *e_input_backend_create_libinput_udev(void);
+EINTERN E_Input_Backend *e_input_backend_create_libinput_path(int ndevices);
+EINTERN Eina_Bool        e_input_backend_libinput_context_create(E_Input_Backend *input);
+
 #endif
index 9e17a07814744d3d31f7243f44047b06636f3ee5..c5652af8b1a150f46625e14469d9a5f72a380173 100644 (file)
@@ -11,9 +11,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#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"
-
 /* e_input_device private variable */
 static Eina_List *einput_devices;
 static E_Input_Device *e_input_device_default = NULL;
@@ -21,57 +18,6 @@ static E_Input_Device *e_input_device_default = NULL;
 struct xkb_keymap *cached_keymap;
 struct xkb_context *cached_context;
 
-static int
-_device_open_no_pending(const char *device, int flags)
-{
-   int fd = -1;
-   struct stat s;
-
-   fd = open(device, flags | O_CLOEXEC);
-
-   if (fd < 0) return fd;
-   if (fstat(fd, &s) == -1)
-     {
-        close(fd);
-        return -1;
-     }
-
-   return fd;
-}
-
-/* local functions */
-static int
-_e_input_device_cb_open_restricted(const char *path, int flags, void *data)
-{
-   E_Input_Backend *input = (E_Input_Backend *)data;
-   int fd = -1;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(input, -1);
-
-   /* try to open the device */
-   fd = _device_open_no_pending(path, flags);
-
-   if (fd < 0)
-     {
-        ERR("Could not open device");
-        return -1;
-     }
-
-   return fd;
-}
-
-static void
-_e_input_device_cb_close_restricted(int fd, void *data)
-{
-   if (fd >= 0) close(fd);
-}
-
-const struct libinput_interface _input_interface =
-{
-   _e_input_device_cb_open_restricted,
-   _e_input_device_cb_close_restricted,
-};
-
 static E_Input_Device *
 _e_input_device_default_get(void)
 {
@@ -723,30 +669,6 @@ e_input_device_touch_transformation_set(E_Input_Device *dev, int offset_x, int o
    return res;
 }
 
-static void
-_libinput_log_handler(struct libinput *libinput EINA_UNUSED,
-                               enum libinput_log_priority priority,
-                               const char *format, va_list args)
-{
-   char buf[1024] = {0,};
-
-   vsnprintf(buf, 1024, format, args);
-   switch (priority)
-     {
-        case LIBINPUT_LOG_PRIORITY_DEBUG:
-           EIDBG("%s", buf);
-           break;
-        case LIBINPUT_LOG_PRIORITY_INFO:
-           EIINF("%s", buf);
-           break;
-        case LIBINPUT_LOG_PRIORITY_ERROR:
-           EIERR("%s", buf);
-           break;
-        default:
-           break;
-     }
-}
-
 EINTERN Eina_Bool
 e_input_device_input_backend_create(E_Input_Device *dev, E_Input_Libinput_Backend backend)
 {
@@ -795,453 +717,6 @@ e_input_device_input_backend_create(E_Input_Device *dev, E_Input_Libinput_Backen
    return EINA_TRUE;
 }
 
-static void
-_e_input_device_input_thread_name_set(void)
-{
-   eina_thread_name_set(eina_thread_self(), "input-device-thread");
-}
-
-static void
-_einput_device_input_thread_udev_backend_heavy(void *data, Ecore_Thread *th, void *msg_data)
-{
-   E_Input_Backend *input = (E_Input_Backend *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN(input);
-   EINA_SAFETY_ON_NULL_RETURN(input->dev);
-   EINA_SAFETY_ON_NULL_RETURN(input->dev->seat);
-
-   /* try to create libinput context */
-   struct udev *udev = udev_new();
-
-   input->libinput =
-     libinput_udev_create_context(&_input_interface, input, udev);
-   udev_unref(udev);
-
-   if (!input->libinput)
-     {
-        free(input);
-
-        ERR("Could not create libinput context: %m");
-        return;
-     }
-
-   _e_input_device_input_thread_name_set();
-
-   if (input->log_disable)
-     libinput_log_set_handler(input->libinput, NULL);
-   else
-     {
-        if (input->log_use_eina)
-          libinput_log_set_handler(input->libinput, _libinput_log_handler);
-        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
-     }
-
-   TRACE_INPUT_BEGIN(libinput_udev_assign_seat);
-   /* assign udev seat */
-   if (libinput_udev_assign_seat(input->libinput, input->dev->seat) != 0)
-     {
-        ERR("Failed to assign seat: %m");
-        TRACE_INPUT_END();
-        return;
-     }
-   TRACE_INPUT_END();
-
-   return;
-}
-
-static void
-_einput_device_input_thread_udev_backend_notify(void *data, Ecore_Thread *th, void *msg_data)
-{
-   //TODO : do if there is something to do in main thread
-}
-
-static void
-_einput_device_input_thread_udev_backend_end(void *data, Ecore_Thread *th, void *msg_data)
-{
-   E_Input_Backend *input = (E_Input_Backend *)data;
-   E_Input_Device *dev = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN(input);
-   EINA_SAFETY_ON_NULL_RETURN(input->dev);
-
-   input->thread = NULL;
-
-   /* enable this input */
-   if (!e_input_backend_enable_input(input))
-     {
-        ERR("Failed to enable input");
-        return;
-     }
-
-   /* append this input */
-   dev = input->dev;
-   dev->inputs = eina_list_append(dev->inputs, input);
-
-   /* process pending events */
-   e_input_backend_events_process(input);
-}
-
-static void
-_einput_device_input_thread_udev_backend_cancel(void *data, Ecore_Thread *th, void *msg_data)
-{
-   E_Input_Backend *input = (E_Input_Backend *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN(input);
-
-   input->thread = NULL;
-}
-
-static Eina_Bool
-_e_input_device_input_thread_init_udev_backend(E_Input_Backend *input)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
-
-   input->thread = ecore_thread_feedback_run((Ecore_Thread_Cb)_einput_device_input_thread_udev_backend_heavy,
-                                             (Ecore_Thread_Notify_Cb)_einput_device_input_thread_udev_backend_notify,
-                                             (Ecore_Thread_Cb)_einput_device_input_thread_udev_backend_end,
-                                             (Ecore_Thread_Cb)_einput_device_input_thread_udev_backend_cancel, input, 1);
-   return !!(input->thread);
-}
-
-/* public functions */
-EINTERN E_Input_Backend *
-e_input_backend_create_libinput_udev()
-{
-   E_Input_Backend *input;
-   char *env = NULL;
-   int buf_size = 0;
-   int res = 0;
-
-   /* try to allocate space for new input structure */
-   if (!(input = calloc(1, sizeof(E_Input_Backend))))
-     {
-        return NULL;
-     }
-
-   input->backend = E_INPUT_LIBINPUT_BACKEND_UDEV;
-   input->log_disable = EINA_FALSE;
-   input->log_use_eina = EINA_FALSE;
-
-   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
-   if ((env) && (atoi(env) == 1))
-     input->log_disable = EINA_TRUE;
-   else
-     {
-        if (env) E_FREE(env);
-
-        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
-        if ((env) && (atoi(env) == 1))
-          input->log_use_eina = EINA_TRUE;
-     }
-   E_FREE(env);
-
-   env = e_util_env_get("UDEV_MONITOR_EVENT_SOURCE");
-
-   if (env)
-     {
-        libinput_udev_set_udev_monitor_event_source(env);
-     }
-   E_FREE(env);
-
-   env = e_util_env_get("UDEV_MONITOR_BUFFER_SIZE");
-
-   if ((env) && (buf_size = atoi(env)))
-     {
-        res = libinput_udev_set_udev_monitor_buffer_size(buf_size);
-        if (res)
-          ERR("Wrong buffer size for udev monitor : %d\n", buf_size);
-     }
-   E_FREE(env);
-
-   if (e_input_thread_mode_get())
-     {
-        e_input_backend_thread_input_backend_set(input);
-        return input;
-     }
-
-   if (e_input_thread_enabled_get())
-     {
-        /* initialize libinput udev backend within an ecore thread */
-        if (!_e_input_device_input_thread_init_udev_backend(input))
-          {
-             ERR("Failed to initialize e_input backend (libinput udev backend) !");
-             goto err;
-        }
-
-        return input;
-     }
-
-   if (!e_input_backend_libinput_context_create(input))
-     goto err;
-
-   /* enable this input */
-   if (!e_input_backend_enable_input(input))
-     {
-        ERR("Failed to enable input");
-        goto err;
-     }
-
-   /* process pending events */
-   e_input_backend_events_process(input);
-
-   return input;
-
-err:
-   if (input->libinput) libinput_unref(input->libinput);
-   free(input);
-
-   return NULL;
-}
-
-EINTERN Eina_Bool
-e_input_backend_libinput_context_create(E_Input_Backend *input)
-{
-   /* try to create libinput context */
-   struct udev *udev = udev_new();
-
-   input->libinput =
-     libinput_udev_create_context(&_input_interface, input, udev);
-   udev_unref(udev);
-
-   if (!input->libinput)
-     {
-        ERR("Could not create libinput context: %m");
-        return EINA_FALSE;
-     }
-
-   if (!input->dev)
-     return EINA_FALSE;
-
-   if (input->log_disable)
-     libinput_log_set_handler(input->libinput, NULL);
-   else
-     {
-        if (input->log_use_eina)
-          libinput_log_set_handler(input->libinput, _libinput_log_handler);
-
-        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
-     }
-
-   /* assign udev seat */
-   TRACE_INPUT_BEGIN(libinput_udev_assign_seat);
-   if (libinput_udev_assign_seat(input->libinput, input->dev->seat) != 0)
-     {
-        ERR("Failed to assign seat: %m");
-        TRACE_INPUT_END();
-        return EINA_FALSE;
-     }
-   TRACE_INPUT_END();
-
-   return EINA_TRUE;
-}
-
-static void
-_einput_device_input_thread_path_backend_heavy(void *data, Ecore_Thread *th, void *msg_data)
-{
-   char *env = NULL;
-   struct libinput_device *device;
-   E_Input_Backend *input = (E_Input_Backend *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN(input);
-   EINA_SAFETY_ON_NULL_RETURN(input->dev);
-   EINA_SAFETY_ON_NULL_RETURN(input->dev->seat);
-
-   /* try to create libinput context */
-   input->libinput =
-     libinput_path_create_context(&_input_interface, input);
-   if (!input->libinput)
-     {
-        free(input);
-
-        ERR("Could not create libinput path context: %m");
-        return;
-     }
-
-   _e_input_device_input_thread_name_set();
-
-   if (input->log_disable)
-     libinput_log_set_handler(input->libinput, NULL);
-   else
-     {
-        if (input->log_use_eina)
-          libinput_log_set_handler(input->libinput, _libinput_log_handler);
-        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
-     }
-
-   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
-   for (int i = 0; i < input->path_ndevices; i++)
-     {
-        char buf[1024] = "PATH_DEVICE_";
-        eina_convert_itoa(i + 1, buf + 12);
-        env = e_util_env_get(buf);
-
-        if (env)
-          {
-             device = libinput_path_add_device(input->libinput, env);
-             if (!device)
-               ERR("Failed to initialized device %s", env);
-             else
-               INF("libinput_path created input device %s", env);
-             E_FREE(env);
-          }
-     }
-   TRACE_INPUT_END();
-
-   return;
-}
-
-static void
-_einput_device_input_thread_path_backend_notify(void *data, Ecore_Thread *th, void *msg_data)
-{
-   //TODO : do if there is something to do in main thread
-}
-
-static void
-_einput_device_input_thread_path_backend_end(void *data, Ecore_Thread *th, void *msg_data)
-{
-   E_Input_Backend *input = (E_Input_Backend *)data;
-   E_Input_Device *dev = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN(input);
-   EINA_SAFETY_ON_NULL_RETURN(input->dev);
-
-   input->thread = NULL;
-
-   /* enable this input */
-   if (!e_input_backend_enable_input(input))
-     {
-        ERR("Failed to enable input");
-        return;
-     }
-
-   /* append this input */
-   dev = input->dev;
-   dev->inputs = eina_list_append(dev->inputs, input);
-
-   /* process pending events */
-   e_input_backend_events_process(input);
-}
-
-static void
-_einput_device_input_thread_path_backend_cancel(void *data, Ecore_Thread *th, void *msg_data)
-{
-   E_Input_Backend *input = (E_Input_Backend *)data;
-
-   EINA_SAFETY_ON_NULL_RETURN(input);
-
-   input->thread = NULL;
-}
-
-static Eina_Bool
-_e_input_device_input_thread_init_path_backend(E_Input_Backend *input)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
-
-   input->thread = ecore_thread_feedback_run((Ecore_Thread_Cb)_einput_device_input_thread_path_backend_heavy,
-                                             (Ecore_Thread_Notify_Cb)_einput_device_input_thread_path_backend_notify,
-                                             (Ecore_Thread_Cb)_einput_device_input_thread_path_backend_end,
-                                             (Ecore_Thread_Cb)_einput_device_input_thread_path_backend_cancel, input, 1);
-   return !!(input->thread);
-}
-
-EINTERN E_Input_Backend *
-e_input_backend_create_libinput_path(int ndevices)
-{
-   E_Input_Backend *input;
-   struct libinput_device *device;
-   char *env;
-
-   /* try to allocate space for new input structure */
-   if (!(input = calloc(1, sizeof(E_Input_Backend))))
-     {
-        return NULL;
-     }
-
-   input->backend = E_INPUT_LIBINPUT_BACKEND_PATH;
-   input->path_ndevices = ndevices;
-   input->log_disable = EINA_FALSE;
-   input->log_use_eina = EINA_FALSE;
-
-   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
-   if ((env) && (atoi(env) == 1))
-     input->log_disable = EINA_TRUE;
-   else
-     {
-        if (env) E_FREE(env);
-
-        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
-        if ((env) && (atoi(env) == 1))
-          input->log_use_eina = EINA_TRUE;
-     }
-   E_FREE(env);
-
-   if (e_input_thread_enabled_get())
-     {
-        /* initialize libinput path backend within an ecore thread */
-        if (!_e_input_device_input_thread_init_path_backend(input))
-          {
-             ERR("Failed to initialize e_input backend (libinput path backend) !");
-             goto err;
-        }
-
-        return input;
-     }
-
-   /* try to create libinput context */
-   input->libinput =
-     libinput_path_create_context(&_input_interface, input);
-   if (!input->libinput)
-     {
-        ERR("Could not create libinput path context: %m");
-        goto err;
-     }
-
-   if (input->log_disable)
-     libinput_log_set_handler(input->libinput, NULL);
-   else
-     {
-        if (input->log_use_eina)
-          libinput_log_set_handler(input->libinput, _libinput_log_handler);
-        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
-     }
-
-   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
-   for (int i = 0; i < ndevices; i++)
-     {
-        char buf[1024] = "PATH_DEVICE_";
-        eina_convert_itoa(i + 1, buf + 12);
-        env = e_util_env_get(buf);
-        if (env)
-          {
-             device = libinput_path_add_device(input->libinput, env);
-             if (!device)
-               ERR("Failed to initialized device %s", env);
-             else
-               INF("libinput_path created input device %s", env);
-             E_FREE(env);
-          }
-     }
-   TRACE_INPUT_END();
-
-   /* enable this input */
-   if (!e_input_backend_enable_input(input))
-     {
-        ERR("Failed to enable input");
-        goto err;
-     }
-
-   /* process pending events */
-   e_input_backend_events_process(input);
-
-   return input;
-
-err:
-   if (input->libinput) libinput_unref(input->libinput);
-   free(input);
-
-   return NULL;
-}
-
 void
 e_input_device_output_changed(E_Input_Device *dev)
 {
index 27abdf3a727255ff1fcfa124623599be56081723..35f955f004551883eb1aa431900476f8d4791ff9 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "e_intern.h"
 #include "e_input_intern.h"
-#include "e_input_backend_intern.h"
 
 struct _E_Input_Device
 {
@@ -40,8 +39,6 @@ EINTERN void            e_input_device_keyboard_cached_keymap_set(struct xkb_key
 EINTERN Eina_Bool       e_input_device_keyboard_remap_set(E_Input_Device *dev, int *from_keys, int *to_keys, int num);
 
 EINTERN Eina_Bool       e_input_device_input_backend_create(E_Input_Device *dev, E_Input_Libinput_Backend backend);
-EINTERN E_Input_Backend *e_input_backend_create_libinput_udev(void);
-EINTERN E_Input_Backend *e_input_backend_create_libinput_path(int ndevices);
 EINTERN Eina_Bool       e_input_device_libinput_log_level_set(E_Input_Device *dev, unsigned int level);
 
 EINTERN void            e_input_device_pointer_xy_get(E_Input_Device *dev, int *x, int *y);
index 5e72e58181babeb9ff32901405da6ac77be12fa2..cf980d6e763e208d01a5be41e58e4f56e9843d1d 100644 (file)
@@ -142,6 +142,4 @@ EINTERN unsigned int  e_input_evdev_touch_pressed_get(E_Input_Evdev *edev);
 EINTERN const char   *e_input_evdev_seatname_get(E_Input_Evdev *evdev);
 EINTERN Eina_Bool     e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname);
 
-EINTERN Eina_Bool e_input_backend_libinput_context_create(E_Input_Backend *input);
-
 #endif