Skip to content

Commit

Permalink
Fix freeze when changing compat mode
Browse files Browse the repository at this point in the history
  • Loading branch information
berarma committed Apr 28, 2024
1 parent 6f98317 commit 4c7062e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions oversteer/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ def set_mode(self, emulation_mode):
with open(path, "w") as file:
file.write(emulation_mode)
# Wait for device ready
while not self.is_ready():
for i in range(10):
if self.is_ready():
return True
time.sleep(1)
# Wait a bit more
time.sleep(5)
return True
return False

def get_range(self):
path = self.checked_device_file("range")
Expand Down
9 changes: 5 additions & 4 deletions oversteer/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def register_event(self, action, udevice):
id = udevice.device_path
if id is None:
return
logging.debug("%s: %s", action, id)
logging.debug("Udev event %s: %s", action, id)
if action == 'add':
self.update_device_list(udevice)
device = self.get_device(id)
if device:
device.enable()
time.sleep(5)
device.enable()
self.changed = True
if action == 'remove':
device = self.get_device(id)
Expand Down Expand Up @@ -126,7 +126,6 @@ def first_device(self):
return None

def get_devices(self):
self.changed = False
return list(self.devices.values())

def get_device(self, did):
Expand All @@ -137,4 +136,6 @@ def get_device(self, did):
return next((item for item in self.devices.values() if item.dev_name == did), None)

def is_changed(self):
return self.changed
changed = self.changed
self.changed = False
return changed
1 change: 1 addition & 0 deletions oversteer/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def install_udev_files(self):
break

def populate_devices(self):
logging.debug("populate_devices")
if self.device_manager.is_changed():
device_list = []
for device in self.device_manager.get_devices():
Expand Down

0 comments on commit 4c7062e

Please sign in to comment.