Skip to content

Commit 77ae20a

Browse files
joystick: Remove options to import/export mappings from/to vehicle
This is now done automatically by the settings syncer.
1 parent b9ff4b2 commit 77ae20a

File tree

2 files changed

+0
-71
lines changed

2 files changed

+0
-71
lines changed

src/stores/controller.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { allAvailableAxes, allAvailableButtons } from '@/libs/joystick/protocols
1818
import { modifierKeyActions, otherAvailableActions } from '@/libs/joystick/protocols/other'
1919
import { Alert, AlertLevel } from '@/types/alert'
2020
import {
21-
type GamepadToCockpitStdMapping,
2221
type JoystickProtocolActionsMapping,
2322
type JoystickState,
2423
type ProtocolAction,
@@ -269,36 +268,6 @@ export const useControllerStore = defineStore('controller', () => {
269268
reader.readAsText(e.target.files[0])
270269
}
271270

272-
const exportJoysticksMappingsToVehicle = async (
273-
vehicleAddress: string,
274-
joystickMappings: { [key in JoystickModel]: GamepadToCockpitStdMapping }
275-
): Promise<void> => {
276-
await setKeyDataOnCockpitVehicleStorage(vehicleAddress, cockpitStdMappingsKey, joystickMappings)
277-
Swal.fire({ icon: 'success', text: 'Joystick mapping exported to vehicle.', timer: 3000 })
278-
}
279-
280-
const importJoysticksMappingsFromVehicle = async (vehicleAddress: string): Promise<void> => {
281-
const newMapping = await getKeyDataFromCockpitVehicleStorage(vehicleAddress, cockpitStdMappingsKey)
282-
if (!newMapping) {
283-
Swal.fire({ icon: 'error', text: 'No joystick mappings to import from vehicle.', timer: 3000 })
284-
return
285-
}
286-
try {
287-
Object.values(newMapping).forEach((mapping) => {
288-
if (!mapping['name'] || !mapping['axes'] || !mapping['buttons']) {
289-
throw Error('Invalid joystick mapping inside vehicle.')
290-
}
291-
})
292-
} catch (error) {
293-
Swal.fire({ icon: 'error', text: `Could not import joystick mapping from vehicle. ${error}`, timer: 3000 })
294-
return
295-
}
296-
297-
// @ts-ignore: We check for the necessary fields in the if before
298-
cockpitStdMappings.value = newMapping
299-
Swal.fire({ icon: 'success', text: 'Joystick mapping imported from vehicle.', timer: 3000 })
300-
}
301-
302271
const exportFunctionsMapping = (protocolActionsMapping: JoystickProtocolActionsMapping): void => {
303272
const blob = new Blob([JSON.stringify(protocolActionsMapping)], { type: 'text/plain;charset=utf-8' })
304273
saveAs(blob, `cockpit-std-profile-joystick-${protocolActionsMapping.name}.json`)
@@ -394,8 +363,6 @@ export const useControllerStore = defineStore('controller', () => {
394363
loadProtocolMapping,
395364
exportJoystickMapping,
396365
importJoystickMapping,
397-
exportJoysticksMappingsToVehicle,
398-
importJoysticksMappingsFromVehicle,
399366
exportFunctionsMapping,
400367
importFunctionsMapping,
401368
exportFunctionsMappingToVehicle,

src/views/ConfigurationJoystickView.vue

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,6 @@
145145
/>
146146
Import from computer
147147
</label>
148-
<button
149-
class="p-2 m-1 font-medium border rounded-md text-uppercase"
150-
@click="
151-
controllerStore.exportJoysticksMappingsToVehicle(globalAddress, controllerStore.cockpitStdMappings)
152-
"
153-
>
154-
Export to vehicle
155-
</button>
156-
<button
157-
class="p-2 m-1 font-medium border rounded-md text-uppercase"
158-
@click="controllerStore.importJoysticksMappingsFromVehicle(globalAddress)"
159-
>
160-
Import from vehicle
161-
</button>
162148
</div>
163149
</div>
164150
<div class="flex flex-col items-center max-w-[30%] mb-4">
@@ -179,20 +165,6 @@
179165
/>
180166
Import from computer
181167
</label>
182-
<button
183-
class="p-2 m-1 font-medium border rounded-md text-uppercase"
184-
@click="
185-
controllerStore.exportFunctionsMappingToVehicle(globalAddress, controllerStore.protocolMappings)
186-
"
187-
>
188-
Export to vehicle
189-
</button>
190-
<button
191-
class="p-2 m-1 font-medium border rounded-md text-uppercase"
192-
@click="importFunctionsMappingFromVehicle"
193-
>
194-
Import from vehicle
195-
</button>
196168
</div>
197169
</div>
198170
</div>
@@ -338,7 +310,6 @@
338310

339311
<script setup lang="ts">
340312
import semver from 'semver'
341-
import Swal from 'sweetalert2'
342313
import { type Ref, computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
343314
344315
import Button from '@/components/Button.vue'
@@ -435,15 +406,6 @@ const setCurrentInputs = (joystick: Joystick, inputs: JoystickInput[]): void =>
435406
inputClickedDialog.value = true
436407
}
437408
438-
const importFunctionsMappingFromVehicle = async (): Promise<void> => {
439-
try {
440-
await controllerStore.importFunctionsMappingFromVehicle(globalAddress)
441-
Swal.fire({ icon: 'success', text: 'Joystick functions mappings imported from the vehicle.' })
442-
} catch (error) {
443-
Swal.fire({ icon: 'error', text: `${error}` })
444-
}
445-
}
446-
447409
/**
448410
* Remaps the input of a given joystick. The function waits for a button press on the joystick and then
449411
* updates the mapping to associate the joystick input with the pressed button. If no button is pressed

0 commit comments

Comments
 (0)