diff --git a/src/views/ConfigurationJoystickView.vue b/src/views/ConfigurationJoystickView.vue index 42258d652..6bafe9a02 100644 --- a/src/views/ConfigurationJoystickView.vue +++ b/src/views/ConfigurationJoystickView.vue @@ -334,4 +334,25 @@ const remapInput = async (joystick: Joystick, input: JoystickInput): Promise 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] +})