mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2024-11-22 18:00:50 +00:00
implements strip output events
This commit is contained in:
parent
9adbf71494
commit
2354cc4501
@ -11,9 +11,9 @@ from .util import (
|
|||||||
class Builder:
|
class Builder:
|
||||||
"""Responsible for building the Window layout"""
|
"""Responsible for building the Window layout"""
|
||||||
|
|
||||||
def __init__(self, window, vm):
|
def __init__(self, window):
|
||||||
self.window = window
|
self.window = window
|
||||||
self.vm = vm
|
self.vm = self.window.vm
|
||||||
self.kind = self.vm.kind
|
self.kind = self.vm.kind
|
||||||
|
|
||||||
def run(self) -> list:
|
def run(self) -> list:
|
||||||
@ -38,9 +38,9 @@ class Builder:
|
|||||||
tab1 = psg.Tab("settings", layout0, key="settings")
|
tab1 = psg.Tab("settings", layout0, key="settings")
|
||||||
tab2 = psg.Tab("physical strips", layout1, key="physical strip")
|
tab2 = psg.Tab("physical strips", layout1, key="physical strip")
|
||||||
tab3 = psg.Tab("virtual strips", layout2, key="virtual strip")
|
tab3 = psg.Tab("virtual strips", layout2, key="virtual strip")
|
||||||
Tg = psg.TabGroup([[tab1, tab2, tab3]], change_submits=True, key="tabs")
|
tab_group = psg.TabGroup([[tab1, tab2, tab3]], change_submits=True, key="tabs")
|
||||||
|
|
||||||
return [[Tg]]
|
return [[tab_group]]
|
||||||
|
|
||||||
def make_tab0_row0(self) -> psg.Frame:
|
def make_tab0_row0(self) -> psg.Frame:
|
||||||
"""row0 represents hardware outs"""
|
"""row0 represents hardware outs"""
|
||||||
@ -186,9 +186,9 @@ class Builder:
|
|||||||
[step(outputs) for step in (add_strip_outputs,)]
|
[step(outputs) for step in (add_strip_outputs,)]
|
||||||
return psg.Frame(self.vm.strip[i].label, outputs)
|
return psg.Frame(self.vm.strip[i].label, outputs)
|
||||||
|
|
||||||
def make_tab1_rows(self) -> list:
|
def make_tab1_rows(self) -> psg.Frame:
|
||||||
layout = [[self.make_tab1_row(i)] for i in range(self.kind.phys_out)]
|
layout = [[self.make_tab1_row(i)] for i in range(self.kind.phys_out)]
|
||||||
return psg.Frame(f"", layout)
|
return psg.Frame(None, layout, border_width=0)
|
||||||
|
|
||||||
def make_tab2_row(self, i) -> psg.Frame:
|
def make_tab2_row(self, i) -> psg.Frame:
|
||||||
def add_strip_outputs(layout):
|
def add_strip_outputs(layout):
|
||||||
@ -209,6 +209,6 @@ class Builder:
|
|||||||
[step(outputs) for step in (add_strip_outputs,)]
|
[step(outputs) for step in (add_strip_outputs,)]
|
||||||
return psg.Frame(self.vm.strip[i].label, outputs)
|
return psg.Frame(self.vm.strip[i].label, outputs)
|
||||||
|
|
||||||
def make_tab2_rows(self) -> list:
|
def make_tab2_rows(self) -> psg.Frame:
|
||||||
layout = [[self.make_tab1_row(i)] for i in range(self.kind.phys_out, self.kind.phys_out + self.kind.virt_out)]
|
layout = [[self.make_tab1_row(i)] for i in range(self.kind.phys_out, self.kind.phys_out + self.kind.virt_out)]
|
||||||
return psg.Frame(f"", layout)
|
return psg.Frame(None, layout, border_width=0)
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
def _make_cache(vm) -> dict:
|
def _make_output_cache(vm) -> dict:
|
||||||
match vm.kind.name:
|
match vm.kind.name:
|
||||||
case "basic":
|
case "basic":
|
||||||
return {
|
return {
|
||||||
**{f"BUTTON||strip {i} A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
|
||||||
}
|
}
|
||||||
case "banana":
|
case "banana":
|
||||||
return {
|
return {
|
||||||
**{f"BUTTON||strip {i} A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} A2": vm.strip[i].A2 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A2": vm.strip[i].A2 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} A3": vm.strip[i].A3 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A3": vm.strip[i].A3 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} B2": vm.strip[i].B2 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||B2": vm.strip[i].B2 for i in range(vm.kind.num_strip)},
|
||||||
}
|
}
|
||||||
case "potato":
|
case "potato":
|
||||||
return {
|
return {
|
||||||
**{f"BUTTON||strip {i} A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} A2": vm.strip[i].A2 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A2": vm.strip[i].A2 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} A3": vm.strip[i].A3 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A3": vm.strip[i].A3 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} A4": vm.strip[i].A4 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A4": vm.strip[i].A4 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} A5": vm.strip[i].A5 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||A5": vm.strip[i].A5 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} B2": vm.strip[i].B2 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||B2": vm.strip[i].B2 for i in range(vm.kind.num_strip)},
|
||||||
**{f"BUTTON||strip {i} B3": vm.strip[i].B3 for i in range(vm.kind.num_strip)},
|
**{f"STRIP {i}||B3": vm.strip[i].B3 for i in range(vm.kind.num_strip)},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
import PySimpleGUI as psg
|
import PySimpleGUI as psg
|
||||||
|
|
||||||
from .builder import Builder
|
from .builder import Builder
|
||||||
from .models import _make_cache, _patch_insert_channels
|
from .models import _make_output_cache, _patch_insert_channels
|
||||||
from .nvda import Nvda
|
from .nvda import Nvda
|
||||||
from .parser import Parser
|
from .parser import Parser
|
||||||
from .util import (
|
from .util import (
|
||||||
@ -24,10 +24,10 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.vm = vm
|
self.vm = vm
|
||||||
self.kind = self.vm.kind
|
self.kind = self.vm.kind
|
||||||
self.logger = logger.getChild(type(self).__name__)
|
self.logger = logger.getChild(type(self).__name__)
|
||||||
self.cache = {}
|
self.cache = {"outputs": _make_output_cache(self.vm)}
|
||||||
self.nvda = Nvda()
|
self.nvda = Nvda()
|
||||||
self.parser = Parser()
|
self.parser = Parser()
|
||||||
self.builder = Builder(self, self.vm)
|
self.builder = Builder(self)
|
||||||
layout = self.builder.run()
|
layout = self.builder.run()
|
||||||
super().__init__(title, layout, finalize=True)
|
super().__init__(title, layout, finalize=True)
|
||||||
[self[f"HARDWARE OUT||A{i + 1}"].Widget.config(takefocus=1) for i in range(self.kind.phys_out)]
|
[self[f"HARDWARE OUT||A{i + 1}"].Widget.config(takefocus=1) for i in range(self.kind.phys_out)]
|
||||||
@ -165,6 +165,15 @@ class NVDAVMWindow(psg.Window):
|
|||||||
channel = _patch_insert_channels[int(channel)]
|
channel = _patch_insert_channels[int(channel)]
|
||||||
num = int(in_num[-1])
|
num = int(in_num[-1])
|
||||||
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
|
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
|
||||||
|
|
||||||
|
# Strip outputs
|
||||||
|
case [["STRIP", "0"], [output]]:
|
||||||
|
val = not self.cache["outputs"][f"STRIP {index}||{output}"]
|
||||||
|
setattr(self.vm.strip[int(index)], output, val)
|
||||||
|
self.cache["outputs"][f"STRIP {index}||{output}"] = val
|
||||||
|
case [["STRIP", index], [output], ["FOCUS", "IN"]]:
|
||||||
|
val = self.cache["outputs"][f"STRIP {index}||{output}"]
|
||||||
|
self.nvda.speak(f"STRIP {index} {output} {'on' if val else 'off'}")
|
||||||
case _:
|
case _:
|
||||||
self.logger.error(f"Unknown event {event}")
|
self.logger.error(f"Unknown event {event}")
|
||||||
self.logger.debug(parsed_cmd)
|
self.logger.debug(parsed_cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user