|
|
@ -55,7 +55,7 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC |
|
|
|
, _rgButtonValues(NULL) |
|
|
|
, _rgButtonValues(NULL) |
|
|
|
, _lastButtonBits(0) |
|
|
|
, _lastButtonBits(0) |
|
|
|
, _throttleMode(ThrottleModeCenterZero) |
|
|
|
, _throttleMode(ThrottleModeCenterZero) |
|
|
|
, _exponential(false) |
|
|
|
, _exponential(0) |
|
|
|
, _accumulator(false) |
|
|
|
, _accumulator(false) |
|
|
|
, _deadband(false) |
|
|
|
, _deadband(false) |
|
|
|
, _activeVehicle(NULL) |
|
|
|
, _activeVehicle(NULL) |
|
|
@ -109,7 +109,7 @@ void Joystick::_setDefaultCalibration(void) { |
|
|
|
_rgFunctionAxis[yawFunction] = 0; |
|
|
|
_rgFunctionAxis[yawFunction] = 0; |
|
|
|
_rgFunctionAxis[throttleFunction] = 1; |
|
|
|
_rgFunctionAxis[throttleFunction] = 1; |
|
|
|
|
|
|
|
|
|
|
|
_exponential = false; |
|
|
|
_exponential = 0; |
|
|
|
_accumulator = false; |
|
|
|
_accumulator = false; |
|
|
|
_deadband = false; |
|
|
|
_deadband = false; |
|
|
|
_throttleMode = ThrottleModeCenterZero; |
|
|
|
_throttleMode = ThrottleModeCenterZero; |
|
|
@ -162,7 +162,7 @@ void Joystick::_loadSettings(void) |
|
|
|
qCDebug(JoystickLog) << "_loadSettings " << _name; |
|
|
|
qCDebug(JoystickLog) << "_loadSettings " << _name; |
|
|
|
|
|
|
|
|
|
|
|
_calibrated = settings.value(_calibratedSettingsKey, false).toBool(); |
|
|
|
_calibrated = settings.value(_calibratedSettingsKey, false).toBool(); |
|
|
|
_exponential = settings.value(_exponentialSettingsKey, false).toBool(); |
|
|
|
_exponential = settings.value(_exponentialSettingsKey, 0).toFloat(); |
|
|
|
_accumulator = settings.value(_accumulatorSettingsKey, false).toBool(); |
|
|
|
_accumulator = settings.value(_accumulatorSettingsKey, false).toBool(); |
|
|
|
_deadband = settings.value(_deadbandSettingsKey, false).toBool(); |
|
|
|
_deadband = settings.value(_deadbandSettingsKey, false).toBool(); |
|
|
|
|
|
|
|
|
|
|
@ -443,16 +443,16 @@ void Joystick::run(void) |
|
|
|
yaw = std::max(-1.0f, std::min(tanf(asinf(yaw_limited)), 1.0f)); |
|
|
|
yaw = std::max(-1.0f, std::min(tanf(asinf(yaw_limited)), 1.0f)); |
|
|
|
throttle = std::max(-1.0f, std::min(tanf(asinf(throttle_limited)), 1.0f)); |
|
|
|
throttle = std::max(-1.0f, std::min(tanf(asinf(throttle_limited)), 1.0f)); |
|
|
|
|
|
|
|
|
|
|
|
if ( _exponential ) { |
|
|
|
if ( _exponential != 0 ) { |
|
|
|
// Exponential (0% to -50% range like most RC radios)
|
|
|
|
// Exponential (0% to -50% range like most RC radios)
|
|
|
|
// 0 for no exponential
|
|
|
|
// 0 for no exponential
|
|
|
|
// -0.5 for strong exponential
|
|
|
|
// -0.5 for strong exponential
|
|
|
|
float expo = -0.35f; |
|
|
|
//float expo = -0.35f;
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate new RPY with exponential applied
|
|
|
|
// Calculate new RPY with exponential applied
|
|
|
|
roll = -expo*powf(roll,3) + (1+expo)*roll; |
|
|
|
roll = -_exponential*powf(roll,3) + (1+_exponential)*roll; |
|
|
|
pitch = -expo*powf(pitch,3) + (1+expo)*pitch; |
|
|
|
pitch = -_exponential*powf(pitch,3) + (1+_exponential)*pitch; |
|
|
|
yaw = -expo*powf(yaw,3) + (1+expo)*yaw; |
|
|
|
yaw = -_exponential*powf(yaw,3) + (1+_exponential)*yaw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Adjust throttle to 0:1 range
|
|
|
|
// Adjust throttle to 0:1 range
|
|
|
@ -682,12 +682,12 @@ void Joystick::setThrottleMode(int mode) |
|
|
|
emit throttleModeChanged(_throttleMode); |
|
|
|
emit throttleModeChanged(_throttleMode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Joystick::exponential(void) |
|
|
|
float Joystick::exponential(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return _exponential; |
|
|
|
return _exponential; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Joystick::setExponential(bool expo) |
|
|
|
void Joystick::setExponential(float expo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_exponential = expo; |
|
|
|
_exponential = expo; |
|
|
|
|
|
|
|
|
|
|
|