add deselect device to hardware outs

This commit is contained in:
onyx-and-iris 2023-08-22 05:37:06 +01:00
parent 65cd21203b
commit 740cf1ac02

View File

@ -31,6 +31,7 @@ class Window(psg.Window):
def add_physical_device_opts(layout): def add_physical_device_opts(layout):
devices = ["{type}: {name}".format(**self.vm.device.output(i)) for i in range(self.vm.device.outs)] devices = ["{type}: {name}".format(**self.vm.device.output(i)) for i in range(self.vm.device.outs)]
devices.append("Deselect Device")
layout.append( layout.append(
[ [
psg.Combo( psg.Combo(
@ -38,6 +39,7 @@ class Window(psg.Window):
size=(22, 4), size=(22, 4),
expand_x=True, expand_x=True,
enable_events=True, enable_events=True,
readonly=True,
key=f"HARDWARE OUT||A{i}", key=f"HARDWARE OUT||A{i}",
) )
for i in range(1, self.kind.phys_out + 1) for i in range(1, self.kind.phys_out + 1)
@ -98,7 +100,11 @@ class Window(psg.Window):
match self.parser.match.parseString(event): match self.parser.match.parseString(event):
case [["HARDWARE", "OUT"], [key]]: case [["HARDWARE", "OUT"], [key]]:
selection = values[f"HARDWARE OUT||{key}"] selection = values[f"HARDWARE OUT||{key}"]
driver, device_name = selection.split(":") match selection.split(":"):
case [device_name]:
device_name = ""
self.nvda.speak(f"HARDWARE OUT {key} device deselected")
case [driver, device_name]:
index = int(key[1]) - 1 index = int(key[1]) - 1
setattr(self.vm.bus[index].device, driver, device_name.strip()) setattr(self.vm.bus[index].device, driver, device_name.strip())
self.nvda.speak(f"{driver} {selection}") self.nvda.speak(f"{driver} {selection}")