Skip to content

Commit

Permalink
auto change mod layout on press
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Dec 5, 2023
1 parent ece1e37 commit ef7335d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/views/ConfigurationJoystickView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,25 @@ const remapInput = async (joystick: Joystick, input: JoystickInput): Promise<voi
const currentButtonActions = computed(
() => controllerStore.protocolMapping.buttonsCorrespondencies[currentModifierKey.value.id as CockpitModifierKeyOption]
)
// Automatically change between modifier key tabs/layouts when they are pressed
watch(controllerStore.joysticks, () => {
if (currentJoystick.value === undefined) {
if (controllerStore.joysticks.size <= 0) return
currentJoystick.value = controllerStore.joysticks.entries().next().value[1]
}
const modifierKeysIds = Object.values(modifierKeyActions).map((v) => v.id)
const activeModKeys = Object.entries(currentButtonActions.value)
.filter((v) => currentJoystick.value?.state.buttons[Number(v[0]) as JoystickButton])
.map((v) => v[1].action)
.filter((v) => v.protocol === JoystickProtocol.CockpitModifierKey)
.filter((v) => modifierKeysIds.includes(v.id))
.filter((v) => v !== modifierKeyActions.regular)
if (activeModKeys.isEmpty() && currentModifierKey.value !== modifierKeyActions.regular) {
currentModifierKey.value = modifierKeyActions.regular
return
}
currentModifierKey.value = activeModKeys[0]
})
</script>

0 comments on commit ef7335d

Please sign in to comment.