|
|
@ -54,8 +54,6 @@ const char* JoystickConfigController::_imageRollRight = "joystickRollRight.p |
|
|
|
const char* JoystickConfigController::_imagePitchUp = "joystickPitchUp.png"; |
|
|
|
const char* JoystickConfigController::_imagePitchUp = "joystickPitchUp.png"; |
|
|
|
const char* JoystickConfigController::_imagePitchDown = "joystickPitchDown.png"; |
|
|
|
const char* JoystickConfigController::_imagePitchDown = "joystickPitchDown.png"; |
|
|
|
|
|
|
|
|
|
|
|
const char* JoystickConfigController::_settingsGroup = "Joysticks"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JoystickConfigController::JoystickConfigController(void) |
|
|
|
JoystickConfigController::JoystickConfigController(void) |
|
|
|
: _activeJoystick(NULL) |
|
|
|
: _activeJoystick(NULL) |
|
|
|
, _currentStep(-1) |
|
|
|
, _currentStep(-1) |
|
|
@ -71,21 +69,17 @@ JoystickConfigController::JoystickConfigController(void) |
|
|
|
connect(joystickManager, &JoystickManager::activeJoystickChanged, this, &JoystickConfigController::_activeJoystickChanged); |
|
|
|
connect(joystickManager, &JoystickManager::activeJoystickChanged, this, &JoystickConfigController::_activeJoystickChanged); |
|
|
|
|
|
|
|
|
|
|
|
_activeJoystickChanged(joystickManager->activeJoystick()); |
|
|
|
_activeJoystickChanged(joystickManager->activeJoystick()); |
|
|
|
_loadSettings(); |
|
|
|
|
|
|
|
_resetInternalCalibrationValues(); |
|
|
|
_resetInternalCalibrationValues(); |
|
|
|
_activeJoystick->startCalibrationMode(Joystick::CalibrationModeMonitor); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void JoystickConfigController::start(void) |
|
|
|
void JoystickConfigController::start(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_stopCalibration(); |
|
|
|
_stopCalibration(); |
|
|
|
_setInternalCalibrationValuesFromSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JoystickConfigController::~JoystickConfigController() |
|
|
|
JoystickConfigController::~JoystickConfigController() |
|
|
|
{ |
|
|
|
{ |
|
|
|
_activeJoystick->stopCalibrationMode(Joystick::CalibrationModeMonitor); |
|
|
|
_activeJoystick->stopCalibrationMode(Joystick::CalibrationModeMonitor); |
|
|
|
_storeSettings(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// @brief Returns the state machine entry for the specified state.
|
|
|
|
/// @brief Returns the state machine entry for the specified state.
|
|
|
@ -460,7 +454,7 @@ void JoystickConfigController::_setInternalCalibrationValuesFromSettings(void) |
|
|
|
info->axisMax = calibration.max; |
|
|
|
info->axisMax = calibration.max; |
|
|
|
info->reversed = calibration.reversed; |
|
|
|
info->reversed = calibration.reversed; |
|
|
|
|
|
|
|
|
|
|
|
qCDebug(JoystickConfigControllerLog) << "Read settings axis:min:max:trim:reversed" << axis << info->axisMin << info->axisMax << info->axisTrim << info->reversed; |
|
|
|
qCDebug(JoystickConfigControllerLog) << "Read settings name:axis:min:max:trim:reversed" << joystick->name() << axis << info->axisMin << info->axisMax << info->axisTrim << info->reversed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int function=0; function<Joystick::maxFunction; function++) { |
|
|
|
for (int function=0; function<Joystick::maxFunction; function++) { |
|
|
@ -484,30 +478,29 @@ void JoystickConfigController::_validateCalibration(void) |
|
|
|
if (chan < _axisCount) { |
|
|
|
if (chan < _axisCount) { |
|
|
|
// Validate Min/Max values. Although the axis appears as available we still may
|
|
|
|
// Validate Min/Max values. Although the axis appears as available we still may
|
|
|
|
// not have good min/max/trim values for it. Set to defaults if needed.
|
|
|
|
// not have good min/max/trim values for it. Set to defaults if needed.
|
|
|
|
if (info->axisMin > _calValidMinValue || info->axisMax < _calValidMaxValue) { |
|
|
|
if (info->axisMin < _calValidMinValue || info->axisMax > _calValidMaxValue) { |
|
|
|
qCDebug(JoystickConfigControllerLog) << "_validateCalibration resetting axis" << chan; |
|
|
|
qCDebug(JoystickConfigControllerLog) << "_validateCalibration resetting axis" << chan; |
|
|
|
info->axisMin = _calDefaultMinValue; |
|
|
|
info->axisMin = _calDefaultMinValue; |
|
|
|
info->axisMax = _calDefaultMaxValue; |
|
|
|
info->axisMax = _calDefaultMaxValue; |
|
|
|
info->axisTrim = info->axisMin + ((info->axisMax - info->axisMin) / 2); |
|
|
|
info->axisTrim = info->axisMin + ((info->axisMax - info->axisMin) / 2); |
|
|
|
} else { |
|
|
|
} |
|
|
|
switch (_rgAxisInfo[chan].function) { |
|
|
|
|
|
|
|
case Joystick::throttleFunction: |
|
|
|
switch (_rgAxisInfo[chan].function) { |
|
|
|
case Joystick::yawFunction: |
|
|
|
case Joystick::throttleFunction: |
|
|
|
case Joystick::rollFunction: |
|
|
|
case Joystick::yawFunction: |
|
|
|
case Joystick::pitchFunction: |
|
|
|
case Joystick::rollFunction: |
|
|
|
// Make sure trim is within min/max
|
|
|
|
case Joystick::pitchFunction: |
|
|
|
if (info->axisTrim < info->axisMin) { |
|
|
|
// Make sure trim is within min/max
|
|
|
|
info->axisTrim = info->axisMin; |
|
|
|
if (info->axisTrim < info->axisMin) { |
|
|
|
} else if (info->axisTrim > info->axisMax) { |
|
|
|
info->axisTrim = info->axisMin; |
|
|
|
info->axisTrim = info->axisMax; |
|
|
|
} else if (info->axisTrim > info->axisMax) { |
|
|
|
} |
|
|
|
info->axisTrim = info->axisMax; |
|
|
|
break; |
|
|
|
} |
|
|
|
default: |
|
|
|
break; |
|
|
|
// Non-attitude control axiss have calculated trim
|
|
|
|
default: |
|
|
|
info->axisTrim = info->axisMin + ((info->axisMax - info->axisMin) / 2); |
|
|
|
// Non-attitude control axis have calculated trim
|
|
|
|
break; |
|
|
|
info->axisTrim = info->axisMin + ((info->axisMax - info->axisMin) / 2); |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Unavailable axiss are set to defaults
|
|
|
|
// Unavailable axiss are set to defaults
|
|
|
@ -610,20 +603,6 @@ void JoystickConfigController::_calSave(void) |
|
|
|
_validateCalibration(); |
|
|
|
_validateCalibration(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void JoystickConfigController::_loadSettings(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void JoystickConfigController::_storeSettings(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void JoystickConfigController::_setHelpImage(const char* imageFile) |
|
|
|
void JoystickConfigController::_setHelpImage(const char* imageFile) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString file = _imageFilePrefix; |
|
|
|
QString file = _imageFilePrefix; |
|
|
@ -749,13 +728,20 @@ void JoystickConfigController::_signalAllAttiudeValueChanges(void) |
|
|
|
|
|
|
|
|
|
|
|
void JoystickConfigController::_activeJoystickChanged(Joystick* joystick) |
|
|
|
void JoystickConfigController::_activeJoystickChanged(Joystick* joystick) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
bool joystickTransition = false; |
|
|
|
|
|
|
|
|
|
|
|
if (_activeJoystick) { |
|
|
|
if (_activeJoystick) { |
|
|
|
|
|
|
|
joystickTransition = true; |
|
|
|
disconnect(_activeJoystick, &Joystick::rawAxisValueChanged, this, &JoystickConfigController::_axisValueChanged); |
|
|
|
disconnect(_activeJoystick, &Joystick::rawAxisValueChanged, this, &JoystickConfigController::_axisValueChanged); |
|
|
|
_activeJoystick = NULL; |
|
|
|
_activeJoystick = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (joystick) { |
|
|
|
if (joystick) { |
|
|
|
_activeJoystick = joystick; |
|
|
|
_activeJoystick = joystick; |
|
|
|
|
|
|
|
if (joystickTransition) { |
|
|
|
|
|
|
|
_stopCalibration(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_activeJoystick->startCalibrationMode(Joystick::CalibrationModeMonitor); |
|
|
|
connect(_activeJoystick, &Joystick::rawAxisValueChanged, this, &JoystickConfigController::_axisValueChanged); |
|
|
|
connect(_activeJoystick, &Joystick::rawAxisValueChanged, this, &JoystickConfigController::_axisValueChanged); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|