input & device : add virtual mouse/key device creation using configuration 59/138459/7
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 12 Jul 2017 08:06:52 +0000 (17:06 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 13 Jul 2017 03:00:31 +0000 (12:00 +0900)
Change-Id: I2d95b15ec8a8ceeb3e10fcdc8911b13b0724b315
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/e_devicemgr_conf.c
src/e_devicemgr_device.c
src/e_devicemgr_device.h
src/e_devicemgr_input.c
src/e_devicemgr_privates.h

index 05cb1c8dae2b4bc8338abe7d4b322f4332a024b9..a6bf8beea7ecfcc65dc8d5319e1a505771edc50f 100644 (file)
@@ -20,6 +20,8 @@ e_devicemgr_conf_init(E_Devicemgr_Config_Data *dconfig)
 #define T E_Devicemgr_Conf_Edd
 #define D dconfig->conf_edd
    E_CONFIG_VAL(D, T, input.button_remap_enable, CHAR);
+   E_CONFIG_VAL(D, T, input.virtual_key_device_enable, CHAR);
+   E_CONFIG_VAL(D, T, input.virtual_mouse_device_enable, CHAR);
    E_CONFIG_VAL(D, T, input.back_keycode, INT);
 
 #undef T
index 3ff88e25b0d133ad94bde06cb0e57d1071dd9283..3751b0e67635d800c5272c0b7aae345336da1902 100644 (file)
@@ -840,7 +840,7 @@ _e_input_devmgr_inputgen_generator_remove_device(e_devicemgr_inputgen_device_dat
         return;
      }
 
-   close(device->uinp_fd);
+   e_devicemgr_destroy_virtual_device(device->uinp_fd);
    device->uinp_fd = -1;
    eina_stringshare_del(device->identifier);
    device->identifier = NULL;
@@ -1060,9 +1060,9 @@ _e_input_devmgr_inputgen_client_remove(struct wl_client *client, unsigned int cl
 }
 
 static int
-_e_input_devmgr_create_keyboard_device(struct wl_client *client, struct uinput_user_dev *uinp)
+_e_input_devmgr_create_keyboard_device(struct wl_client *client, const char *device_name)
 {
-   int uinp_fd = -1, ret = -1;
+   int uinp_fd = -1;
    Eina_List *l, *l2;
    e_devicemgr_inputgen_client_data *cdata;
    e_devicemgr_inputgen_device_data *ddata, *device = NULL;
@@ -1070,7 +1070,7 @@ _e_input_devmgr_create_keyboard_device(struct wl_client *client, struct uinput_u
 
    EINA_LIST_FOREACH(input_devmgr_data->inputgen.kbd_list, l, ddata)
      {
-        if (!strncmp(ddata->name, uinp->name, UINPUT_MAX_NAME_SIZE))
+        if (!strncmp(ddata->name, device_name, UINPUT_MAX_NAME_SIZE))
           {
              EINA_LIST_FOREACH(ddata->clients, l2, cdata)
                {
@@ -1091,7 +1091,7 @@ _e_input_devmgr_create_keyboard_device(struct wl_client *client, struct uinput_u
      {
         device = E_NEW(e_devicemgr_inputgen_device_data, 1);
         if (!device) return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
-        strncpy(device->name, uinp->name, UINPUT_MAX_NAME_SIZE - 1);
+        strncpy(device->name, device_name, UINPUT_MAX_NAME_SIZE - 1);
      }
 
    cdata = NULL;
@@ -1110,31 +1110,10 @@ _e_input_devmgr_create_keyboard_device(struct wl_client *client, struct uinput_u
    if (exist_device_flag)
      return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
-   uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
-   if ( uinp_fd < 0)
-     {
-        DMWRN("Failed to open /dev/uinput: (%d)\n", uinp_fd);
-        goto fail_create_device;
-     }
-
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
+   uinp_fd = e_devicemgr_create_virtual_device(E_DEVICEMGR_DEVICE_TYPE_KEY, device_name);
 
-   ioctl(uinp_fd, UI_SET_MSCBIT, MSC_SCAN);
-   ioctl(uinp_fd, UI_SET_KEYBIT, KEY_ESC);
-
-   ret = write(uinp_fd, uinp, sizeof(struct uinput_user_dev));
-   if (ret < 0)
-     {
-        DMWRN("keyboard Failed to write UINPUT device\n");
-        goto fail_create_device;
-     }
-   if (ioctl(uinp_fd, UI_DEV_CREATE))
-     {
-        DMWRN("keyboard Unable to create UINPUT device\n");
-        goto fail_create_device;
-     }
+   if (uinp_fd < 0)
+    goto fail_create_device;
 
    device->uinp_fd = uinp_fd;
    input_devmgr_data->inputgen.kbd_list =
@@ -1143,19 +1122,13 @@ _e_input_devmgr_create_keyboard_device(struct wl_client *client, struct uinput_u
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
 fail_create_device:
-   if (uinp_fd >= 0) close(uinp_fd);
-   if (!exist_device_flag && device)
-     {
-        E_FREE(device);
-     }
-   if (cdata) E_FREE(cdata);
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
 }
 
 static int
-_e_input_devmgr_create_mouse_device(struct wl_client *client, struct uinput_user_dev *uinp)
+_e_input_devmgr_create_mouse_device(struct wl_client *client, const char *device_name)
 {
-   int uinp_fd = -1, ret = -1;
+   int uinp_fd = -1;
    Eina_List *l, *l2;
    e_devicemgr_inputgen_client_data *cdata;
    e_devicemgr_inputgen_device_data *ddata, *device = NULL;
@@ -1163,7 +1136,7 @@ _e_input_devmgr_create_mouse_device(struct wl_client *client, struct uinput_user
 
    EINA_LIST_FOREACH(input_devmgr_data->inputgen.ptr_list, l, ddata)
      {
-        if (!strncmp(ddata->name, uinp->name, UINPUT_MAX_NAME_SIZE))
+        if (!strncmp(ddata->name, device_name, UINPUT_MAX_NAME_SIZE))
           {
              EINA_LIST_FOREACH(ddata->clients, l2, cdata)
                {
@@ -1184,7 +1157,7 @@ _e_input_devmgr_create_mouse_device(struct wl_client *client, struct uinput_user
      {
         device = E_NEW(e_devicemgr_inputgen_device_data, 1);
         if (!device) return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
-        strncpy(device->name, uinp->name, UINPUT_MAX_NAME_SIZE - 1);
+        strncpy(device->name, device_name, UINPUT_MAX_NAME_SIZE - 1);
      }
 
    cdata = NULL;
@@ -1203,38 +1176,10 @@ _e_input_devmgr_create_mouse_device(struct wl_client *client, struct uinput_user
    if (exist_device_flag)
      return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
-   uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
-   if ( uinp_fd < 0)
-     {
-        DMWRN("Failed to open /dev/uinput: (%d)\n", uinp_fd);
-        goto fail_create_device;
-     }
-
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_REL);
-
-   ioctl(uinp_fd, UI_SET_MSCBIT, MSC_SCAN);
-
-   ioctl(uinp_fd, UI_SET_KEYBIT, BTN_LEFT);
-   ioctl(uinp_fd, UI_SET_RELBIT, BTN_RIGHT);
-   ioctl(uinp_fd, UI_SET_RELBIT, BTN_MIDDLE);
-   ioctl(uinp_fd, UI_SET_RELBIT, REL_X);
-   ioctl(uinp_fd, UI_SET_RELBIT, REL_Y);
-   ioctl(uinp_fd, UI_SET_RELBIT, REL_WHEEL);
+   uinp_fd = e_devicemgr_create_virtual_device(E_DEVICEMGR_DEVICE_TYPE_MOUSE, device_name);
 
-   ret = write(uinp_fd, uinp, sizeof(struct uinput_user_dev));
-   if (ret < 0)
-     {
-        DMWRN("mouse Failed to write UINPUT device\n");
-        goto fail_create_device;
-     }
-   if (ioctl(uinp_fd, UI_DEV_CREATE))
-     {
-        DMWRN("mouse Unable to create UINPUT device\n");
-        goto fail_create_device;
-     }
+   if (uinp_fd < 0)
+     goto fail_create_device;
 
    device->uinp_fd = uinp_fd;
    input_devmgr_data->inputgen.ptr_list =
@@ -1243,19 +1188,13 @@ _e_input_devmgr_create_mouse_device(struct wl_client *client, struct uinput_user
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
 fail_create_device:
-   if (uinp_fd >= 0) close(uinp_fd);
-   if (!exist_device_flag && device)
-     {
-        E_FREE(device);
-     }
-   if (cdata) E_FREE(cdata);
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
 }
 
 static int
-_e_input_devmgr_create_touch_device(struct wl_client *client, struct uinput_user_dev *uinp)
+_e_input_devmgr_create_touch_device(struct wl_client *client, const char *device_name)
 {
-   int uinp_fd = -1, ret = -1;
+   int uinp_fd = -1;
    Eina_List *l, *l2;
    e_devicemgr_inputgen_client_data *cdata;
    e_devicemgr_inputgen_device_data *ddata, *device = NULL;
@@ -1263,7 +1202,7 @@ _e_input_devmgr_create_touch_device(struct wl_client *client, struct uinput_user
 
    EINA_LIST_FOREACH(input_devmgr_data->inputgen.touch_list, l, ddata)
      {
-        if (!strncmp(ddata->name, uinp->name, UINPUT_MAX_NAME_SIZE))
+        if (!strncmp(ddata->name, device_name, UINPUT_MAX_NAME_SIZE))
           {
              EINA_LIST_FOREACH(ddata->clients, l2, cdata)
                {
@@ -1284,7 +1223,7 @@ _e_input_devmgr_create_touch_device(struct wl_client *client, struct uinput_user
      {
         device = E_NEW(e_devicemgr_inputgen_device_data, 1);
         if (!device) return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
-        strncpy(device->name, uinp->name, UINPUT_MAX_NAME_SIZE - 1);
+        strncpy(device->name, device_name, UINPUT_MAX_NAME_SIZE - 1);
      }
 
    cdata = NULL;
@@ -1303,42 +1242,10 @@ _e_input_devmgr_create_touch_device(struct wl_client *client, struct uinput_user
    if (exist_device_flag)
      return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
-   uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
-   if ( uinp_fd < 0)
-     {
-        DMWRN("Failed to open /dev/uinput: (%d)\n", uinp_fd);
-        goto fail_create_device;
-     }
-
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
-   ioctl(uinp_fd, UI_SET_EVBIT, EV_ABS);
-
-   ioctl(uinp_fd, UI_SET_KEYBIT, BTN_TOUCH);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_X);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_Y);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_SLOT);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MAJOR);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MINOR);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_WIDTH_MAJOR);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
-   ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);
+   uinp_fd = e_devicemgr_create_virtual_device(E_DEVICEMGR_DEVICE_TYPE_TOUCH, device_name);
 
-   ioctl(uinp_fd, UI_SET_MSCBIT, MSC_SCAN);
-
-   ret = write(uinp_fd, uinp, sizeof(struct uinput_user_dev));
-   if (ret < 0)
-     {
-        DMWRN("touch Failed to write UINPUT device\n");
-        goto fail_create_device;
-     }
-   if (ioctl(uinp_fd, UI_DEV_CREATE))
-     {
-        DMWRN("touch Unable to create UINPUT device\n");
-        goto fail_create_device;
-     }
+   if (uinp_fd < 0)
+     goto fail_create_device;
 
    device->uinp_fd = uinp_fd;
    input_devmgr_data->inputgen.touch_list =
@@ -1347,19 +1254,12 @@ _e_input_devmgr_create_touch_device(struct wl_client *client, struct uinput_user
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
 fail_create_device:
-   if (uinp_fd >= 0) close(uinp_fd);
-   if (!exist_device_flag && device)
-     {
-        E_FREE(device);
-     }
-   if (cdata) E_FREE(cdata);
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
 }
 
 static void
 _e_input_devmgr_cb_init_generator(struct wl_client *client, struct wl_resource *resource, uint32_t clas)
 {
-   struct uinput_user_dev uinp;
    int ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
 #ifdef ENABLE_CYNARA
@@ -1371,17 +1271,12 @@ _e_input_devmgr_cb_init_generator(struct wl_client *client, struct wl_resource *
      }
 #endif
 
-   memset(&uinp, 0, sizeof(uinp));
-   strncpy(uinp.name, "Input Generator", UINPUT_MAX_NAME_SIZE - 1);
-   uinp.id.version = 4;
-   uinp.id.bustype = BUS_VIRTUAL;
-
    if (clas & TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD)
-     ret = _e_input_devmgr_create_keyboard_device(client, &uinp);
+     ret = _e_input_devmgr_create_keyboard_device(client, INPUT_GENERATOR_DEVICE);
    if (clas & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE)
-     ret = _e_input_devmgr_create_mouse_device(client, &uinp);
+     ret = _e_input_devmgr_create_mouse_device(client, INPUT_GENERATOR_DEVICE);
    if (clas & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN)
-     ret = _e_input_devmgr_create_touch_device(client, &uinp);
+     ret = _e_input_devmgr_create_touch_device(client, INPUT_GENERATOR_DEVICE);
 
    if (ret == TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
      {
@@ -1396,7 +1291,6 @@ finish:
 static void
 _e_input_devmgr_cb_init_generator_with_name(struct wl_client *client, struct wl_resource *resource, uint32_t clas, const char *name)
 {
-   struct uinput_user_dev uinp;
    int ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 
 #ifdef ENABLE_CYNARA
@@ -1408,17 +1302,12 @@ _e_input_devmgr_cb_init_generator_with_name(struct wl_client *client, struct wl_
      }
 #endif
 
-   memset(&uinp, 0, sizeof(uinp));
-   strncpy(uinp.name, name, UINPUT_MAX_NAME_SIZE - 1);
-   uinp.id.version = 4;
-   uinp.id.bustype = BUS_VIRTUAL;
-
    if (clas & TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD)
-     ret = _e_input_devmgr_create_keyboard_device(client, &uinp);
+     ret = _e_input_devmgr_create_keyboard_device(client, name);
    if (clas & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE)
-     ret = _e_input_devmgr_create_mouse_device(client, &uinp);
+     ret = _e_input_devmgr_create_mouse_device(client, name);
    if (clas & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN)
-     ret = _e_input_devmgr_create_touch_device(client, &uinp);
+     ret = _e_input_devmgr_create_touch_device(client, name);
 
    if (ret == TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
      {
@@ -2027,6 +1916,104 @@ _e_devicemgr_device_mgr_cb_bind(struct wl_client *client, void *data, uint32_t v
      }
 }
 
+void
+e_devicemgr_destroy_virtual_device(int uinp_fd)
+{
+   ioctl(uinp_fd, UI_DEV_DESTROY, NULL);
+   close(uinp_fd);
+}
+
+int
+e_devicemgr_create_virtual_device(E_Devicemgr_Device_Type type, const char *name)
+{
+   int ret;
+   int uinp_fd = -1;
+   struct uinput_user_dev uinp;
+
+   memset(&uinp, 0, sizeof(uinp));
+   strncpy(uinp.name, name, UINPUT_MAX_NAME_SIZE - 1);
+   uinp.id.version = 4;
+   uinp.id.bustype = BUS_VIRTUAL;
+
+   uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
+   if ( uinp_fd < 0)
+     {
+        DMWRN("Failed to open /dev/uinput: (%d)\n", uinp_fd);
+        goto fail_create_device;
+     }
+
+   if (E_DEVICEMGR_DEVICE_TYPE_KEY == type)
+     {
+       /* key device setup */
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
+       ioctl(uinp_fd, UI_SET_MSCBIT, MSC_SCAN);
+       ioctl(uinp_fd, UI_SET_KEYBIT, KEY_ESC);
+     }
+   else if (E_DEVICEMGR_DEVICE_TYPE_MOUSE == type)
+     {
+       /* mouse device setup */
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_REL);
+       ioctl(uinp_fd, UI_SET_MSCBIT, MSC_SCAN);
+       ioctl(uinp_fd, UI_SET_KEYBIT, BTN_LEFT);
+       ioctl(uinp_fd, UI_SET_RELBIT, BTN_RIGHT);
+       ioctl(uinp_fd, UI_SET_RELBIT, BTN_MIDDLE);
+       ioctl(uinp_fd, UI_SET_RELBIT, REL_X);
+       ioctl(uinp_fd, UI_SET_RELBIT, REL_Y);
+       ioctl(uinp_fd, UI_SET_RELBIT, REL_WHEEL);
+     }
+   else if (E_DEVICEMGR_DEVICE_TYPE_TOUCH == type)
+     {
+       /* touch device setup */
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
+       ioctl(uinp_fd, UI_SET_EVBIT, EV_ABS);
+
+       ioctl(uinp_fd, UI_SET_KEYBIT, BTN_TOUCH);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_X);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_Y);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_SLOT);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MAJOR);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MINOR);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_WIDTH_MAJOR);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
+       ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);
+       ioctl(uinp_fd, UI_SET_MSCBIT, MSC_SCAN);
+     }
+   else
+     goto fail_create_device;
+
+   ret = write(uinp_fd, &uinp, sizeof(struct uinput_user_dev));
+
+   if (ret < 0)
+     {
+        DMWRN("Failed to write to uinput fd ! (fd:%d, type:%d, name:%s)\n", uinp_fd, type, name);
+        goto fail_create_device;
+     }
+
+   if (ioctl(uinp_fd, UI_DEV_CREATE))
+     {
+       DMWRN("Failed to create a virtual device ! (type:%d, name:%s)\n", type, name);
+       goto fail_create_device;
+     }
+
+   return uinp_fd;
+
+fail_create_device:
+
+   if (uinp_fd >= 0)
+     close(uinp_fd);
+
+   return -1;
+}
+
+
 int
 e_devicemgr_device_init(void)
 {
index 3ad941dd960d3a8db01c248a2168d211a5eda02f..b496299f6789891f19d5567e222c61f173026a3f 100644 (file)
@@ -38,6 +38,8 @@
 #include <cynara-creds-socket.h>
 #endif
 
+#define INPUT_GENERATOR_DEVICE "Input Generator"
+
 typedef struct _e_devicemgr_input_devmgr_data e_devicemgr_input_devmgr_data;
 typedef struct _e_devicemgr_input_device_user_data e_devicemgr_input_device_user_data;
 typedef struct _e_devicemgr_inputgen_client_data e_devicemgr_inputgen_client_data;
@@ -110,9 +112,20 @@ struct _e_devicemgr_input_devmgr_data
    Eina_List *watched_clients;
 };
 
+typedef enum _E_Devicemgr_Device_Type
+{
+   E_DEVICEMGR_DEVICE_TYPE_NONE,
+   E_DEVICEMGR_DEVICE_TYPE_KEY,
+   E_DEVICEMGR_DEVICE_TYPE_MOUSE,
+   E_DEVICEMGR_DEVICE_TYPE_TOUCH,
+} E_Devicemgr_Device_Type;
+
 int e_devicemgr_device_init(void);
 void e_devicemgr_device_fini(void);
 
+void e_devicemgr_destroy_virtual_device(int uinp_fd);
+int e_devicemgr_create_virtual_device(E_Devicemgr_Device_Type type, const char *name);
+
 Eina_Bool e_devicemgr_block_check_keyboard(int type, void *event);
 Eina_Bool e_devicemgr_block_check_pointer(int type, void *event);
 Eina_Bool e_devicemgr_is_detent_device(const char *name);
index 03cf1f7302ac5a91e56e04802835c6b6fedf6248..3792fba2c88dcef4df387895bfd9bdf075a2d307 100644 (file)
@@ -5,6 +5,8 @@
 #include "e_devicemgr_device.h"
 
 static Ecore_Event_Filter *ev_filter = NULL;
+static int virtual_key_device_fd = -1;
+static int virtual_mouse_device_fd = -1;
 
 extern E_Devicemgr_Config_Data *dconfig;
 
@@ -111,7 +113,6 @@ _e_devicemgr_event_filter(void *data, void *loop_data EINA_UNUSED, int type, voi
    return ECORE_CALLBACK_PASS_ON;
 }
 
-
 int
 e_devicemgr_input_init(void)
 {
@@ -120,6 +121,26 @@ e_devicemgr_input_init(void)
 
    DMDBG("input.button_remap_enable: %d\n", dconfig->conf->input.button_remap_enable);
 
+   if (dconfig->conf->input.virtual_key_device_enable)
+     {
+        virtual_key_device_fd = e_devicemgr_create_virtual_device(E_DEVICEMGR_DEVICE_TYPE_KEY, "Virtual Key Device");
+
+        if (virtual_key_device_fd >= 0)
+          DMDBG("input.virtual_key_device_enable: 1, device fd : %d\n", virtual_key_device_fd);
+        else
+          DMDBG("input.virtual_key_device_enable: 1, but failed to create device !\n");
+     }
+
+   if (dconfig->conf->input.virtual_mouse_device_enable)
+     {
+        virtual_mouse_device_fd = e_devicemgr_create_virtual_device(E_DEVICEMGR_DEVICE_TYPE_MOUSE, "Virtual Mouse Device");
+
+        if (virtual_mouse_device_fd >= 0)
+          DMDBG("input.virtual_mouse_device_enable: 1, device fd : %d\n", virtual_mouse_device_fd);
+        else
+          DMDBG("input.virtual_mouse_device_enable: 1, but failed to create device !\n");
+     }
+
    return 1;
 }
 
@@ -128,4 +149,16 @@ e_devicemgr_input_fini(void)
 {
    /* remove existing event filter */
    ecore_event_filter_del(ev_filter);
+
+   if (virtual_key_device_fd)
+     {
+        e_devicemgr_destroy_virtual_device(virtual_key_device_fd);
+        virtual_key_device_fd = -1;
+     }
+
+   if (virtual_mouse_device_fd)
+     {
+        e_devicemgr_destroy_virtual_device(virtual_mouse_device_fd);
+        virtual_mouse_device_fd = -1;
+     }
 }
index 204daa6041955477bfacfe6f69568da4f737c7f6..05b8cec95659271933c1640dfd5102e0ead180de 100644 (file)
@@ -2,7 +2,7 @@
 #define _E_DEVICEMGR_PRIVATE_H_
 
 #include "e.h"
-#define LOG_TAG        "DEVICEMGR"
+#define LOG_TAG "DEVICEMGR"
 #include "dlog.h"
 
 extern int _log_dom;
@@ -53,6 +53,8 @@ struct _E_Devicemgr_Conf_Edd
    struct
    {
       Eina_Bool button_remap_enable;
+      Eina_Bool virtual_key_device_enable;
+      Eina_Bool virtual_mouse_device_enable;
       int back_keycode;
    } input;
 };