ADD: Detent strength setting

This commit is contained in:
Robert Kossessa
2024-05-28 23:53:47 +02:00
parent 8913f7e1e8
commit b82e89f838
2 changed files with 58 additions and 7 deletions

View File

@@ -5,11 +5,36 @@
:show-toggle="true" :show-toggle="true"
> >
<SteppedSlider <SteppedSlider
v-model="outputRampDampening" v-model="feedbackStrength"
:label="$t('config_options.feedback_designer.haptic_response.output_ramp_dampening')" :max="feedbackStrengthValues.length - 1"
:named-positions="[
{
label: 'Min',
value: 0
},
{
label: 'Max',
value: feedbackStrengthValues.length - 1
}
]"
:label="$t('config_options.feedback_designer.haptic_response.feedback_strength')"
/> />
<Separator /> <Separator />
<WIP /> <SteppedSlider
v-model="outputRampDampening"
:max="outputRampValues.length - 1"
:named-positions="[
{
label: 'Min',
value: 0
},
{
label: 'Max',
value: outputRampValues.length - 1
}
]"
:label="$t('config_options.feedback_designer.haptic_response.output_ramp_dampening')"
/>
</ConfigSection> </ConfigSection>
<ConfigSection <ConfigSection
:title="$t('config_options.feedback_designer.auditory_response.title')" :title="$t('config_options.feedback_designer.auditory_response.title')"
@@ -76,13 +101,24 @@ const feedbackTypeOptions = {
} }
} }
const outputRampValues = [0, 100, 200, 5000, 10000] const outputRampValues = ref([5, 20, 50, 1000, 10000])
const index = outputRampValues.indexOf(deviceStore.activeValue?.haptic?.outputRamp) const outputRampIndex = outputRampValues.value.indexOf(deviceStore.activeValue?.haptic?.outputRamp)
const outputRampDampening = ref(index === -1 ? 2 : index) const outputRampDampening = ref(outputRampIndex === -1 ? 2 : outputRampIndex)
watch(outputRampDampening, (value) => { watch(outputRampDampening, (value) => {
deviceStore.setHapticOutputRamp(outputRampValues[value]) deviceStore.setHapticOutputRamp(outputRampValues.value[value])
})
const feedbackStrengthValues = ref([0, 2, 5, 7, 10])
const feedbackStrengthIndex = feedbackStrengthValues.value.indexOf(
deviceStore.activeValue?.haptic?.detentStrength
)
const feedbackStrength = ref(feedbackStrengthIndex === -1 ? 5 : feedbackStrengthIndex)
watch(feedbackStrength, (value) => {
deviceStore.setHapticFeedbackStrength(feedbackStrengthValues.value[value])
}) })
const auditoryHapticLevel = ref(2) const auditoryHapticLevel = ref(2)

View File

@@ -569,6 +569,21 @@ export const useDeviceStore = defineStore('device', {
) )
this.setDirtyState(true) this.setDirtyState(true)
} }
},
setHapticFeedbackStrength(value: number, updateDevice: boolean = true) {
this.currentProfile!.knob.forEach((v) => {
v.haptic.detentStrength = value
})
if (updateDevice) {
sendDebounced(
this.currentDeviceId!,
JSON.stringify({
profile: this.currentProfileName,
updates: { knob: this.currentProfile!.knob }
})
)
this.setDirtyState(true)
}
} }
} }
}) })