From 9c1ef6f2d468cc00732bd78be7ae4c5347830cfa Mon Sep 17 00:00:00 2001 From: jimmy Date: Fri, 23 Oct 2026 00:02:08 +1300 Subject: [PATCH] Read the pad over Bluetooth first, and USB when it isn't paired. Co-Authored-By: Claude Opus 5.5 --- padcontroller/midi.py | 10 +++++----- tests/test_padcontroller_midi.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/padcontroller/midi.py b/padcontroller/midi.py index 405295d..7a3d9b0 100644 --- a/padcontroller/midi.py +++ b/padcontroller/midi.py @@ -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 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 -up) and re-links QLC+ to the virtual port after a restart, so QLC+ can stay open. +links: it reopens the pad when it is replugged (or moves to Bluetooth when that +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 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" 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 -# USB first when the pad is plugged in, Bluetooth otherwise. +# Bluetooth first when the pad is paired, USB otherwise. SOURCE_HINTS = ( - "SINCO SMC-PAD-Master", "SMC-PAD Bluetooth", + "SINCO SMC-PAD-Master", "SINCO SMC-PAD-Private", "SINCO", "SMC-PAD", @@ -242,7 +242,7 @@ def main() -> None: while True: now = time.monotonic() 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() best = pick_source(names) best_name = names[best] if best is not None else None diff --git a/tests/test_padcontroller_midi.py b/tests/test_padcontroller_midi.py index 3ea51d3..b2f00e2 100644 --- a/tests/test_padcontroller_midi.py +++ b/tests/test_padcontroller_midi.py @@ -35,13 +35,13 @@ client 131: 'qlcplus' [type=user,pid=57635] """ -def test_usb_wins_over_bluetooth(): - assert BOTH[pick_source(BOTH)] == "SINCO:SINCO SMC-PAD-Master 20:1" +def test_bluetooth_wins_over_usb(): + assert BOTH[pick_source(BOTH)] == "SMC-PAD:SMC-PAD Bluetooth 128:0" -def test_bluetooth_when_unplugged(): - names = [n for n in BOTH if "SINCO" not in n] - assert names[pick_source(names)] == "SMC-PAD:SMC-PAD Bluetooth 128:0" +def test_usb_when_not_paired(): + names = [n for n in BOTH if "Bluetooth" not in n] + assert names[pick_source(names)] == "SINCO:SINCO SMC-PAD-Master 20:1" def test_no_pad_and_never_our_own_port():