Skip to content

Commit

Permalink
fix input detect again (#77)
Browse files Browse the repository at this point in the history
seems like in some platforms the calls to libinput and xinput may throw random errors, lets protect against that

Reported by @emphasize
  • Loading branch information
JarbasAl committed Oct 18, 2022
1 parent c600ace commit c3372a3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ovos_utils/device_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ def _build_linput_devices_list(self):
})

def _get_libinput_devices_list(self):
self._build_linput_devices_list()
if find_executable("libinput"):
try:
self._build_linput_devices_list()
except:
self.libinput_devices_list.clear()
LOG.exception("Failed to query libinput for devices")
return self.libinput_devices_list

def _build_xinput_devices_list(self):
Expand All @@ -92,18 +97,19 @@ def _build_xinput_devices_list(self):
self.xinput_devices_list.append(dev)

def _get_xinput_devices_list(self):
self._build_xinput_devices_list()
if find_executable("xinput"):
try:
self._build_xinput_devices_list()
except:
self.xinput_devices_list.clear()
LOG.exception("Failed to query xinput for devices")
return self.xinput_devices_list

def get_input_device_list(self):
# check if any of the devices support touch or mouse
if find_executable("libinput"):
self._build_linput_devices_list()
if find_executable("xinput"):
self._build_xinput_devices_list()

return self.libinput_devices_list + \
self.xinput_devices_list
self._get_libinput_devices_list()
self._get_xinput_devices_list()
return self.libinput_devices_list + self.xinput_devices_list

def can_use_touch_mouse(self):
if not find_executable("libinput") and not find_executable("xinput"):
Expand Down

0 comments on commit c3372a3

Please sign in to comment.