UPD: Allow setting outputRamp

This commit is contained in:
Robert Kossessa
2024-05-28 12:58:20 +02:00
parent a8af352a70
commit c6f8616555
3 changed files with 74 additions and 24 deletions

View File

@@ -37,20 +37,21 @@
<CommandList> <CommandList>
<CommandGroup> <CommandGroup>
<CommandItem <CommandItem
v-for="(actionType, key) in actionTypeOptions" v-for="(actionTypeOption, key) in actionTypeOptions"
:key="key" :key="key"
:value="actionType" :value="actionTypeOption"
@select=" @select="
() => { () => {
typeInputValue = key typeInputValue = key
open = false open = false
deviceStore.updateKeyActionParameter(actionIndex - 1, { type: key })
} }
" "
> >
{{ actionType.label }} {{ actionTypeOption.label }}
<Check <Check
:class=" :class="
cn('ml-auto h-4 w-4', typeInputValue === key ? 'opacity-100' : 'opacity-0') cn('ml-auto h-4 w-4', actionType === key ? 'opacity-100' : 'opacity-0')
" "
/> />
</CommandItem> </CommandItem>
@@ -103,7 +104,7 @@ import {
CommandItem, CommandItem,
CommandList CommandList
} from '@renderer/components/ui/command' } from '@renderer/components/ui/command'
import { ref } from 'vue' import { ref, computed } from 'vue'
import { cn } from '@renderer/lib/utils' import { cn } from '@renderer/lib/utils'
import SendKeyAction from '@renderer/components/config/actions/SendKeyAction.vue' import SendKeyAction from '@renderer/components/config/actions/SendKeyAction.vue'
import SendMidiCCAction from '@renderer/components/config/actions/SendMidiCCAction.vue' import SendMidiCCAction from '@renderer/components/config/actions/SendMidiCCAction.vue'
@@ -111,11 +112,14 @@ import ScrambleText from '@renderer/components/common/ScrambleText.vue'
import { ChevronsUpDown, Check, GripHorizontal, Trash2, X } from 'lucide-vue-next' import { ChevronsUpDown, Check, GripHorizontal, Trash2, X } from 'lucide-vue-next'
import { useElementSize } from '@vueuse/core' import { useElementSize } from '@vueuse/core'
import { Action } from '@renderer/deviceStore' import { Action } from '@renderer/deviceStore'
import { useDeviceStore } from '@renderer/deviceStore'
const deviceStore = useDeviceStore()
const props = defineProps({ const props = defineProps({
actionIndex: { actionIndex: {
type: Number, type: Number,
required: false required: true
}, },
action: { action: {
type: Object as () => Action, type: Object as () => Action,
@@ -125,7 +129,17 @@ const props = defineProps({
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 },
prev_profile: { label: 'Go to the Previous Profile', component: WIP },
profile: { label: 'Go to a specific Profile', component: WIP }
})
const actionType = computed(() => {
if (typeInputValue.value in actionTypeOptions.value) {
return actionTypeOptions.value[typeInputValue.value]
}
return null
}) })
const comboboxButton = ref(null) const comboboxButton = ref(null)

View File

@@ -4,20 +4,12 @@
:icon-component="AudioWaveform" :icon-component="AudioWaveform"
:show-toggle="true" :show-toggle="true"
> >
<SteppedSlider
v-model="feedbackStrength"
:label="$t('config_options.feedback_designer.haptic_response.feedback_strength')"
/>
<Separator />
<SteppedSlider
v-model="bounceBackStrength"
:label="$t('config_options.feedback_designer.haptic_response.bounce_back_strength')"
/>
<Separator />
<SteppedSlider <SteppedSlider
v-model="outputRampDampening" v-model="outputRampDampening"
:label="$t('config_options.feedback_designer.haptic_response.output_ramp_dampening')" :label="$t('config_options.feedback_designer.haptic_response.output_ramp_dampening')"
/> />
<Separator />
<WIP />
</ConfigSection> </ConfigSection>
<ConfigSection <ConfigSection
:title="$t('config_options.feedback_designer.auditory_response.title')" :title="$t('config_options.feedback_designer.auditory_response.title')"
@@ -50,7 +42,7 @@
<script setup> <script setup>
import { AudioLines, AudioWaveform, GaugeCircle } from 'lucide-vue-next' import { AudioLines, AudioWaveform, GaugeCircle } from 'lucide-vue-next'
import ConfigSection from '@renderer/components/common/ConfigSection.vue' import ConfigSection from '@renderer/components/common/ConfigSection.vue'
import { ref } from 'vue' import { ref, watch } from 'vue'
import TabSelect from '@renderer/components/common/TabSelect.vue' import TabSelect from '@renderer/components/common/TabSelect.vue'
import FdIcon from '@renderer/assets/icons/iconFineDetents.svg' import FdIcon from '@renderer/assets/icons/iconFineDetents.svg'
import CdIcon from '@renderer/assets/icons/iconCoarseDetents.svg' import CdIcon from '@renderer/assets/icons/iconCoarseDetents.svg'
@@ -59,6 +51,9 @@ import RcIcon from '@renderer/assets/icons/iconReturnToCenter.svg'
import SteppedSlider from '@renderer/components/common/SteppedSlider.vue' import SteppedSlider from '@renderer/components/common/SteppedSlider.vue'
import { Separator } from '@renderer/components/ui/separator' import { Separator } from '@renderer/components/ui/separator'
import WIP from '@renderer/components/WIP.vue' import WIP from '@renderer/components/WIP.vue'
import { useDeviceStore } from '@renderer/deviceStore'
const deviceStore = useDeviceStore()
const feedbackType = ref('fineDetents') // TODO: replace with actual value const feedbackType = ref('fineDetents') // TODO: replace with actual value
@@ -81,9 +76,14 @@ const feedbackTypeOptions = {
} }
} }
const feedbackStrength = ref(2) const outputRampValues = [0, 100, 200, 5000, 10000]
const bounceBackStrength = ref(2)
const outputRampDampening = ref(2) const index = outputRampValues.indexOf(deviceStore.activeValue?.haptic?.outputRamp)
const outputRampDampening = ref(index === -1 ? 2 : index)
watch(outputRampDampening, (value) => {
deviceStore.setHapticOutputRamp(outputRampValues[value])
})
const auditoryHapticLevel = ref(2) const auditoryHapticLevel = ref(2)
const auditoryMagnitude = ref(2) const auditoryMagnitude = ref(2)

View File

@@ -73,6 +73,9 @@ export interface HapticSettings {
endPos: number endPos: number
detentCount: number detentCount: number
vernier: number vernier: number
kxForce: number
outputRamp: number
detentStrength: number
} }
export interface DeviceSettings { export interface DeviceSettings {
@@ -107,6 +110,7 @@ interface UpdateData {
kd: number | undefined kd: number | undefined
ku: number | undefined ku: number | undefined
settings: DeviceSettings | undefined settings: DeviceSettings | undefined
error: string | undefined // TODO: Error messages have eventid 'update', change this once it's fixed
} }
const { nanoIpc } = window const { nanoIpc } = window
@@ -537,6 +541,34 @@ export const useDeviceStore = defineStore('device', {
) )
this.setDirtyState(true) this.setDirtyState(true)
} }
},
updateKeyActionParameter(index: number, updates: object, updateDevice: boolean = true) {
Object.assign(this.currentProfile!.keys[index], updates)
if (updateDevice) {
sendDebounced(
this.currentDeviceId!,
JSON.stringify({
profile: this.currentProfileName,
updates: { keys: this.currentProfile!.keys }
})
)
this.setDirtyState(true)
}
},
setHapticOutputRamp(value: number, updateDevice: boolean = true) {
this.currentProfile!.knob.forEach((v) => {
v.haptic.outputRamp = value
})
if (updateDevice) {
sendDebounced(
this.currentDeviceId!,
JSON.stringify({
profile: this.currentProfileName,
updates: { knob: this.currentProfile!.knob }
})
)
this.setDirtyState(true)
}
} }
} }
}) })
@@ -552,9 +584,13 @@ export const initializeDevices = () => {
// register event handlers // register event handlers
nanoIpc.on((eventid, deviceid, dataString) => { nanoIpc.on((eventid, deviceid, dataString) => {
//console.log('Received event', eventid, deviceid, dataString) //console.log('Received event', eventid, deviceid, dataString)
if (eventid === 'error') { if (eventid === 'error' || (eventid === 'update' && dataString.includes('error'))) {
messageCallbacks.forEach((callback) => callback('Error', dataString)) // TODO: Error messages have eventid 'update', change this once it's fixed
console.error('Error:', dataString) const data = JSON.parse(dataString) as UpdateData
if (data.error) {
messageCallbacks.forEach((callback) => callback('Error', data.error as string))
console.error('Error:', data.error)
}
} }
if (eventid === 'saved') { if (eventid === 'saved') {
deviceStore.setDirtyState(false) deviceStore.setDirtyState(false)