UPD: Key mapping types
This commit is contained in:
@@ -47,7 +47,12 @@
|
|||||||
() => {
|
() => {
|
||||||
typeInputValue = key
|
typeInputValue = key
|
||||||
open = false
|
open = false
|
||||||
deviceStore.updateKeyActionParameter(actionIndex - 1, { type: key })
|
deviceStore.updateKeyActionParameter(
|
||||||
|
actionIndex - 1,
|
||||||
|
appStore.selectedKey,
|
||||||
|
trigger,
|
||||||
|
{ type: key }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -83,20 +88,26 @@
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Separator />
|
<template v-if="actionTypeOptions[typeInputValue]?.component">
|
||||||
<component
|
<Separator />
|
||||||
:is="
|
<component
|
||||||
actionTypeOptions[typeInputValue]?.component
|
:is="actionTypeOptions[typeInputValue]?.component"
|
||||||
? actionTypeOptions[typeInputValue]?.component
|
:action="action"
|
||||||
: WIP
|
@update="
|
||||||
"
|
(updates) =>
|
||||||
:action="action"
|
deviceStore.updateKeyActionParameter(
|
||||||
/>
|
actionIndex - 1,
|
||||||
|
appStore.selectedKey,
|
||||||
|
trigger,
|
||||||
|
updates
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import WIP from '@renderer/components/WIP.vue'
|
|
||||||
import { Popover, PopoverTrigger, PopoverContent } from '@renderer/components/ui/popover'
|
import { Popover, PopoverTrigger, PopoverContent } from '@renderer/components/ui/popover'
|
||||||
import { Button } from '@renderer/components/ui/button'
|
import { Button } from '@renderer/components/ui/button'
|
||||||
import { Separator } from '@renderer/components/ui/separator'
|
import { Separator } from '@renderer/components/ui/separator'
|
||||||
@@ -118,6 +129,7 @@ import { useElementSize } from '@vueuse/core'
|
|||||||
import { Action } from '@renderer/deviceStore'
|
import { Action } from '@renderer/deviceStore'
|
||||||
import { useDeviceStore } from '@renderer/deviceStore'
|
import { useDeviceStore } from '@renderer/deviceStore'
|
||||||
import { useAppStore } from '@renderer/appStore'
|
import { useAppStore } from '@renderer/appStore'
|
||||||
|
import SwitchProfileAction from './SwitchProfileAction.vue'
|
||||||
|
|
||||||
const deviceStore = useDeviceStore()
|
const deviceStore = useDeviceStore()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
@@ -132,15 +144,19 @@ const props = defineProps({
|
|||||||
action: {
|
action: {
|
||||||
type: Object as () => Action,
|
type: Object as () => Action,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
trigger: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const actionTypeOptions = ref({
|
const actionTypeOptions = ref({
|
||||||
key: { label: 'Press a Keyboard Key', component: SendKeyAction },
|
key: { label: 'Press a Keyboard Key', component: SendKeyAction },
|
||||||
midi: { label: 'Send a MIDI Control Change', component: SendMidiCCAction },
|
midi: { label: 'Send a MIDI Control Change', component: SendMidiCCAction },
|
||||||
next_profile: { label: 'Go to the Next Profile', component: WIP },
|
next_profile: { label: 'Go to the Next Profile', component: null },
|
||||||
prev_profile: { label: 'Go to the Previous Profile', component: WIP },
|
prev_profile: { label: 'Go to the Previous Profile', component: null },
|
||||||
profile: { label: 'Go to a specific Profile', component: WIP }
|
profile: { label: 'Go to a specific Profile', component: SwitchProfileAction }
|
||||||
})
|
})
|
||||||
|
|
||||||
const actionType = computed(() => {
|
const actionType = computed(() => {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<ActionCard
|
<ActionCard
|
||||||
:action-index="dragAction.index + 1"
|
:action-index="dragAction.index + 1"
|
||||||
:action="dragAction.element"
|
:action="dragAction.element"
|
||||||
|
:trigger="trigger"
|
||||||
@delete="$emit('delete', dragAction.index)"
|
@delete="$emit('delete', dragAction.index)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -40,6 +41,10 @@ defineProps({
|
|||||||
actions: {
|
actions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
trigger: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const dragOptions = ref({
|
const dragOptions = ref({
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex flex-col p-4">
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<div class="flex-1">
|
||||||
|
<span class="font-mono text-sm text-muted-foreground">Profile Name:</span>
|
||||||
|
<Input v-model="profileNameInput" class="my-2 uppercase" type="text" />
|
||||||
|
<!-- TODO: Make this a dropdown -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Action } from '@renderer/deviceStore'
|
||||||
|
import { ref, watch, nextTick } from 'vue'
|
||||||
|
import { Input } from '@renderer/components/ui/input'
|
||||||
|
|
||||||
|
const emit = defineEmits(['update'])
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
action: {
|
||||||
|
type: Object as () => Action,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const profileNameInput = ref(props.action.name)
|
||||||
|
|
||||||
|
watch(profileNameInput, (profileName) => {
|
||||||
|
nextTick(() => {
|
||||||
|
profileNameInput.value = profileName?.toUpperCase() || ''
|
||||||
|
})
|
||||||
|
emit('update', { name: profileNameInput.value })
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<ActionGroup
|
<ActionGroup
|
||||||
:actions="pressedActions"
|
:actions="pressedActions"
|
||||||
class="p-2"
|
class="p-2"
|
||||||
|
:trigger="0"
|
||||||
@add="deviceStore.addKeyAction(null, appStore.selectedKey, 0)"
|
@add="deviceStore.addKeyAction(null, appStore.selectedKey, 0)"
|
||||||
@delete="(index) => deviceStore.removeKeyAction(index, appStore.selectedKey, 0)"
|
@delete="(index) => deviceStore.removeKeyAction(index, appStore.selectedKey, 0)"
|
||||||
/>
|
/>
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
<ActionGroup
|
<ActionGroup
|
||||||
:actions="releasedActions"
|
:actions="releasedActions"
|
||||||
class="p-2"
|
class="p-2"
|
||||||
|
:trigger="1"
|
||||||
@add="deviceStore.addKeyAction(null, appStore.selectedKey, 1)"
|
@add="deviceStore.addKeyAction(null, appStore.selectedKey, 1)"
|
||||||
@delete="(index) => deviceStore.removeKeyAction(index, appStore.selectedKey, 1)"
|
@delete="(index) => deviceStore.removeKeyAction(index, appStore.selectedKey, 1)"
|
||||||
/>
|
/>
|
||||||
@@ -28,6 +30,7 @@
|
|||||||
<ActionGroup
|
<ActionGroup
|
||||||
:actions="heldActions"
|
:actions="heldActions"
|
||||||
class="p-2"
|
class="p-2"
|
||||||
|
:trigger="2"
|
||||||
@add="deviceStore.addKeyAction(null, appStore.selectedKey, 2)"
|
@add="deviceStore.addKeyAction(null, appStore.selectedKey, 2)"
|
||||||
@delete="(index) => deviceStore.removeKeyAction(index, appStore.selectedKey, 2)"
|
@delete="(index) => deviceStore.removeKeyAction(index, appStore.selectedKey, 2)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export interface Action {
|
|||||||
cc?: number
|
cc?: number
|
||||||
val?: number
|
val?: number
|
||||||
buttons?: number
|
buttons?: number
|
||||||
|
name?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Value {
|
export interface Value {
|
||||||
@@ -600,8 +601,21 @@ export const useDeviceStore = defineStore('device', {
|
|||||||
this.setDirtyState(true)
|
this.setDirtyState(true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateKeyActionParameter(index: number, updates: object, updateDevice: boolean = true) {
|
updateKeyActionParameter(
|
||||||
Object.assign(this.currentProfile!.keys[index], updates)
|
index: number,
|
||||||
|
key: string,
|
||||||
|
trigger: number,
|
||||||
|
updates: object,
|
||||||
|
updateDevice: boolean = true
|
||||||
|
) {
|
||||||
|
const keyIndex = this.keyLabels.indexOf(key)
|
||||||
|
if (trigger === 0) {
|
||||||
|
Object.assign(this.currentProfile!.keys[keyIndex].pressed![index], updates)
|
||||||
|
} else if (trigger === 1) {
|
||||||
|
Object.assign(this.currentProfile!.keys[keyIndex].released![index], updates)
|
||||||
|
} else if (trigger === 2) {
|
||||||
|
Object.assign(this.currentProfile!.keys[keyIndex].held![index], updates)
|
||||||
|
}
|
||||||
if (updateDevice) {
|
if (updateDevice) {
|
||||||
sendDebounced(
|
sendDebounced(
|
||||||
this.currentDeviceId!,
|
this.currentDeviceId!,
|
||||||
|
|||||||
Reference in New Issue
Block a user