From 72ff11f21c5fc7339df9064151db276e9de80de6 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Wed, 10 Jan 2024 18:38:09 -0300 Subject: [PATCH] mavlink-manual-control: Use already mapped functions slot backwards In the case all the button slots are already taken, we try to change the last button slots first, as in the case of vehicles with 32 buttons available, we prevent changing the first 16, which are usually used by other ground control stations, preventing clashs. --- src/libs/joystick/protocols/mavlink-manual-control.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/joystick/protocols/mavlink-manual-control.ts b/src/libs/joystick/protocols/mavlink-manual-control.ts index c82a6727a..60de7d3f0 100644 --- a/src/libs/joystick/protocols/mavlink-manual-control.ts +++ b/src/libs/joystick/protocols/mavlink-manual-control.ts @@ -565,7 +565,7 @@ export class MavlinkManualControlManager { } else { const mavlinkActionValue = this.vehicleButtonParameterTable.find((e) => e.title === actionId) if (mavlinkActionValue === undefined) return - this.vehicle?.setParameter({ id: unnecessaryVehicleRegularButtons[indexRegularButtonToUse].button, value: mavlinkActionValue.value }) + this.vehicle?.setParameter({ id: unnecessaryVehicleRegularButtons[unnecessaryVehicleRegularButtons.length - 1].button, value: mavlinkActionValue.value }) } indexRegularButtonToUse++ }) @@ -578,7 +578,7 @@ export class MavlinkManualControlManager { } else { const mavlinkActionValue = this.vehicleButtonParameterTable.find((e) => e.title === actionId) if (mavlinkActionValue === undefined) return - this.vehicle?.setParameter({ id: unnecessaryVehicleShiftButtons[indexShiftButtonToUse].button, value: mavlinkActionValue.value }) + this.vehicle?.setParameter({ id: unnecessaryVehicleShiftButtons[unnecessaryVehicleShiftButtons.length - 1].button, value: mavlinkActionValue.value }) } indexShiftButtonToUse++ })