e_input: Add E_API e_input_device_is_virtual(dev, device_path, clas) 67/306667/2
authorduna.oh <duna.oh@samsung.com>
Thu, 8 Feb 2024 07:13:33 +0000 (16:13 +0900)
committerduna.oh <duna.oh@samsung.com>
Wed, 28 Feb 2024 22:53:06 +0000 (07:53 +0900)
E_API for checking if a device is physically connected or virtual

Change-Id: Ib7ff83e9ce2290bdb613091c2d2e9d7ff2b4b4e9

src/bin/e_input.h
src/bin/e_input_device.c
src/bin/e_input_inputs.c

index 0a187bdad0e721151bfad1403b4be33a96d112ab..a2fc5fdd41590f6fef584fd4b2d9606967af0a89 100644 (file)
@@ -185,6 +185,7 @@ EINTERN void e_input_thread_run(E_Input_Backend *input);
 EINTERN Eina_Bool e_input_libinput_context_create(E_Input_Backend *input);
 
 E_API Eina_Bool        e_input_device_keyboard_has_key(E_Input_Device *dev, const char *device_path, uint32_t code);
+E_API Eina_Bool        e_input_device_is_virtual(E_Input_Device *dev, const char *device_path, Ecore_Device_Class clas);
 
 #endif
 #endif
index 4cdb31304b147245f9427df31b2eeb4858820679..e3eadfa1e21ce06b9abc47e1cf47bf6c2d5eb7a4 100644 (file)
@@ -1681,3 +1681,47 @@ e_input_device_keyboard_has_key(E_Input_Device *dev, const char *device_path, ui
 
    return ret;
 }
+
+E_API Eina_Bool
+e_input_device_is_virtual(E_Input_Device *dev, const char *device_path, Ecore_Device_Class clas)
+{
+   Eina_Bool ret = EINA_FALSE;
+   Ecore_Device *ecore_dev = NULL;
+   E_Device *e_dev = NULL;
+   Ecore_Device_Subclass subclas = ECORE_DEVICE_SUBCLASS_NONE;
+
+   if (!e_input_thread_mode_get())
+     {
+        ecore_dev = e_input_evdev_get_ecore_device(device_path, clas);
+        if (!ecore_dev)
+          {
+             ERR("Failed to find input device: %s", device_path);
+             return EINA_FALSE;
+          }
+        subclas = ecore_device_subclass_get(ecore_dev);
+     }
+   else
+     {
+        e_dev = e_input_evdev_get_e_device(device_path, clas);
+        if (!e_dev)
+          {
+             ERR("Failed to find input device: %s", device_path);
+             return EINA_FALSE;
+          }
+        subclas = e_device_subclass_get(e_dev);
+     }
+   if (clas == ECORE_DEVICE_CLASS_MOUSE)
+     {
+        if (subclas == ECORE_DEVICE_SUBCLASS_VIRTUAL_MOUSE)
+          ret = EINA_TRUE;
+     }
+   else if (clas == ECORE_DEVICE_CLASS_KEYBOARD)
+     {
+        if (subclas == ECORE_DEVICE_SUBCLASS_VIRTUAL_REMOCON)
+          ret = EINA_TRUE;
+     }
+   INF("device(%s) device_is_virtual %s (clas:%d, subclas:%d)",
+       device_path, ret ? "True" : "False", clas, subclas);
+
+   return ret;
+}
index 8a6ed3bbb28a474c723d77cec10f280e48442dbe..88fdf465d612f2ac4cdf4667d24764304def166e 100644 (file)
@@ -320,7 +320,7 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas, Ecore_De
 
    _e_input_ecore_device_event(dev, edev->seat ? edev->seat->name : NULL, EINA_TRUE);
 
-   INF("[Add Device] device name(%s), identifier(%s), class(%s)", e_device_name_get(e_dev), edev->path, _e_input_ecore_device_class_to_string(clas));
+   INF("[Add Device] device name(%s), identifier(%s), class(%s) subclas(%d)", e_device_name_get(e_dev), edev->path, _e_input_ecore_device_class_to_string(clas), subclas);
 
    return EINA_TRUE;
 }