Read the pad over Bluetooth first, and USB when it isn't paired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-23 00:02:08 +13:00
1 parent 2586ead4fa
commit 9c1ef6f2d4
2 files changed
+10 -10

No files matched your search

+5 -5
View File
@@ -11,8 +11,8 @@ While Play is held, bank 2 notes 52–67 go out as 68–83 (see padcontroller/la
Point QLC+ MIDI input at that virtual port (midi.qxw does this via Point QLC+ MIDI input at that virtual port (midi.qxw does this via
patch_smc_pad.py once the pad controller is running). Every 2 s it checks the patch_smc_pad.py once the pad controller is running). Every 2 s it checks the
links: it reopens the pad when it is replugged (or moves to USB when that turns links: it reopens the pad when it is replugged (or moves to Bluetooth when that
up) and re-links QLC+ to the virtual port after a restart, so QLC+ can stay open. turns up) and re-links QLC+ to the virtual port after a restart, so QLC+ can stay open.
QLC+ reopens its MIDI port when it loads a show, so a new link to QLC+ while QLC+ reopens its MIDI port when it loads a show, so a new link to QLC+ while
the pad controller runs means the show has just loaded with every button off. the pad controller runs means the show has just loaded with every button off.
@@ -56,10 +56,10 @@ from pad_lamps import set_lamps, set_sound_lamps # noqa: E402
VIRTUAL_NAME = "padcontroller" VIRTUAL_NAME = "padcontroller"
COLOURS_FILE = Path(os.environ.get("XDG_STATE_HOME", Path.home() / ".local" / "state")) / "padcontroller" / "colours.json" COLOURS_FILE = Path(os.environ.get("XDG_STATE_HOME", Path.home() / ".local" / "state")) / "padcontroller" / "colours.json"
REOPEN_DELAY = 1.5 # s for QLC+ to finish loading the virtual console REOPEN_DELAY = 1.5 # s for QLC+ to finish loading the virtual console
# USB first when the pad is plugged in, Bluetooth otherwise. # Bluetooth first when the pad is paired, USB otherwise.
SOURCE_HINTS = ( SOURCE_HINTS = (
"SINCO SMC-PAD-Master",
"SMC-PAD Bluetooth", "SMC-PAD Bluetooth",
"SINCO SMC-PAD-Master",
"SINCO SMC-PAD-Private", "SINCO SMC-PAD-Private",
"SINCO", "SINCO",
"SMC-PAD", "SMC-PAD",
@@ -242,7 +242,7 @@ def main() -> None:
while True: while True:
now = time.monotonic() now = time.monotonic()
if now >= next_link_check: if now >= next_link_check:
# Follow the pad: reopen it when it comes back, and move to USB when plugged in. # Follow the pad: reopen it when it comes back, and move to Bluetooth when paired.
names = midiin.get_ports() names = midiin.get_ports()
best = pick_source(names) best = pick_source(names)
best_name = names[best] if best is not None else None best_name = names[best] if best is not None else None
+5 -5
View File
@@ -35,13 +35,13 @@ client 131: 'qlcplus' [type=user,pid=57635]
""" """
def test_usb_wins_over_bluetooth(): def test_bluetooth_wins_over_usb():
assert BOTH[pick_source(BOTH)] == "SINCO:SINCO SMC-PAD-Master 20:1" assert BOTH[pick_source(BOTH)] == "SMC-PAD:SMC-PAD Bluetooth 128:0"
def test_bluetooth_when_unplugged(): def test_usb_when_not_paired():
names = [n for n in BOTH if "SINCO" not in n] names = [n for n in BOTH if "Bluetooth" not in n]
assert names[pick_source(names)] == "SMC-PAD:SMC-PAD Bluetooth 128:0" assert names[pick_source(names)] == "SINCO:SINCO SMC-PAD-Master 20:1"
def test_no_pad_and_never_our_own_port(): def test_no_pad_and_never_our_own_port():