mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2024-11-22 18:00:50 +00:00
events registered for hardware out
hardware out now sets a physical device nvida speech added
This commit is contained in:
parent
e200462b85
commit
1fd181d097
@ -1,7 +1,11 @@
|
||||
import logging
|
||||
|
||||
import voicemeeterlib
|
||||
|
||||
import nvda_voicemeeter
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
kind_id = "potato"
|
||||
|
||||
with voicemeeterlib.api("potato") as vm:
|
||||
|
@ -6,5 +6,5 @@ class Parser:
|
||||
self.widget = Group(OneOrMore(Word(alphanums)))
|
||||
self.token = Suppress("||")
|
||||
self.identifier = Group(OneOrMore(Word(alphanums)))
|
||||
self.event = OneOrMore(Word(alphanums))
|
||||
self.event = Group(OneOrMore(Word(alphanums)))
|
||||
self.match = self.widget + self.token + self.identifier + Optional(self.token) + Optional(self.event)
|
||||
|
@ -1,18 +1,24 @@
|
||||
import logging
|
||||
|
||||
import PySimpleGUI as psg
|
||||
|
||||
from .models import _make_cache
|
||||
from .nvda import Nvda
|
||||
from .parser import Parser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Window(psg.Window):
|
||||
def __init__(self, title, vm):
|
||||
self.vm = vm
|
||||
self.kind = self.vm.kind
|
||||
super().__init__(title, self.make_layout(), finalize=True)
|
||||
self.logger = logger.getChild(type(self).__name__)
|
||||
self.cache = _make_cache(self.vm)
|
||||
self.nvda = Nvda()
|
||||
self.parser = Parser()
|
||||
self.register_events()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
@ -32,18 +38,22 @@ class Window(psg.Window):
|
||||
size=(22, 4),
|
||||
expand_x=True,
|
||||
enable_events=True,
|
||||
key=f"DEVICE LIST||PHYSOUT {i}",
|
||||
key=f"HARDWARE OUT||A{i}",
|
||||
)
|
||||
for i in range(self.kind.phys_out)
|
||||
for i in range(1, self.kind.phys_out + 1)
|
||||
]
|
||||
)
|
||||
|
||||
upper_layout = list()
|
||||
[step(upper_layout) for step in (add_physical_device_opts,)]
|
||||
row0 = psg.Frame("Hardware Out", upper_layout)
|
||||
hardware_out = list()
|
||||
[step(hardware_out) for step in (add_physical_device_opts,)]
|
||||
row0 = psg.Frame("Hardware Out", hardware_out)
|
||||
|
||||
return [[row0]]
|
||||
|
||||
def register_events(self):
|
||||
for i in range(1, self.vm.kind.phys_out + 1):
|
||||
self[f"HARDWARE OUT||A{i}"].bind("<FocusIn>", "||FOCUS IN")
|
||||
|
||||
def run(self):
|
||||
"""Runs the main window until an Close/Exit event"""
|
||||
while True:
|
||||
@ -51,8 +61,17 @@ class Window(psg.Window):
|
||||
if event in (psg.WIN_CLOSED, "Exit"):
|
||||
break
|
||||
match self.parser.match.parseString(event):
|
||||
case [["HARDWARE", "OUT"], [key]]:
|
||||
selection = values[f"HARDWARE OUT||{key}"]
|
||||
driver, device_name = selection.split(":")
|
||||
index = int(key[1]) - 1
|
||||
setattr(self.vm.bus[index].device, driver, device_name.strip())
|
||||
self.nvda.speak(f"{driver} {selection}")
|
||||
case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]:
|
||||
self.nvda.speak(f"HARDWARE OUT {key} in focus")
|
||||
case _:
|
||||
pass
|
||||
print(f"Unknown event {event}")
|
||||
self.logger.debug(self.parser.match.parseString(event))
|
||||
|
||||
|
||||
def request_window_object(title, vm):
|
||||
|
Loading…
Reference in New Issue
Block a user