From 5995ecbb4a0a8d779ba6fa6b273392b12935875a Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Tue, 5 Sep 2023 16:10:54 +0100 Subject: [PATCH] hardware outs cache implemented --- src/nvda_voicemeeter/models.py | 2 +- src/nvda_voicemeeter/window.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nvda_voicemeeter/models.py b/src/nvda_voicemeeter/models.py index 9941803..da66ab3 100644 --- a/src/nvda_voicemeeter/models.py +++ b/src/nvda_voicemeeter/models.py @@ -1,5 +1,5 @@ def _make_hardware_outs_cache(vm) -> dict: - pass + return {**{f"HARDWARE OUT||A{i + 1}": vm.bus[i].device.name for i in range(vm.kind.phys_out)}} def _make_output_cache(vm) -> dict: diff --git a/src/nvda_voicemeeter/window.py b/src/nvda_voicemeeter/window.py index 2a44e3c..b726d60 100644 --- a/src/nvda_voicemeeter/window.py +++ b/src/nvda_voicemeeter/window.py @@ -39,6 +39,7 @@ class NVDAVMWindow(psg.Window): self.kind = self.vm.kind self.logger = logger.getChild(type(self).__name__) self.cache = { + "hw_outs": _make_hardware_outs_cache(self.vm), "outputs": _make_output_cache(self.vm), "busmode": _make_bus_mode_cache(self.vm), "labels": _make_label_cache(self.vm), @@ -91,6 +92,7 @@ class NVDAVMWindow(psg.Window): def on_pdirty(self): self.cache = { + "hw_outs": _make_hardware_outs_cache(self.vm), "outputs": _make_output_cache(self.vm), "busmode": _make_bus_mode_cache(self.vm), "labels": _make_label_cache(self.vm), @@ -382,7 +384,7 @@ class NVDAVMWindow(psg.Window): f"HARDWARE OUT {key} set {phonetic.get(driver, driver)} {device_name}", ) case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]: - self.nvda.speak(f"HARDWARE OUT {key} {self.vm.bus[int(key[-1]) - 1].device.name}") + self.nvda.speak(f"HARDWARE OUT {key} {self.cache['hw_outs'][f'HARDWARE OUT||{key}']}") case [["HARDWARE", "OUT"], [key], ["KEY", "SPACE" | "ENTER"]]: open_context_menu_for_buttonmenu(self, f"HARDWARE OUT||{key}")