Commit cf1dde16 authored by Lorenz Meier's avatar Lorenz Meier

Fix button mask sent via manual control

parent d7fe2ad3
......@@ -293,7 +293,7 @@ void Joystick::run(void)
// Adjust throttle to 0:1 range
if (_throttleMode == ThrottleModeCenterZero) {
throttle = std::max(0.0f, throttle);
throttle = std::max(0.0f, throttle);
} else {
throttle = (throttle + 1.0f) / 2.0f;
}
......@@ -312,15 +312,14 @@ void Joystick::run(void)
for (int buttonIndex=0; buttonIndex<_buttonCount; buttonIndex++) {
quint16 buttonBit = 1 << buttonIndex;
if (_rgButtonValues[buttonIndex]) {
// Button pressed down, just record it
if (!_rgButtonValues[buttonIndex]) {
// Button up, just record it
newButtonBits |= buttonBit;
} else {
if (_lastButtonBits & buttonBit) {
// Button was down last time through, but is now up which indicates a button press
// Button was up last time through, but is now down which indicates a button press
qCDebug(JoystickLog) << "button triggered" << buttonIndex;
if (buttonIndex >= reservedButtonCount) {
// Button is above firmware reserved set
int buttonAction =_rgButtonActions[buttonIndex];
......@@ -328,13 +327,11 @@ void Joystick::run(void)
qCDebug(JoystickLog) << "buttonActionTriggered" << buttonAction;
emit buttonActionTriggered(buttonAction);
}
} else {
// Button is within firmware reserved set
// Record the button press for manualControl signal
buttonPressedBits |= buttonBit;
qCDebug(JoystickLog) << "button press recorded for manualControl" << buttonIndex;
}
}
// Mark the button as pressed as long as its pressed
buttonPressedBits |= buttonBit;
}
}
......
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