diff --git a/src/stores/controller.ts b/src/stores/controller.ts index 315dea7b0..e10525a9f 100644 --- a/src/stores/controller.ts +++ b/src/stores/controller.ts @@ -5,12 +5,10 @@ import { computed, ref } from 'vue' import { availableGamepadToCockpitMaps, cockpitStandardToProtocols } from '@/assets/joystick-profiles' import { useBlueOsStorage } from '@/composables/settingsSyncer' -import { getKeyDataFromCockpitVehicleStorage, setKeyDataOnCockpitVehicleStorage } from '@/libs/blueos' import { type JoystickEvent, EventType, joystickManager, JoystickModel } from '@/libs/joystick/manager' import { allAvailableAxes, allAvailableButtons } from '@/libs/joystick/protocols' import { modifierKeyActions, otherAvailableActions } from '@/libs/joystick/protocols/other' import { - type GamepadToCockpitStdMapping, type JoystickProtocolActionsMapping, type JoystickState, type ProtocolAction, @@ -187,36 +185,6 @@ export const useControllerStore = defineStore('controller', () => { reader.readAsText(e.target.files[0]) } - const exportJoysticksMappingsToVehicle = async ( - vehicleAddress: string, - joystickMappings: { [key in JoystickModel]: GamepadToCockpitStdMapping } - ): Promise => { - await setKeyDataOnCockpitVehicleStorage(vehicleAddress, cockpitStdMappingsKey, joystickMappings) - Swal.fire({ icon: 'success', text: 'Joystick mapping exported to vehicle.', timer: 3000 }) - } - - const importJoysticksMappingsFromVehicle = async (vehicleAddress: string): Promise => { - const newMapping = await getKeyDataFromCockpitVehicleStorage(vehicleAddress, cockpitStdMappingsKey) - if (!newMapping) { - Swal.fire({ icon: 'error', text: 'No joystick mappings to import from vehicle.', timer: 3000 }) - return - } - try { - Object.values(newMapping).forEach((mapping) => { - if (!mapping['name'] || !mapping['axes'] || !mapping['buttons']) { - throw Error('Invalid joystick mapping inside vehicle.') - } - }) - } catch (error) { - Swal.fire({ icon: 'error', text: `Could not import joystick mapping from vehicle. ${error}`, timer: 3000 }) - return - } - - // @ts-ignore: We check for the necessary fields in the if before - cockpitStdMappings.value = newMapping - Swal.fire({ icon: 'success', text: 'Joystick mapping imported from vehicle.', timer: 3000 }) - } - const exportFunctionsMapping = (protocolActionsMapping: JoystickProtocolActionsMapping): void => { const blob = new Blob([JSON.stringify(protocolActionsMapping)], { type: 'text/plain;charset=utf-8' }) saveAs(blob, `cockpit-std-profile-joystick-${protocolActionsMapping.name}.json`) @@ -242,29 +210,6 @@ export const useControllerStore = defineStore('controller', () => { reader.readAsText(e.target.files[0]) } - const exportFunctionsMappingToVehicle = async ( - vehicleAddress: string, - functionsMapping: JoystickProtocolActionsMapping[] - ): Promise => { - await setKeyDataOnCockpitVehicleStorage(vehicleAddress, protocolMappingsKey, functionsMapping) - Swal.fire({ icon: 'success', text: 'Joystick functions mapping exported to vehicle.', timer: 3000 }) - } - - const importFunctionsMappingFromVehicle = async (vehicleAddress: string): Promise => { - const newMappings = await getKeyDataFromCockpitVehicleStorage(vehicleAddress, protocolMappingsKey) - if (!newMappings) { - throw new Error('Could not import functions mapping from vehicle. No data available.') - } - - newMappings.forEach((mapping: JoystickProtocolActionsMapping) => { - if (!mapping || !mapping['name'] || !mapping['axesCorrespondencies'] || !mapping['buttonsCorrespondencies']) { - throw new Error('Could not import joystick funtions from vehicle. Invalid data.') - } - }) - // @ts-ignore: We check for the necessary fields in the if before - protocolMappings.value = newMappings - } - return { registerControllerUpdateCallback, enableForwarding, @@ -277,11 +222,7 @@ export const useControllerStore = defineStore('controller', () => { loadProtocolMapping, exportJoystickMapping, importJoystickMapping, - exportJoysticksMappingsToVehicle, - importJoysticksMappingsFromVehicle, exportFunctionsMapping, importFunctionsMapping, - exportFunctionsMappingToVehicle, - importFunctionsMappingFromVehicle, } }) diff --git a/src/views/ConfigurationJoystickView.vue b/src/views/ConfigurationJoystickView.vue index 3c3d051dc..44db9c964 100644 --- a/src/views/ConfigurationJoystickView.vue +++ b/src/views/ConfigurationJoystickView.vue @@ -126,20 +126,6 @@ /> Import from computer - -
@@ -160,20 +146,6 @@ /> Import from computer - -
@@ -284,7 +256,6 @@