Skip to content

Commit 9d76664

Browse files
joystick: Remove options to import/export mappings from/to vehicle
This is now done automatically by the settings syncer.
1 parent 2c7f1cb commit 9d76664

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
@@ -17,7 +17,6 @@ import { type JoystickEvent, EventType, joystickManager, JoystickModel } from '@
1717
import { allAvailableAxes, allAvailableButtons } from '@/libs/joystick/protocols'
1818
import { modifierKeyActions, otherAvailableActions } from '@/libs/joystick/protocols/other'
1919
import {
20-
type GamepadToCockpitStdMapping,
2120
type JoystickProtocolActionsMapping,
2221
type JoystickState,
2322
type ProtocolAction,
@@ -266,36 +265,6 @@ export const useControllerStore = defineStore('controller', () => {
266265
reader.readAsText(e.target.files[0])
267266
}
268267

269-
const exportJoysticksMappingsToVehicle = async (
270-
vehicleAddress: string,
271-
joystickMappings: { [key in JoystickModel]: GamepadToCockpitStdMapping }
272-
): Promise<void> => {
273-
await setKeyDataOnCockpitVehicleStorage(vehicleAddress, cockpitStdMappingsKey, joystickMappings)
274-
Swal.fire({ icon: 'success', text: 'Joystick mapping exported to vehicle.', timer: 3000 })
275-
}
276-
277-
const importJoysticksMappingsFromVehicle = async (vehicleAddress: string): Promise<void> => {
278-
const newMapping = await getKeyDataFromCockpitVehicleStorage(vehicleAddress, cockpitStdMappingsKey)
279-
if (!newMapping) {
280-
Swal.fire({ icon: 'error', text: 'No joystick mappings to import from vehicle.', timer: 3000 })
281-
return
282-
}
283-
try {
284-
Object.values(newMapping).forEach((mapping) => {
285-
if (!mapping['name'] || !mapping['axes'] || !mapping['buttons']) {
286-
throw Error('Invalid joystick mapping inside vehicle.')
287-
}
288-
})
289-
} catch (error) {
290-
Swal.fire({ icon: 'error', text: `Could not import joystick mapping from vehicle. ${error}`, timer: 3000 })
291-
return
292-
}
293-
294-
// @ts-ignore: We check for the necessary fields in the if before
295-
cockpitStdMappings.value = newMapping
296-
Swal.fire({ icon: 'success', text: 'Joystick mapping imported from vehicle.', timer: 3000 })
297-
}
298-
299268
const exportFunctionsMapping = (protocolActionsMapping: JoystickProtocolActionsMapping): void => {
300269
const blob = new Blob([JSON.stringify(protocolActionsMapping)], { type: 'text/plain;charset=utf-8' })
301270
saveAs(blob, `cockpit-std-profile-joystick-${protocolActionsMapping.name}.json`)
@@ -379,8 +348,6 @@ export const useControllerStore = defineStore('controller', () => {
379348
loadProtocolMapping,
380349
exportJoystickMapping,
381350
importJoystickMapping,
382-
exportJoysticksMappingsToVehicle,
383-
importJoysticksMappingsFromVehicle,
384351
exportFunctionsMapping,
385352
importFunctionsMapping,
386353
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)