From 5d15d79f1b4823b55e272a3c9ed5ae13c7daa4ff Mon Sep 17 00:00:00 2001 From: Ali Hatami Tajik Date: Sat, 11 Mar 2023 12:41:34 +0330 Subject: [PATCH] Add egalax utility --- src/scripts/python/xutil/egalax.py | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/scripts/python/xutil/egalax.py diff --git a/src/scripts/python/xutil/egalax.py b/src/scripts/python/xutil/egalax.py new file mode 100644 index 0000000..2a29c0b --- /dev/null +++ b/src/scripts/python/xutil/egalax.py @@ -0,0 +1,39 @@ +"""eGalax + +This module is responsible for detecting the touchpanel. It would detect the +touchpannel's drm output and its overal status. +""" + +from pathlib import Path + +VENDOR_ID = "0EEF" +DEVICE_ID = "C000" + +def get_egalax_path() -> Path: + """Get device path + + This function will return the path of the HID device related to the pannel. + NOTE that it is not the path of the EDID but it can be extracted from it. + + Returns: + Path: Path of the eGalax hid device OR None if device is not ceonnected + """ + query = '*' + VENDOR_ID + ':' + DEVICE_ID + '*' + devices = list(Path('/sys/devices').rglob(query)) + if devices: + return devices[0] + else: + return None + + +def is_egalax_connected() -> bool: + """Checks if device is connected + + avaiability of the device is checked by existing a path of the device in the + /sys/devices directory. + + Returns: + bool: True if device is connected + """ + devpath = get_egalax_path() + return bool(devpath) \ No newline at end of file