0.38.0 (72): Bluetooth LE MIDI controllers in Settings (Android and iOS)
- Android: BleMidi scans for the BLE MIDI service, connects through MidiManager.openBluetoothDevice, remembers and reconnects controllers; Settings › MIDI inputs › Bluetooth MIDI (Scan / Connect / Disconnect / Forget) - iOS: the system Bluetooth MIDI panel from Setup › MIDI Sync, connected controllers remembered and reconnected at launch via CoreBluetooth Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2bc5cb1cbb
commit
4d9e2328cb
@@ -29,6 +29,10 @@ final class AppSettings: ObservableObject {
|
||||
@Published var soundModule: Bool { didSet { d.set(soundModule, forKey: "soundModule") } }
|
||||
/// MIDI sources the user switched off (MidiSourceKey).
|
||||
@Published var midiSourcesOff: Set<String> { didSet { d.set(Array(midiSourcesOff).sorted(), forKey: "midiSourcesOff") } }
|
||||
/// Bluetooth LE MIDI controllers to connect at launch: peripheral id -> name.
|
||||
@Published var bleMidiDevices: [String: String] {
|
||||
didSet { d.set(bleMidiDevices.map { "\($0.key)|\($0.value)" }.sorted(), forKey: "bleMidiDevices") }
|
||||
}
|
||||
/// Input bindings, one `code=actionId` line each (gamepad: `modifier:code=actionId`);
|
||||
/// nil until the user changes them (the defaults apply).
|
||||
@Published var keyboardBindings: String? { didSet { d.set(keyboardBindings, forKey: "bindKeyboard") } }
|
||||
@@ -45,6 +49,10 @@ final class AppSettings: ObservableObject {
|
||||
receiveMidiClock = d.bool(forKey: "midiClockRecv")
|
||||
soundModule = d.bool(forKey: "soundModule")
|
||||
midiSourcesOff = Set(d.stringArray(forKey: "midiSourcesOff") ?? [])
|
||||
bleMidiDevices = Dictionary((d.stringArray(forKey: "bleMidiDevices") ?? []).map { e -> (String, String) in
|
||||
let parts = e.split(separator: "|", maxSplits: 1).map(String.init)
|
||||
return (parts[0], parts.count > 1 ? parts[1] : parts[0])
|
||||
}, uniquingKeysWith: { a, _ in a })
|
||||
keyboardBindings = d.string(forKey: "bindKeyboard")
|
||||
gamepadBindings = d.string(forKey: "bindGamepad")
|
||||
midiBindings = d.string(forKey: "bindMidi")
|
||||
@@ -53,7 +61,8 @@ final class AppSettings: ObservableObject {
|
||||
// MARK: Backup text
|
||||
|
||||
private static let keys = ["palette", "recordTailBars", "kbdChannel", "kbdOctave", "vuMeters", "midiClockSend",
|
||||
"midiClockRecv", "soundModule", "midiSourcesOff", "bindKeyboard", "bindGamepad", "bindMidi"]
|
||||
"midiClockRecv", "soundModule", "midiSourcesOff", "bleMidiDevices", "bindKeyboard",
|
||||
"bindGamepad", "bindMidi"]
|
||||
|
||||
/// Every setting as `key=value` lines; multi-line values (bindings, the source
|
||||
/// list) are escaped (`\n` → `\\n`).
|
||||
@@ -92,6 +101,12 @@ final class AppSettings: ObservableObject {
|
||||
if let v = map["midiClockRecv"] { receiveMidiClock = v == "true" }
|
||||
if let v = map["soundModule"] { soundModule = v == "true" }
|
||||
if let v = map["midiSourcesOff"] { midiSourcesOff = Set(v.split(separator: "\n").map(String.init)) }
|
||||
if let v = map["bleMidiDevices"] {
|
||||
bleMidiDevices = Dictionary(v.split(separator: "\n").map { e -> (String, String) in
|
||||
let parts = e.split(separator: "|", maxSplits: 1).map(String.init)
|
||||
return (parts[0], parts.count > 1 ? parts[1] : parts[0])
|
||||
}, uniquingKeysWith: { a, _ in a })
|
||||
}
|
||||
if let v = map["bindKeyboard"] { keyboardBindings = v }
|
||||
if let v = map["bindGamepad"] { gamepadBindings = v }
|
||||
if let v = map["bindMidi"] { midiBindings = v }
|
||||
|
||||
Reference in New Issue
Block a user