e_input: Add E_API e_input_device_is_virtual(dev, device_path, clas) 07/306507/1
authorduna.oh <duna.oh@samsung.com>
Thu, 8 Feb 2024 07:13:33 +0000 (16:13 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 22 Feb 2024 08:00:41 +0000 (17:00 +0900)
E_API for checking if a device is physically connected or virtual

Change-Id: Ib7ff83e9ce2290bdb613091c2d2e9d7ff2b4b4e9

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

index df1e0f5..4adbf8a 100644 (file)
@@ -1685,3 +1685,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 d263cbc..963bf0a 100644 (file)
@@ -326,7 +326,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;
 }
index 7793123..1066085 100644 (file)
@@ -95,6 +95,7 @@ E_API Eina_Bool        e_input_device_pointer_warp(E_Input_Device *dev, int x, i
 E_API Eina_Bool        e_input_device_mouse_accel_speed_set(E_Input_Device *dev, double speed);
 E_API Eina_Bool        e_input_device_mouse_accel_enable_set(const char *device_name, Eina_Bool enable);
 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);
 
 E_API unsigned int e_input_touch_max_count_get();