using utility index methods

This commit is contained in:
onyx-and-iris 2023-08-23 00:27:12 +01:00
parent 990aea2b42
commit c0c0701ed8

View File

@ -6,6 +6,7 @@ from .builder import Builder
from .models import _make_cache, _patch_insert_channels from .models import _make_cache, _patch_insert_channels
from .nvda import Nvda from .nvda import Nvda
from .parser import Parser from .parser import Parser
from .util import get_asio_checkbox_index, get_insert_checkbox_index
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -75,10 +76,7 @@ class Window(psg.Window):
case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]: case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]:
self.nvda.speak(f"HARDWARE OUT {key} in focus") self.nvda.speak(f"HARDWARE OUT {key} in focus")
case [["ASIO", "CHECKBOX"], [in_num, channel]]: case [["ASIO", "CHECKBOX"], [in_num, channel]]:
if int(channel) == 0: index = get_asio_checkbox_index(int(channel), int(in_num[-1]))
index = (2 * int(in_num[-1])) - 2
else:
index = 2 * int(in_num[-1]) - 1
val = values[f"ASIO CHECKBOX||{in_num} {channel}"] val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
self.vm.patch.asio[index].set(val) self.vm.patch.asio[index].set(val)
channel = ("left", "right")[int(channel)] channel = ("left", "right")[int(channel)]
@ -88,14 +86,11 @@ class Window(psg.Window):
num = int(in_num[-1]) num = int(in_num[-1])
self.nvda.speak(f"Patch ASIO inputs to strips IN#{num} {channel} in focus") self.nvda.speak(f"Patch ASIO inputs to strips IN#{num} {channel} in focus")
case [["INSERT", "CHECKBOX"], [in_num, channel]]: case [["INSERT", "CHECKBOX"], [in_num, channel]]:
num = int(in_num[-1]) index = get_insert_checkbox_index(
if num <= self.kind.phys_in: self.kind,
if int(channel) == 0: int(channel),
index = (2 * int(in_num[-1])) - 2 int(in_num[-1]),
else: )
index = 2 * int(in_num[-1]) - 1
else:
index = (2 * self.kind.phys_in) + (8 * (int(in_num[-1]) - self.kind.phys_in - 1)) + int(channel)
val = values[f"INSERT CHECKBOX||{in_num} {channel}"] val = values[f"INSERT CHECKBOX||{in_num} {channel}"]
self.vm.patch.insert[index].on = val self.vm.patch.insert[index].on = val
self.nvda.speak( self.nvda.speak(