e_devicemgr: support a subclass device change event 43/189443/2 accepted/tizen/unified/20180927.174508 submit/tizen/20180927.080107
authorJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 18 Sep 2018 01:01:28 +0000 (10:01 +0900)
committerJeongHyun Kang <jhyuni.kang@samsung.com>
Thu, 27 Sep 2018 05:18:09 +0000 (05:18 +0000)
Change-Id: I987e531d7f8aef82434473e612b9ca9e735616cf

src/bin/e_devicemgr_input.c
src/bin/e_devicemgr_private.h
src/bin/e_devicemgr_wl.c

index ff406817b44b090d19d5b8dfa9928b38ebf6618a..880359628a661ac7ffb245f523577f21ec19a3d3 100644 (file)
@@ -1,5 +1,22 @@
 #include "e_devicemgr_private.h"
 
+Eina_Bool
+e_devicemgr_strcmp(const char *dst, const char *src)
+{
+   int dst_len, src_len, str_len;
+
+   dst_len = strlen(dst);
+   src_len = strlen(src);
+
+   if (src_len > dst_len) str_len = src_len;
+   else str_len = dst_len;
+
+   if (!strncmp(dst, src, str_len))
+     return EINA_TRUE;
+   else
+     return EINA_FALSE;
+}
+
 static int
 _e_devicemgr_input_pointer_warp(int x, int y)
 {
@@ -275,6 +292,33 @@ _e_devicemgr_input_device_del(const char *name, const char *identifier, const ch
    E_FREE(dev);
 }
 
+static void
+_e_devicemgr_input_device_update(Ecore_Device *dev)
+{
+   Eina_List *l;
+   E_Devicemgr_Input_Device *data;
+   char *dev_identifier;
+
+   EINA_SAFETY_ON_NULL_RETURN(dev);
+
+   dev_identifier = (char *)ecore_device_identifier_get(dev);
+   EINA_SAFETY_ON_NULL_RETURN(dev_identifier);
+
+   EINA_LIST_FOREACH(e_devicemgr->device_list, l, data)
+     {
+        if (data->clas == ecore_device_class_get(dev) && data->identifier)
+          {
+             if (e_devicemgr_strcmp(dev_identifier, data->identifier))
+               {
+                  data->subclas = ecore_device_subclass_get(dev);
+
+                  e_devicemgr_wl_device_update(data);
+                  return;
+               }
+          }
+     }
+}
+
 static Eina_Bool
 _e_devicemgr_input_cb_mouse_button_down(void *data, int type, void *event)
 {
@@ -335,6 +379,21 @@ _e_devicemgr_input_cb_device_del(void *data, int type, void *event)
    return ECORE_CALLBACK_PASS_ON;
 }
 
+static Eina_Bool
+_e_devicemgr_input_cb_device_update(void *data, int type, void *event)
+{
+   Ecore_Event_Device_Update *ev;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(event, ECORE_CALLBACK_PASS_ON);
+
+   ev = (Ecore_Event_Device_Update *)event;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ev->dev, ECORE_CALLBACK_PASS_ON);
+
+   _e_devicemgr_input_device_update(ev->dev);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 static Eina_Bool
 _e_devicemgr_input_process_mouse_button_down(Ecore_Event_Mouse_Button *ev)
 {
@@ -518,6 +577,7 @@ e_devicemgr_input_init(void)
    E_LIST_HANDLER_APPEND(e_devicemgr->handlers, ECORE_EVENT_MOUSE_BUTTON_UP, _e_devicemgr_input_cb_mouse_button_up, NULL);
    E_LIST_HANDLER_APPEND(e_devicemgr->handlers, ECORE_EVENT_DEVICE_ADD, _e_devicemgr_input_cb_device_add, NULL);
    E_LIST_HANDLER_APPEND(e_devicemgr->handlers, ECORE_EVENT_DEVICE_DEL, _e_devicemgr_input_cb_device_del, NULL);
+   E_LIST_HANDLER_APPEND(e_devicemgr->handlers, ECORE_EVENT_DEVICE_SUBCLASS_UPDATE, _e_devicemgr_input_cb_device_update, NULL);
 
    _e_devicemgr_device_query();
 
index 61e34dc92b0bbc18127eef1867d8ae924a75739b..acafeae6cad822acbc8b40c4deb76a5d75d48a57 100644 (file)
@@ -114,6 +114,7 @@ Eina_Bool e_devicemgr_wl_init(void);
 void e_devicemgr_wl_shutdown(void);
 void e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev);
 void e_devicemgr_wl_device_del(E_Devicemgr_Input_Device *dev);
+void e_devicemgr_wl_device_update(E_Devicemgr_Input_Device *dev);
 
 Eina_Bool e_devicemgr_block_check_keyboard(Ecore_Event_Key *ev, Eina_Bool pressed);
 Eina_Bool e_devicemgr_block_check_move(Ecore_Event_Mouse_Move *ev);
@@ -132,6 +133,7 @@ void e_devicemgr_inputgen_get_device_info(E_Devicemgr_Input_Device *dev);
 int e_devicemgr_create_virtual_device(Ecore_Device_Class clas, const char *name);
 void e_devicemgr_destroy_virtual_device(int uinp_fd);
 
+Eina_Bool e_devicemgr_strcmp(const char *dst, const char *src);
 int e_devicemgr_keycode_from_string(const char *keyname);
 int e_devicemgr_input_pointer_warp(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, wl_fixed_t x, wl_fixed_t y);
 void e_devicemgr_wl_detent_send_event(int detent);
index 22d73c0f158feb61edaf32ff0644ae37c9e59d30..149367d633016a45c79bf745a7fe9101e572c1ae 100644 (file)
@@ -101,6 +101,21 @@ _e_devicemgr_wl_device_cb_unbind(struct wl_resource *resource)
    dev->resources = eina_list_remove(dev->resources, resource);
 }
 
+void
+e_devicemgr_wl_device_update(E_Devicemgr_Input_Device *dev)
+{
+   struct wl_array axes;
+   Eina_List *l;
+   struct wl_resource *res;
+
+   wl_array_init(&axes);
+
+   EINA_LIST_FOREACH(dev->resources, l, res)
+     {
+        tizen_input_device_send_device_info(res, dev->name, dev->clas, dev->subclas, &axes);
+     }
+}
+
 void
 e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev)
 {