mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2025-12-11 13:26:16 +00:00
feat: read full chord actions every time
feat: add special view for compound chords fix: make it possible to delete compound chords fixes #94
This commit is contained in:
@@ -48,9 +48,7 @@ export function deserializeActions(native: bigint): number[] {
|
||||
const actions = []
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const action = Number(native & 0x3ffn)
|
||||
if (action !== 0) {
|
||||
actions.push(action)
|
||||
}
|
||||
actions.push(action)
|
||||
native >>= 10n
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,19 @@
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
$: chordActions = chord?.actions.slice(chord.actions.lastIndexOf(0) + 1).toSorted(compare)
|
||||
$: compoundIndices = chord?.actions.slice(0, chord.actions.indexOf(0))
|
||||
|
||||
$: {
|
||||
console.log(chord?.actions, chordActions, compoundIndices)
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
class:deleted={chord && chord.deleted}
|
||||
class:edited={chord && chord.actionsChanged}
|
||||
class:invalid={chord && chord.actions.toSorted(compare).some((it, i) => chord?.actions[i] !== it)}
|
||||
class:invalid={chord && chordActions?.some((it, i) => chordActions?.[i] !== it)}
|
||||
class="chord"
|
||||
on:click={edit}
|
||||
on:keydown={keydown}
|
||||
@@ -82,7 +89,15 @@
|
||||
{:else if !editing && !chord}
|
||||
<span>{$LL.configure.chords.NEW_CHORD()}</span>
|
||||
{/if}
|
||||
<ActionString display="keys" actions={editing ? [...pressedKeys].sort(compare) : chord?.actions ?? []} />
|
||||
{#if !editing}
|
||||
{#each compoundIndices ?? [] as index}
|
||||
<sub>{index}</sub>
|
||||
{/each}
|
||||
{#if compoundIndices?.length}
|
||||
<span>→</span>
|
||||
{/if}
|
||||
{/if}
|
||||
<ActionString display="keys" actions={editing ? [...pressedKeys].sort(compare) : chordActions ?? []} />
|
||||
<button class="icon add" on:click|stopPropagation={addSpecial}>add_circle</button>
|
||||
<sup>•</sup>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user