Master and secondary shift are now configurable

This commit is contained in:
patben8 committed 2026-11-03 23:35:44 +01:00
1 parent 5d4df2aa52
commit 632d2dc3c4
10 files changed
+133 -50

No files matched your search

+4 -2
View File
@@ -1522,7 +1522,7 @@ Two independent apps that talk over HTTP:
position jogs that wrap; `detectEncoding` guesses from what a control sent position jogs that wrap; `detectEncoding` guesses from what a control sent
while learning: relative REPEATS and jitters inside its zones, absolute while learning: relative REPEATS and jitters inside its zones, absolute
progresses), `actions.ts` (the vocabulary: deck buttons = the deck keys' progresses), `actions.ts` (the vocabulary: deck buttons = the deck keys'
actions, plus pitch, jog, jog touch, fast scrub, load, SYNC, keylock, actions, plus pitch, jog, jog touch, fast scrub, load, SYNC, MASTER, keylock,
loops; mixer; browse / tree; performance mode; `shiftDefault` = the loops; mixer; browse / tree; performance mode; `shiftDefault` = the
keyboard's Shift meaning), `mapping.ts` (per controller, keyed by SOURCE; keyboard's Shift meaning), `mapping.ts` (per controller, keyed by SOURCE;
each control a normal + a FREE Shift binding; learning REPLACES an each control a normal + a FREE Shift binding; learning REPLACES an
@@ -1535,7 +1535,9 @@ Two independent apps that talk over HTTP:
encoder wins only where it has an action for the layer. A CC learned for encoder wins only where it has an action for the layer. A CC learned for
a button waits 400 ms: one message, or any 0, = a button; several a button waits 400 ms: one message, or any 0, = a button; several
non-zero = a turn (so a two's-complement encoder's 127s are not a press). non-zero = a turn (so a two's-complement encoder's 127s are not a press).
**`router.ts`**: Shift is a learned control (an unbound Shift **`router.ts`**: Shift is a learned control — up to TWO per controller
(`Mapping.shifts`, many have one per deck; either held = the Shift layer;
the old single `shift` field still loads) (an unbound Shift
binding falls back to normal); deck B and the mixer act only in binding falls back to normal); deck B and the mixer act only in
performance mode; positions JUMP (no soft takeover — "the controller performance mode; positions JUMP (no soft takeover — "the controller
always wins"); a held control releases where it was pressed; Learn sees always wins"); a held control releases where it was pressed; Learn sees
+39 -26
View File
@@ -5,6 +5,7 @@ import { ENCODING_LABELS, ENCODINGS } from '../lib/midi/encoding'
import { import {
DEFAULT_JOG_SENSITIVITY, DEFAULT_JOG_SENSITIVITY,
DEFAULT_SCRUB_SPEED, DEFAULT_SCRUB_SPEED,
bindShift,
emptyMapping, emptyMapping,
sanitizeMapping, sanitizeMapping,
setBinding, setBinding,
@@ -24,8 +25,8 @@ import { Modal } from './Modal'
const section = 'text-[11px] font-semibold uppercase tracking-wider text-faint' const section = 'text-[11px] font-semibold uppercase tracking-wider text-faint'
const MAPPING_SUFFIX = '.konduktor-midi.json' const MAPPING_SUFFIX = '.konduktor-midi.json'
const sameTarget = (a: LearnTarget | null, b: LearnTarget) => const which = (t: LearnTarget) => ('layer' in t ? t.layer : t.slot)
a != null && a.action === b.action && ('layer' in a ? a.layer : null) === ('layer' in b ? b.layer : null) const sameTarget = (a: LearnTarget | null, b: LearnTarget) => a != null && a.action === b.action && which(a) === which(b)
/** /**
* Settings ▸ MIDI Controllers… (decided 2026-11-03): every controller is * Settings ▸ MIDI Controllers… (decided 2026-11-03): every controller is
@@ -169,7 +170,7 @@ export function MidiSettings({ onClose }: { onClose: () => void }) {
try { try {
const m = sanitizeMapping((await api.midiImport(path)).mapping) const m = sanitizeMapping((await api.midiImport(path)).mapping)
if (!m) throw new Error('That file is not a MIDI mapping') if (!m) throw new Error('That file is not a MIDI mapping')
if (Object.keys(mapping.bindings).length > 0 || mapping.shift) { if (Object.keys(mapping.bindings).length > 0 || mapping.shifts.some(Boolean)) {
const ok = await askConfirm({ const ok = await askConfirm({
title: `Replace ${port}'s mapping?`, title: `Replace ${port}'s mapping?`,
body: 'The imported mapping replaces every control learned on this controller.', body: 'The imported mapping replaces every control learned on this controller.',
@@ -253,29 +254,41 @@ export function MidiSettings({ onClose }: { onClose: () => void }) {
</div> </div>
{note && <div className={`text-xs ${note.error ? 'text-pink' : 'text-faint'}`}>{note.text}</div>} {note && <div className={`text-xs ${note.error ? 'text-pink' : 'text-faint'}`}>{note.text}</div>}
<div className="grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2"> <div className="grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2">
<span className="text-text">Shift button</span> {([0, 1] as const).map((slot) => {
<div className="flex items-center gap-2"> const src = mapping.shifts[slot]
{sameTarget(armed, { action: 'shift' }) ? ( const t: LearnTarget = { action: 'shift', slot }
<button onClick={() => armLearn(null)} className="animate-pulse rounded-md bg-accent/25 px-2 py-1 text-[11px] text-text ring-1 ring-accent"> return (
Press the controller's Shift… <div key={slot} className="contents">
</button> <span className="text-text">{slot === 0 ? 'Shift button' : 'Second Shift'}</span>
) : mapping.shift ? ( <div className="flex items-center gap-2">
<> {sameTarget(armed, t) ? (
<span className="rounded-md bg-ink-800 px-2 py-1 font-mono text-[10.5px] text-text">{describeSource(mapping.shift)}</span> <button onClick={() => armLearn(null)} className="animate-pulse rounded-md bg-accent/25 px-2 py-1 text-[11px] text-text ring-1 ring-accent">
<button onClick={() => learn({ action: 'shift' })} className="text-[11px] text-faint hover:text-text"> Press the controller's Shift…
Learn again </button>
</button> ) : src ? (
<button onClick={() => edit((m) => ({ ...m, shift: null }))} className="text-[11px] text-faint hover:text-pink"> <>
Clear <span className="rounded-md bg-ink-800 px-2 py-1 font-mono text-[10.5px] text-text">{describeSource(src)}</span>
</button> <button onClick={() => learn(t)} className="text-[11px] text-faint hover:text-text">
</> Learn again
) : ( </button>
<button onClick={() => learn({ action: 'shift' })} className="rounded-md px-2 py-1 text-[11px] text-faint hover:bg-ink-800 hover:text-text"> <button onClick={() => edit((m) => bindShift(m, null, slot))} className="text-[11px] text-faint hover:text-pink">
Learn Clear
</button> </button>
)} </>
<span className="text-[11px] text-faint">Hold it while moving a control to learn its Shift action.</span> ) : (
</div> <button onClick={() => learn(t)} className="rounded-md px-2 py-1 text-[11px] text-faint hover:bg-ink-800 hover:text-text">
Learn
</button>
)}
<span className="text-[11px] text-faint">
{slot === 0
? 'Hold it while moving a control to learn its Shift action.'
: 'Optional — many controllers have one per deck. Either one gives the Shift layer.'}
</span>
</div>
</div>
)
})}
<span className="text-text">Jog sensitivity</span> <span className="text-text">Jog sensitivity</span>
<Slider <Slider
value={mapping.jogSensitivity} value={mapping.jogSensitivity}
+4
View File
@@ -302,6 +302,10 @@ export function PrepStrip({
if (synced[id] || !syncBlocked(id)) toggleSync(id) if (synced[id] || !syncBlocked(id)) toggleSync(id)
else onError?.(syncBlocked(id)!) else onError?.(syncBlocked(id)!)
}, },
// As the on-screen MASTER button: performance mode, a track loaded.
makeMaster: () => {
if (performance && d.track) makeMaster(id)
},
toggleKeylock: () => d.setKeylock(!d.keylock), toggleKeylock: () => d.setKeylock(!d.keylock),
pitch: d.pitch, pitch: d.pitch,
setPitch: (v) => { setPitch: (v) => {
@@ -62,6 +62,7 @@ export function DeckTempo({ deck, master, synced, syncBlocked, onSync, onMaster,
SYNC SYNC
</button> </button>
<button <button
data-midi-action={`deck.${deck.channel}.master`}
onClick={onMaster} onClick={onMaster}
disabled={!track} disabled={!track}
aria-pressed={master} aria-pressed={master}
+1
View File
@@ -34,6 +34,7 @@ function deckActions(d: DeckId): ActionDef[] {
a('play', 'Play / pause'), a('play', 'Play / pause'),
a('cue', 'CUE', 'hold'), a('cue', 'CUE', 'hold'),
a('sync', 'SYNC'), a('sync', 'SYNC'),
a('master', 'Tempo MASTER'),
a('keylock', 'Keylock'), a('keylock', 'Keylock'),
a('pitch', 'Pitch fader', 'continuous'), a('pitch', 'Pitch fader', 'continuous'),
a('jog', 'Jog wheel', 'jog'), a('jog', 'Jog wheel', 'jog'),
+17 -3
View File
@@ -42,10 +42,24 @@ describe('mapping', () => {
it('the Shift control does nothing else', () => { it('the Shift control does nothing else', () => {
let m = bind(emptyMapping(), 'note:1:63', 'button', 'normal', 'deck.A.play') let m = bind(emptyMapping(), 'note:1:63', 'button', 'normal', 'deck.A.play')
m = bindShift(m, 'note:1:63') m = bindShift(m, 'note:1:63')
expect(m.shift).toBe('note:1:63') expect(m.shifts).toEqual(['note:1:63', null])
expect(m.bindings['note:1:63']).toBeUndefined() expect(m.bindings['note:1:63']).toBeUndefined()
m = bind(m, 'note:1:63', 'button', 'normal', 'deck.A.cue') m = bind(m, 'note:1:63', 'button', 'normal', 'deck.A.cue')
expect(m.shift).toBeNull() expect(m.shifts).toEqual([null, null])
})
it('two Shift controls, each in its own slot', () => {
let m = bindShift(emptyMapping(), 'note:1:63')
m = bindShift(m, 'note:2:63', 1)
expect(m.shifts).toEqual(['note:1:63', 'note:2:63'])
// Learning one into the other slot moves it, never doubles it.
m = bindShift(m, 'note:1:63', 1)
expect(m.shifts).toEqual([null, 'note:1:63'])
m = bindShift(m, null, 1)
expect(m.shifts).toEqual([null, null])
})
it("reads the single-Shift form mappings had before", () => {
expect(sanitizeMapping({ version: 1, shift: 'note:1:63', bindings: {} })?.shifts).toEqual(['note:1:63', null])
expect(sanitizeMapping({ version: 1, shifts: ['note:1:63', 'note:1:63'] })?.shifts).toEqual(['note:1:63', null])
}) })
it('the LSB half of a 14-bit pair reaches its MSB', () => { it('the LSB half of a 14-bit pair reaches its MSB', () => {
const m = bind(emptyMapping(), 'cc:1:0', 'abs14', 'normal', 'deck.A.pitch') const m = bind(emptyMapping(), 'cc:1:0', 'abs14', 'normal', 'deck.A.pitch')
@@ -73,7 +87,7 @@ describe('mapping', () => {
'nonsense': { encoding: 'button', normal: 'deck.A.play' }, 'nonsense': { encoding: 'button', normal: 'deck.A.play' },
}, },
}) })
expect(m?.shift).toBe('note:1:63') expect(m?.shifts).toEqual(['note:1:63', null])
expect(m?.jogSensitivity).toBe(10) expect(m?.jogSensitivity).toBe(10)
expect(Object.keys(m!.bindings)).toEqual(['note:1:0']) expect(Object.keys(m!.bindings)).toEqual(['note:1:0'])
expect(sanitizeMapping({ version: 2 })).toBeNull() expect(sanitizeMapping({ version: 2 })).toBeNull()
+25 -9
View File
@@ -19,8 +19,10 @@ export interface Binding {
export interface Mapping { export interface Mapping {
version: 1 version: 1
/** The control acting as Shift (itself a learned control). */ /** The controls acting as Shift (learned controls), up to two — many
shift: SourceKey | null * controllers have one per deck. Either held = the Shift layer. Slot order
* is only the editor's; a mapping from before two were allowed had `shift`. */
shifts: [SourceKey | null, SourceKey | null]
bindings: Record<SourceKey, Binding> bindings: Record<SourceKey, Binding>
/** Jog: scratch / nudge / scrub sensitivity (1 = the default feel). */ /** Jog: scratch / nudge / scrub sensitivity (1 = the default feel). */
jogSensitivity: number jogSensitivity: number
@@ -34,7 +36,7 @@ export const DEFAULT_JOG_SENSITIVITY = 1
export const DEFAULT_SCRUB_SPEED = 8 export const DEFAULT_SCRUB_SPEED = 8
export function emptyMapping(): Mapping { export function emptyMapping(): Mapping {
return { version: 1, shift: null, bindings: {}, jogSensitivity: DEFAULT_JOG_SENSITIVITY, scrubSpeed: DEFAULT_SCRUB_SPEED } return { version: 1, shifts: [null, null], bindings: {}, jogSensitivity: DEFAULT_JOG_SENSITIVITY, scrubSpeed: DEFAULT_SCRUB_SPEED }
} }
const num = (v: unknown, lo: number, hi: number, fallback: number) => const num = (v: unknown, lo: number, hi: number, fallback: number) =>
@@ -46,7 +48,10 @@ export function sanitizeMapping(raw: unknown): Mapping | null {
const r = raw as Record<string, unknown> const r = raw as Record<string, unknown>
if (r.version !== 1) return null if (r.version !== 1) return null
const out = emptyMapping() const out = emptyMapping()
if (typeof r.shift === 'string' && parseSource(r.shift)) out.shift = r.shift const shift = (v: unknown) => (typeof v === 'string' && parseSource(v) ? v : null)
if (Array.isArray(r.shifts)) out.shifts = [shift(r.shifts[0]), shift(r.shifts[1])]
else out.shifts = [shift(r.shift), null] // the single-Shift form
if (out.shifts[0] && out.shifts[0] === out.shifts[1]) out.shifts[1] = null
out.jogSensitivity = num(r.jogSensitivity, 0.05, 10, DEFAULT_JOG_SENSITIVITY) out.jogSensitivity = num(r.jogSensitivity, 0.05, 10, DEFAULT_JOG_SENSITIVITY)
out.scrubSpeed = num(r.scrubSpeed, 1, 64, DEFAULT_SCRUB_SPEED) out.scrubSpeed = num(r.scrubSpeed, 1, 64, DEFAULT_SCRUB_SPEED)
const bindings = r.bindings && typeof r.bindings === 'object' ? (r.bindings as Record<string, unknown>) : {} const bindings = r.bindings && typeof r.bindings === 'object' ? (r.bindings as Record<string, unknown>) : {}
@@ -116,14 +121,25 @@ export function bind(m: Mapping, source: SourceKey, encoding: Encoding, layer: L
const { base, dir } = splitSource(source) const { base, dir } = splitSource(source)
const other = dir && bindings[turnSource(base, dir === '+' ? '-' : '+')] const other = dir && bindings[turnSource(base, dir === '+' ? '-' : '+')]
if (dir && other) bindings[turnSource(base, dir === '+' ? '-' : '+')] = { ...other, encoding } if (dir && other) bindings[turnSource(base, dir === '+' ? '-' : '+')] = { ...other, encoding }
return { ...cleared, shift: cleared.shift === source ? null : cleared.shift, bindings } return { ...cleared, shifts: withoutShift(cleared.shifts, source), bindings }
} }
/** Make `source` the Shift control (it then does nothing else). */ const withoutShift = (s: Mapping['shifts'], source: SourceKey): Mapping['shifts'] => [
export function bindShift(m: Mapping, source: SourceKey): Mapping { s[0] === source ? null : s[0],
s[1] === source ? null : s[1],
]
/** Whether `source` is one of the mapping's Shift controls. */
export const isShift = (m: Mapping, source: SourceKey) => m.shifts[0] === source || m.shifts[1] === source
/** Make `source` Shift control `slot` (it then does nothing else; it leaves
* the other slot if it was there). `null` clears the slot. */
export function bindShift(m: Mapping, source: SourceKey | null, slot: 0 | 1 = 0): Mapping {
const bindings = { ...m.bindings } const bindings = { ...m.bindings }
delete bindings[source] const shifts = source ? withoutShift(m.shifts, source) : ([...m.shifts] as Mapping['shifts'])
return { ...m, shift: source, bindings } shifts[slot] = source
if (source) delete bindings[source]
return { ...m, shifts, bindings }
} }
export function setBinding(m: Mapping, source: SourceKey, patch: Partial<Binding>): Mapping { export function setBinding(m: Mapping, source: SourceKey, patch: Partial<Binding>): Mapping {
+22 -2
View File
@@ -29,6 +29,7 @@ function fakeDeck(): DeckMidi & { calls: string[] } {
loopOut: log('loopOut'), loopOut: log('loopOut'),
toggleLoop: log('toggleLoop'), toggleLoop: log('toggleLoop'),
toggleSync: log('sync'), toggleSync: log('sync'),
makeMaster: log('master'),
toggleKeylock: log('keylock'), toggleKeylock: log('keylock'),
setPitch: log('pitch'), setPitch: log('pitch'),
jogTouch: log('jogTouch'), jogTouch: log('jogTouch'),
@@ -72,6 +73,14 @@ beforeEach(() => {
}) })
describe('router', () => { describe('router', () => {
it('MASTER is a mappable button on each deck', () => {
map((m) => bind(m, 'note:2:20', 'button', 'normal', 'deck.B.master'))
router.receive(PORT, [0x91, 20, 127])
expect(B.calls).toEqual([]) // deck B: performance mode only
targets.performance = true
router.receive(PORT, [0x91, 20, 127])
expect(B.calls).toEqual(['master'])
})
it('runs a button on press only', () => { it('runs a button on press only', () => {
note(11, 127) note(11, 127)
note(11, 0) note(11, 0)
@@ -91,6 +100,17 @@ describe('router', () => {
note(0, 0) note(0, 0)
expect(A.calls).toEqual(['slotPress 0', 'slotRelease 0']) expect(A.calls).toEqual(['slotPress 0', 'slotRelease 0'])
}) })
it('with two Shift buttons, either one held gives the Shift layer', () => {
map((m) => bindShift(bindShift(bind(m, 'note:1:0', 'button', 'normal', 'deck.A.hotcue.1'), 'note:1:63', 0), 'note:2:63', 1))
router.receive(PORT, [0x91, 63, 127]) // the second Shift (deck B's side)
note(0, 127)
note(63, 127) // both held…
router.receive(PORT, [0x91, 63, 0]) // …one let go: still shifted
note(0, 127)
note(63, 0)
note(0, 127)
expect(A.calls).toEqual(['deleteSlot 0', 'deleteSlot 0', 'slotPress 0'])
})
it('an unbound Shift layer falls back to the normal action', () => { it('an unbound Shift layer falls back to the normal action', () => {
note(63, 127) note(63, 127)
note(11, 127) note(11, 127)
@@ -244,8 +264,8 @@ describe('learning', () => {
} }
}) })
it('the Shift control itself', () => { it('the Shift control itself', () => {
armLearn({ action: 'shift' }) armLearn({ action: 'shift', slot: 1 })
note(70, 127) note(70, 127)
expect(getMidiState().mappings[PORT].shift).toBe('note:1:70') expect(getMidiState().mappings[PORT].shifts).toEqual(['note:1:63', 'note:1:70'])
}) })
}) })
+19 -7
View File
@@ -14,7 +14,7 @@
import { actionDef, actionDeck, performanceOnly, type ActionKind, type DeckId } from './actions' import { actionDef, actionDeck, performanceOnly, type ActionKind, type DeckId } from './actions'
import { Decoder, detectEncoding, type Decoded, type Encoding, type LearnKind } from './encoding' import { Decoder, detectEncoding, type Decoded, type Encoding, type LearnKind } from './encoding'
import { bind, bindShift, resolveBinding, type Binding, type Layer, type Mapping } from './mapping' import { bind, bindShift, isShift, resolveBinding, type Binding, type Layer, type Mapping } from './mapping'
import { parseMessage, sourceKey, splitSource, turnSource, type MidiMessage, type SourceKey } from './messages' import { parseMessage, sourceKey, splitSource, turnSource, type MidiMessage, type SourceKey } from './messages'
import { armLearn, getMidiState, patchMidi, updateMapping, type LearnTarget } from './store' import { armLearn, getMidiState, patchMidi, updateMapping, type LearnTarget } from './store'
import type { Track } from '../../api' import type { Track } from '../../api'
@@ -29,6 +29,8 @@ export interface DeckMidi extends DeckShortcuts {
loopOut(): void loopOut(): void
toggleLoop(): void toggleLoop(): void
toggleSync(): void toggleSync(): void
/** Make this deck the tempo master (performance mode). */
makeMaster(): void
toggleKeylock(): void toggleKeylock(): void
/** The pitch fader, -1..1. */ /** The pitch fader, -1..1. */
pitch: number pitch: number
@@ -90,7 +92,8 @@ interface Capture {
} }
export class MidiRouter { export class MidiRouter {
private shiftHeld = new Map<string, boolean>() /** Per port, the Shift controls held now (two may be mapped). */
private shiftHeld = new Map<string, Set<SourceKey>>()
private decoders = new Map<string, Decoder>() private decoders = new Map<string, Decoder>()
private held = new Map<string, string>() private held = new Map<string, string>()
private capture: Capture | null = null private capture: Capture | null = null
@@ -120,8 +123,11 @@ export class MidiRouter {
const mapping = st.mappings[port] const mapping = st.mappings[port]
// Shift: tracked always, and never an action of its own. // Shift: tracked always, and never an action of its own.
if (mapping?.shift === key && !(st.armed?.action === 'shift')) { if (mapping && isShift(mapping, key) && !(st.armed?.action === 'shift')) {
this.shiftHeld.set(port, m.value > 0) const held = this.shiftHeld.get(port) ?? new Set<SourceKey>()
if (m.value > 0) held.add(key)
else held.delete(key)
this.shiftHeld.set(port, held)
return return
} }
if (st.armed) { if (st.armed) {
@@ -129,7 +135,7 @@ export class MidiRouter {
return return
} }
if (!mapping) return if (!mapping) return
const shift = !!this.shiftHeld.get(port) const shift = this.isShifted(port)
const hit = resolveBinding(mapping, key) const hit = resolveBinding(mapping, key)
// An encoder whose turns are bound by direction. The plain binding wins // An encoder whose turns are bound by direction. The plain binding wins
// where it has an action for this layer; else the turns do. // where it has an action for this layer; else the turns do.
@@ -188,6 +194,10 @@ export class MidiRouter {
} }
} }
private isShifted(port: string): boolean {
return (this.shiftHeld.get(port)?.size ?? 0) > 0
}
/** Forget held controls and decoder state (a controller unplugged). */ /** Forget held controls and decoder state (a controller unplugged). */
forget(port: string): void { forget(port: string): void {
this.shiftHeld.delete(port) this.shiftHeld.delete(port)
@@ -253,6 +263,8 @@ export class MidiRouter {
return deck.toggle() return deck.toggle()
case 'sync': case 'sync':
return deck.toggleSync() return deck.toggleSync()
case 'master':
return deck.makeMaster()
case 'keylock': case 'keylock':
return deck.toggleKeylock() return deck.toggleKeylock()
case 'jumpBack': case 'jumpBack':
@@ -318,7 +330,7 @@ export class MidiRouter {
let c = this.capture let c = this.capture
if (!c || c.target !== target) { if (!c || c.target !== target) {
if (c?.timer) clearTimeout(c.timer) if (c?.timer) clearTimeout(c.timer)
const layer: Layer = 'layer' in target ? (this.shiftHeld.get(port) ? 'shift' : target.layer) : 'normal' const layer: Layer = 'layer' in target ? (this.isShifted(port) ? 'shift' : target.layer) : 'normal'
c = this.capture = { target, kind, port: null, source: null, samples: [], layer, timer: null } c = this.capture = { target, kind, port: null, source: null, samples: [], layer, timer: null }
} }
if (c.port && c.port !== port) return // one controller at a time if (c.port && c.port !== port) return // one controller at a time
@@ -395,7 +407,7 @@ export class MidiRouter {
if (this.capture !== c) return if (this.capture !== c) return
this.capture = null this.capture = null
const t = c.target const t = c.target
if (t.action === 'shift') updateMapping(port, (m) => bindShift(m, source)) if ('slot' in t) updateMapping(port, (m) => bindShift(m, source, t.slot))
else { else {
updateMapping(port, (m) => bind(m, source, encoding, c.layer, t.action)) updateMapping(port, (m) => bind(m, source, encoding, c.layer, t.action))
patchMidi({ learned: { port, action: t.action, layer: c.layer, at: performance.now() } }) patchMidi({ learned: { port, action: t.action, layer: c.layer, at: performance.now() } })
+1 -1
View File
@@ -12,7 +12,7 @@ import { emptyMapping } from './mapping'
import type { SourceKey } from './messages' import type { SourceKey } from './messages'
/** What Learn is waiting for: an action in a layer, or the Shift control itself. */ /** What Learn is waiting for: an action in a layer, or the Shift control itself. */
export type LearnTarget = { action: string; layer: Layer } | { action: 'shift' } export type LearnTarget = { action: string; layer: Layer } | { action: 'shift'; slot: 0 | 1 }
export interface MidiState { export interface MidiState {
/** Whether this build can read MIDI at all (desktop app, or a Web MIDI browser). */ /** Whether this build can read MIDI at all (desktop app, or a Web MIDI browser). */