Add per-binding CC invert toggle
Each CC binding gains an "Invert" toggle in the mapping sheet (shown once the control is bound). Inverting swaps the sweep — CC 0 drives the control to its max, 127 to its min — so a single expression pedal can crossfade two controls: map both to the same CC and invert one. The MIDICCBinding.inverted field and applyCC already honored inversion; this adds isCCInverted / setCCInverted plus the sheet toggle, and the binding label now notes "· inverted". Test: an inverted binding reverses the mapped output. 321 green; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -176,6 +176,22 @@ public final class MIDIController {
|
||||
shoeGaze?.midiMap?.ccs.first { $0.target.addresses(target) }
|
||||
}
|
||||
|
||||
/// Whether the CC binding on a control is inverted (CC 0 → control max), or `false` if unbound.
|
||||
public func isCCInverted(for target: MIDIMap.CCTarget) -> Bool {
|
||||
ccBinding(for: target)?.inverted ?? false
|
||||
}
|
||||
|
||||
/// Sets the invert flag on the CC binding assigned to a control. Inverting swaps the sweep so a
|
||||
/// single expression pedal can crossfade — e.g. fade one control down as it moves, another up.
|
||||
public func setCCInverted(for target: MIDIMap.CCTarget, _ inverted: Bool) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap,
|
||||
let index: Int = map.ccs.firstIndex(where: { $0.target.addresses(target) }),
|
||||
map.ccs[index].inverted != inverted else { return }
|
||||
map.ccs[index].inverted = inverted
|
||||
shoeGaze.midiMap = map
|
||||
onMapChanged?()
|
||||
}
|
||||
|
||||
/// Removes any CC binding assigned to a control.
|
||||
public func clearCCBinding(for target: MIDIMap.CCTarget) {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap else { return }
|
||||
|
||||
Reference in New Issue
Block a user