From: duna.oh Date: Thu, 8 Feb 2024 07:13:33 +0000 (+0900) Subject: e_input: Add E_API e_input_device_is_virtual(dev, device_path, clas) X-Git-Tag: accepted/tizen/unified/20240228.170406~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F306507%2F1;p=platform%2Fupstream%2Fenlightenment.git e_input: Add E_API e_input_device_is_virtual(dev, device_path, clas) E_API for checking if a device is physically connected or virtual Change-Id: Ib7ff83e9ce2290bdb613091c2d2e9d7ff2b4b4e9 --- diff --git a/src/bin/e_input_device.c b/src/bin/e_input_device.c index df1e0f5..4adbf8a 100644 --- a/src/bin/e_input_device.c +++ b/src/bin/e_input_device.c @@ -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; +} diff --git a/src/bin/e_input_inputs.c b/src/bin/e_input_inputs.c index d263cbc..963bf0a 100644 --- a/src/bin/e_input_inputs.c +++ b/src/bin/e_input_inputs.c @@ -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; } diff --git a/src/include/e_input.h b/src/include/e_input.h index 7793123..1066085 100644 --- a/src/include/e_input.h +++ b/src/include/e_input.h @@ -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();