From 7648b68b859532c63f44403567be9646dbfafdce Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 11 Sep 2023 12:36:40 +0100 Subject: [PATCH 1/3] remove asio devices from hardware out context menus if not A1 removes `-remove device selection-` from hardware out A1 context menu patch bump fixes #7 --- pyproject.toml | 2 +- src/nvda_voicemeeter/builder.py | 4 +--- src/nvda_voicemeeter/util.py | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index de469d4..5e21e95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nvda_voicemeeter" -version = "0.1.3" +version = "0.1.4" description = "A Voicemeeter app compatible with NVDA" authors = [ { name = "onyx-and-iris", email = "code@onyxandiris.online" }, diff --git a/src/nvda_voicemeeter/builder.py b/src/nvda_voicemeeter/builder.py index cf7549b..a9e0d41 100644 --- a/src/nvda_voicemeeter/builder.py +++ b/src/nvda_voicemeeter/builder.py @@ -102,8 +102,6 @@ class Builder: """tab0 row1 represents hardware outs""" def add_physical_device_opts(layout): - devices = get_output_device_list(self.vm) - devices.append("- remove device selection -") if self.kind.name == "basic": num_outs = self.kind.phys_out + self.kind.virt_out else: @@ -113,7 +111,7 @@ class Builder: psg.ButtonMenu( f"A{i + 1}", size=(6, 3), - menu_def=["", devices], + menu_def=["", get_output_device_list(i, self.vm)], key=f"HARDWARE OUT||A{i + 1}", ) for i in range(num_outs) diff --git a/src/nvda_voicemeeter/util.py b/src/nvda_voicemeeter/util.py index ee2e957..f38a2bd 100644 --- a/src/nvda_voicemeeter/util.py +++ b/src/nvda_voicemeeter/util.py @@ -17,8 +17,12 @@ def get_input_device_list(vm) -> list: return ["{type}: {name}".format(**vm.device.input(i)) for i in range(vm.device.ins)] -def get_output_device_list(vm) -> list: - return ["{type}: {name}".format(**vm.device.output(i)) for i in range(vm.device.outs)] +def get_output_device_list(i, vm) -> list: + devices = ["{type}: {name}".format(**vm.device.output(j)) for j in range(vm.device.outs)] + if i == 0: + return devices + devices.append("- remove device selection -") + return [device for device in devices if not device.startswith("asio")] def get_patch_composite_list(kind) -> list: From aaa2c7266885deb7ea21410b32720ab9fe02a658 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 13 Sep 2023 10:56:09 +0100 Subject: [PATCH 2/3] fixes bug setting devices with trailing spaces adds rejected_ids to util. removes Voicemeeter devices as assignable hardware devices patch bump --- pyproject.toml | 2 +- src/nvda_voicemeeter/util.py | 20 ++++++++++++++++++-- src/nvda_voicemeeter/window.py | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e21e95..931c0b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nvda_voicemeeter" -version = "0.1.4" +version = "0.1.5" description = "A Voicemeeter app compatible with NVDA" authors = [ { name = "onyx-and-iris", email = "code@onyxandiris.online" }, diff --git a/src/nvda_voicemeeter/util.py b/src/nvda_voicemeeter/util.py index f38a2bd..02ad543 100644 --- a/src/nvda_voicemeeter/util.py +++ b/src/nvda_voicemeeter/util.py @@ -13,12 +13,28 @@ def get_insert_checkbox_index(kind, channel, num) -> int: return (2 * kind.phys_in) + (8 * (num - kind.phys_in - 1)) + channel +_rejected_ids = ( + "VBAudio100VMVAIO3", + "{F5735BD4-6EAF-4758-9710-9886E5AD0FF3}", + "{0239BE07-CEEF-4236-A900-AA778D432FD4}", +) + + def get_input_device_list(vm) -> list: - return ["{type}: {name}".format(**vm.device.input(i)) for i in range(vm.device.ins)] + devices = [] + for j in range(vm.device.ins): + device = vm.device.input(j) + if device["id"] not in _rejected_ids: + devices.append("{type}: {name}".format(**device)) + return devices def get_output_device_list(i, vm) -> list: - devices = ["{type}: {name}".format(**vm.device.output(j)) for j in range(vm.device.outs)] + devices = [] + for j in range(vm.device.outs): + device = vm.device.output(j) + if device["id"] not in _rejected_ids: + devices.append("{type}: {name}".format(**device)) if i == 0: return devices devices.append("- remove device selection -") diff --git a/src/nvda_voicemeeter/window.py b/src/nvda_voicemeeter/window.py index d677716..ecfbcfa 100644 --- a/src/nvda_voicemeeter/window.py +++ b/src/nvda_voicemeeter/window.py @@ -431,7 +431,7 @@ class NVDAVMWindow(psg.Window): setattr(self.vm.bus[index].device, "wdm", "") self.TKroot.after(200, self.nvda.speak, f"HARDWARE OUT {key} device selection removed") case [driver, device_name]: - setattr(self.vm.bus[index].device, driver, device_name.strip()) + setattr(self.vm.bus[index].device, driver, device_name.lstrip()) phonetic = {"mme": "em em e"} self.TKroot.after( 200, From 2562c02b7e9aeb0383333c150220cff57dffcee3 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 13 Sep 2023 10:59:41 +0100 Subject: [PATCH 3/3] lstrip hardware in as well. --- src/nvda_voicemeeter/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvda_voicemeeter/window.py b/src/nvda_voicemeeter/window.py index ecfbcfa..5c81d92 100644 --- a/src/nvda_voicemeeter/window.py +++ b/src/nvda_voicemeeter/window.py @@ -410,7 +410,7 @@ class NVDAVMWindow(psg.Window): setattr(self.vm.strip[index].device, "wdm", "") self.TKroot.after(200, self.nvda.speak, f"HARDWARE IN {key} device selection removed") case [driver, device_name]: - setattr(self.vm.strip[index].device, driver, device_name.strip()) + setattr(self.vm.strip[index].device, driver, device_name.lstrip()) phonetic = {"mme": "em em e"} self.TKroot.after( 200,