Guard evdev uinput setup

This commit is contained in:
Storm Dragon
2026-03-04 04:01:19 -05:00
parent 4050c32a16
commit 57c09e0db9
2 changed files with 8 additions and 2 deletions

View File

@@ -4,5 +4,5 @@
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributors.
version = "2026.02.15"
version = "2026.03.04"
code_name = "testing"

View File

@@ -68,7 +68,9 @@ class driver(inputDriver):
self.gDevices = {}
self.iDeviceNo = 0
self.watch_dog = Value(c_bool, True)
self.UInputinject = UInput()
self.UInputinject = (
UInput() if _evdevAvailable and "UInput" in globals() else None
)
self._deviceLock = threading.Lock()
def initialize(self, environment):
@@ -634,6 +636,8 @@ class driver(inputDriver):
self.uDevices[fd] = None
if self.uDevices[fd] is not None:
return
if "UInput" not in globals():
return
try:
self.uDevices[fd] = UInput.from_device(
self.iDevices[fd], name="fenrir-uinput", phys="fenrir-uinput"
@@ -936,6 +940,8 @@ class driver(inputDriver):
"""
if not self._initialized:
return
if self.UInputinject is None:
return
try:
self.UInputinject.write(e.EV_KEY, e.ecodes[key], state)
self.UInputinject.syn()