Skip to content

Commit

Permalink
update layout automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Dec 5, 2023
1 parent 04fd165 commit e1a2420
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/views/ConfigurationJoystickView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
class="w-[95%] p-4 shadow-md rounded-2xl flex-centered flex-column position-relative"
>
<p class="text-xl font-semibold text-grey-darken-3">{{ joystick.model }} controller</p>
<div class="flex flex-col items-center justify-center w-full">
<div v-if="showJoystickLayout" class="flex flex-col items-center justify-center w-full">
<JoystickPS
class="w-[70%]"
:model="joystick.model"
Expand Down Expand Up @@ -112,6 +112,7 @@
<v-card-title class="flex justify-center w-full">Update mapping</v-card-title>
<v-card-text class="flex justify-between align-center">
<JoystickPS
v-if="showJoystickLayout"
class="w-[50%] p-6"
:model="currentJoystick.model"
:left-axis-horiz="currentJoystick.state.axes[0]"
Expand Down Expand Up @@ -218,7 +219,7 @@
currentButtonActions[input.id].action.protocol == action.protocol &&
currentButtonActions[input.id].action.id == action.id,
}"
@click="currentButtonActions[input.id].action = action"
@click="updateButtonAction(input, action)"
>
{{ action.name }}
</Button>
Expand Down Expand Up @@ -256,9 +257,11 @@ import {
JoystickButton,
JoystickButtonInput,
JoystickProtocol,
type ProtocolAction,
} from '@/types/joystick'
import BaseConfigurationView from './BaseConfigurationView.vue'
import { nextTick } from 'vue'
const controllerStore = useControllerStore()
Expand All @@ -278,7 +281,7 @@ const justRemappedInput = ref<boolean>()
const inputClickedDialog = ref(false)
const currentModifierKey = ref(modifierKeyActions.regular)
const availableModifierKeys = Object.values(modifierKeyActions)
const showJoystickLayout = ref(true)
watch(inputClickedDialog, () => (justRemappedInput.value = undefined))
const setCurrentInputs = (joystick: Joystick, inputs: JoystickInput[]): void => {
Expand Down Expand Up @@ -335,6 +338,12 @@ const currentButtonActions = computed(
() => controllerStore.protocolMapping.buttonsCorrespondencies[currentModifierKey.value.id as CockpitModifierKeyOption]
)
const updateButtonAction = (input: JoystickInput, action: ProtocolAction): void => {
controllerStore.protocolMapping.buttonsCorrespondencies[currentModifierKey.value.id as CockpitModifierKeyOption][input.id].action = action
showJoystickLayout.value = false
nextTick(() => (showJoystickLayout.value = true))
}
// Automatically change between modifier key tabs/layouts when they are pressed
watch(controllerStore.joysticks, () => {
if (currentJoystick.value === undefined) {
Expand Down

0 comments on commit e1a2420

Please sign in to comment.