@@ -109,7 +109,7 @@ AssignedButtonAction::AssignedButtonAction(
109
109
{
110
110
}
111
111
112
- int16_t AssignedButtonAction::calculatePwm (Vehicle *vehicle, bool buttonDown)
112
+ int16_t AssignedButtonAction::calculatePwm (bool buttonDown)
113
113
{
114
114
if (!_isPwmOverrideAction) {
115
115
qCWarning (JoystickLog) << " send called on non-pwm action" ;
@@ -126,10 +126,7 @@ int16_t AssignedButtonAction::calculatePwm(Vehicle *vehicle, bool buttonDown)
126
126
}
127
127
pwmValue = _pwmLatchButtonDown ? _hiPwmValue : _loPwmValue;
128
128
}
129
-
130
129
qCDebug (JoystickLog) << " Calculated PWM Value " << pwmValue << " for action " << _action;
131
- // vehicle->rcChannelOverride(_pwmRcChannel, pwmValue);
132
-
133
130
return pwmValue;
134
131
}
135
132
@@ -626,12 +623,16 @@ void Joystick::_handleButtons()
626
623
if (!_buttonActionArray[buttonIndex]->repeat ()) {
627
624
// -- This button just went down
628
625
if (_rgButtonValues[buttonIndex] == BUTTON_DOWN) {
629
- // Check for a multi-button action
626
+ // Check for a multi-button action except for PWM actions.
627
+ // PWM buttons can produce different PWM values on same channel.
628
+ // Therefore low value must be the same for all buttons at the same channel.
630
629
QList<int > rgButtons = { buttonIndex };
631
630
bool executeButtonAction = true ;
632
631
for (int multiIndex = 0 ; multiIndex < _totalButtonCount; multiIndex++) {
633
632
if (multiIndex != buttonIndex) {
634
- if (_buttonActionArray[multiIndex] && _buttonActionArray[multiIndex]->action () == buttonAction) {
633
+ if (_buttonActionArray[multiIndex] && _buttonActionArray[multiIndex]->action () == buttonAction
634
+ && !_buttonActionArray[multiIndex]->isPwmOverrideAction ()) {
635
+ qCDebug (JoystickLog) << " Multi-button action:" << buttonAction;
635
636
// We found a multi-button action
636
637
if (_rgButtonValues[multiIndex] == BUTTON_DOWN || _rgButtonValues[multiIndex] == BUTTON_REPEAT) {
637
638
// So far so good
@@ -1390,7 +1391,7 @@ bool Joystick::_executeRcOverrideButtonAction(int buttonIndex, bool buttonDown)
1390
1391
{
1391
1392
if (_buttonActionArray[buttonIndex]) {
1392
1393
uint8_t channel = _buttonActionArray[buttonIndex]->rcChannel ();
1393
- auto pwm = _buttonActionArray[buttonIndex]->calculatePwm (_activeVehicle, buttonDown);
1394
+ auto pwm = _buttonActionArray[buttonIndex]->calculatePwm (buttonDown);
1394
1395
_rcOverride[channel-1 ] = pwm;
1395
1396
_rcOverrideActive = true ;
1396
1397
return true ;
0 commit comments