e_input: Set device's subclass to virtual using udev property 06/306506/1
authorduna.oh <duna.oh@samsung.com>
Thu, 8 Feb 2024 07:08:02 +0000 (16:08 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 22 Feb 2024 08:00:41 +0000 (17:00 +0900)
Change-Id: Id765eac76334698d28715cd940abf1b0ab147f33

configure.ac
packaging/enlightenment.spec
src/bin/e_input_inputs.c

index def81d1..d22de9d 100755 (executable)
@@ -284,6 +284,7 @@ e_requires="\
   eo >= $efl_version \
   eeze >= $efl_version \
   libinput \
+  libudev \
   libtbm \
   libtdm >= "1.0.0" \
   glib-2.0 \
index 85db150..c688acb 100644 (file)
@@ -56,6 +56,7 @@ BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  pkgconfig(pixman-1)
 BuildRequires:  systemd-devel
 BuildRequires:  pkgconfig(libinput)
+BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(presentation-time-server)
 BuildRequires:  pkgconfig(egl)
 BuildRequires:  pkgconfig(linux-explicit-synchronization-unstable-v1-server)
index 7e73090..d263cbc 100644 (file)
@@ -7,6 +7,7 @@
 #include "e_config_intern.h"
 #include "e_device_intern.h"
 #include "e_comp_wl_input_intern.h"
+#include <libudev.h>
 
 #include <glib.h>
 
@@ -206,7 +207,7 @@ _seat_get(E_Input_Backend *input, const char *seat)
 }
 
 static Eina_Bool
-_e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
+_e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas, Ecore_Device_Subclass subclas)
 {
    const Eina_List *dev_list = NULL;
    const Eina_List *l;
@@ -244,7 +245,7 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
    ecore_device_name_set(dev, libinput_device_get_name(edev->device));
    ecore_device_identifier_set(dev, edev->path);
    ecore_device_class_set(dev, clas);
-   ecore_device_subclass_set(dev, ECORE_DEVICE_SUBCLASS_NONE);
+   ecore_device_subclass_set(dev, subclas);
 
    if (!edev->ecore_dev)
      {
@@ -299,7 +300,7 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
    e_device_name_set(e_dev, libinput_device_get_name(edev->device));
    e_device_identifier_set(e_dev, edev->path);
    e_device_class_set(e_dev, clas);
-   e_device_subclass_set(e_dev, ECORE_DEVICE_SUBCLASS_NONE);
+   e_device_subclass_set(e_dev, subclas);
 
    if (!edev->e_dev)
      {
@@ -423,27 +424,51 @@ _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
    return ret;
 }
 
+static Ecore_Device_Subclass
+_e_input_device_get_ecore_device_subclass(E_Input_Evdev *edev, Ecore_Device_Class clas)
+{
+   Ecore_Device_Subclass subclas = ECORE_DEVICE_SUBCLASS_NONE;
+   struct udev_device *udev_device = NULL;
+   const char *devpath;
+
+   udev_device = libinput_device_get_udev_device(edev->device);
+   devpath = udev_device_get_property_value(udev_device, "DEVPATH");
+   if (devpath && strstr(devpath, "virtual"))
+     {
+        if (clas == ECORE_DEVICE_CLASS_MOUSE)
+          subclas = ECORE_DEVICE_SUBCLASS_VIRTUAL_MOUSE;
+        else if (clas == ECORE_DEVICE_CLASS_KEYBOARD)
+          subclas = ECORE_DEVICE_SUBCLASS_VIRTUAL_REMOCON;
+     }
+   return subclas;
+}
+
 Eina_Bool
 _e_input_device_add(E_Input_Evdev *edev)
 {
    Eina_Bool ret = EINA_FALSE;
    Ecore_Device_Class clas = ECORE_DEVICE_CLASS_NONE;
+   Ecore_Device_Subclass subclas = ECORE_DEVICE_SUBCLASS_NONE;
 
    if (edev->caps & E_INPUT_SEAT_POINTER)
      {
         if (!e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
-          clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
-        ret = _e_input_add_ecore_device(edev, clas);
+          {
+             clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
+             subclas = _e_input_device_get_ecore_device_subclass(edev, clas);
+          }
+        ret = _e_input_add_ecore_device(edev, clas, subclas);
      }
    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
      {
         clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_KEYBOARD);
-        ret = _e_input_add_ecore_device(edev, clas);
+        subclas = _e_input_device_get_ecore_device_subclass(edev, clas);
+        ret = _e_input_add_ecore_device(edev, clas, subclas);
      }
    if (edev->caps & E_INPUT_SEAT_TOUCH)
      {
         clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_TOUCH);
-        ret = _e_input_add_ecore_device(edev, clas);
+        ret = _e_input_add_ecore_device(edev, clas, subclas);
      }
 
    return ret;