Commit 56f7a034 authored by Nate Weibley's avatar Nate Weibley

Enable binding mode commands to joystick buttons

parent 41a81a78
...@@ -174,7 +174,7 @@ bool PX4FirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_m ...@@ -174,7 +174,7 @@ bool PX4FirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_m
int PX4FirmwarePlugin::manualControlReservedButtonCount(void) int PX4FirmwarePlugin::manualControlReservedButtonCount(void)
{ {
return 8; // 8 buttons reserved for rc switch simulation return 0; // 0 buttons reserved for rc switch simulation
} }
void PX4FirmwarePlugin::adjustMavlinkMessage(mavlink_message_t* message) void PX4FirmwarePlugin::adjustMavlinkMessage(mavlink_message_t* message)
......
...@@ -347,7 +347,9 @@ void Joystick::run(void) ...@@ -347,7 +347,9 @@ void Joystick::run(void)
} }
// Mark the button as pressed as long as its pressed // Mark the button as pressed as long as its pressed
buttonPressedBits |= buttonBit; if (buttonIndex < reservedButtonCount) {
buttonPressedBits |= buttonBit;
}
} }
} }
...@@ -461,6 +463,10 @@ QStringList Joystick::actions(void) ...@@ -461,6 +463,10 @@ QStringList Joystick::actions(void)
QStringList list; QStringList list;
list << "Arm" << "Disarm"; list << "Arm" << "Disarm";
if (_activeVehicle) {
list << _activeVehicle->flightModes();
}
return list; return list;
} }
...@@ -558,6 +564,8 @@ void Joystick::_buttonAction(const QString& action) ...@@ -558,6 +564,8 @@ void Joystick::_buttonAction(const QString& action)
_activeVehicle->setArmed(true); _activeVehicle->setArmed(true);
} else if (action == "Disarm") { } else if (action == "Disarm") {
_activeVehicle->setArmed(false); _activeVehicle->setArmed(false);
} else if (_activeVehicle->flightModes().contains(action)) {
_activeVehicle->setFlightMode(action);
} else { } else {
qCDebug(JoystickLog) << "_buttonAction unknown action:" << action; qCDebug(JoystickLog) << "_buttonAction unknown action:" << action;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment