Add computer-keyboard control mapping

Bind letter/digit keys (with Shift/Control/Option; Command reserved for
menu shortcuts) to the same rig toggle Actions a MIDI Program-Change
footswitch drives. Keys reuse MIDIController's perform(_:) dispatch via a
new .key learn target and ingestKey(_:modifiers:).

Key capture is platform-specific: macOS installs an AppKit
NSEvent.addLocalMonitorForEvents(.keyDown) monitor (SwiftUI .onKeyPress
only delivers to the focused view); iOS uses .onKeyPress with the root
made focusable/focused, reclaiming focus when a text-field modal closes.
Both gate on the first responder not being a text field so typing is
never hijacked, filter key-repeat, and reserve Command for the menu.

MIDIMap gains keys:[KeyBinding] and a KeyModifiers OptionSet, both with
tolerant Codable decode so old rigs (no keys / no modifiers) still load
with switches/ccs intact. The mapping sheet is unified: each switch row
shows its footswitch (PC) and key bindings with per-source learn/clear,
and the sheet is retitled "MIDI / Control Mapping".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-08 15:03:12 -07:00
parent 2c2ce06797
commit a33d5488c9
8 changed files with 785 additions and 28 deletions
+15 -8
View File
@@ -109,8 +109,9 @@ public struct HelpView: View {
"Tracks A–D: tap a dot to select the track Record overdubs into; tap a selected, "
+ "recorded track again to mute or unmute it.",
"MIDI: Record, Stop, Cue Stop, Reverse, Sync, Reset, and each Track A–D map as "
+ "footswitch (Program Change) actions in MIDI Mapping; the Crossfade / Playback / "
+ "Overdub / Feedback knobs sweep from an expression pedal like any pedal knob.",
+ "footswitch (Program Change) or key actions in MIDI / Control Mapping; the "
+ "Crossfade / Playback / Overdub / Feedback knobs sweep from an expression pedal "
+ "like any pedal knob.",
]
)
topicSection(
@@ -136,13 +137,19 @@ public struct HelpView: View {
)
topicSection(
icon: "pianokeys",
title: "MIDI Control",
intro: "Map a MIDI foot controller (e.g. a Behringer FCB1010) for hands-free control.",
title: "MIDI / Control",
intro: "Map a MIDI foot controller (e.g. a Behringer FCB1010) or your computer keyboard for "
+ "hands-free control.",
steps: [
"The keys icon in the top bar lights green when a device is connected. Tap it to open MIDI Mapping.",
"Switches (Program Change): footswitches toggle Rig Bypass, All Boards, and each board's "
+ "Solo / Audible / Bypass or a pedal's bypass. Tap Learn, then press the footswitch. "
+ "One switch can drive several actions at once — a scene.",
"The keys icon in the top bar lights green when a device is connected. Tap it to open "
+ "MIDI / Control Mapping.",
"Switches: footswitches and letter keys toggle Rig Bypass, All Boards, and each board's "
+ "Solo / Audible / Bypass or a pedal's bypass. Tap PC then press a footswitch, or Key "
+ "then press a key. One switch or key can drive several actions at once — a scene.",
"Keys fire only when you're not typing — while a text field (like a rig name) is focused, "
+ "letters go to the field, not to your mappings.",
"Hold Shift, Control, or Option while learning to bind a modified key — a and ⇧a are "
+ "separate triggers. Command is reserved for the menu shortcuts.",
"Expression (Control Change): an expression pedal sweeps any pedal knob or slider, or a "
+ "board's Level. Tap Learn, then move the pedal. Invert reverses the sweep — map one "
+ "CC to two controls and invert one for a crossfade.",