Commit f086840f authored by Bryant's avatar Bryant

Remove range limiting for joystick axes in preparation for moving that code into UASInterface.h.

parent f820eefc
...@@ -198,12 +198,7 @@ void JoystickInput::run() ...@@ -198,12 +198,7 @@ void JoystickInput::run()
axisValue = (axisValue - calibrationPositive[i]) / (calibrationNegative[i] - calibrationPositive[i]); axisValue = (axisValue - calibrationPositive[i]) / (calibrationNegative[i] - calibrationPositive[i]);
} }
axisValue = 1.0f - axisValue; axisValue = 1.0f - axisValue;
axisValue = axisValue * 2.0f - 1.0f;
// If the joystick isn't limited to [0:1.0], map it into [-1.0:1.0].
if (!joystickAxesRangeLimited[i])
{
axisValue = axisValue * 2.0f - 1.0f;
}
// Bound rounding errors // Bound rounding errors
if (axisValue > 1.0f) axisValue = 1.0f; if (axisValue > 1.0f) axisValue = 1.0f;
...@@ -281,7 +276,6 @@ void JoystickInput::setActiveJoystick(int id) ...@@ -281,7 +276,6 @@ void JoystickInput::setActiveJoystick(int id)
// Update cached joystick values // Update cached joystick values
joystickAxes.clear(); joystickAxes.clear();
joystickAxesInverted.clear(); joystickAxesInverted.clear();
joystickAxesRangeLimited.clear();
for (int i = 0; i < joystickNumAxes; i++) for (int i = 0; i < joystickNumAxes; i++)
{ {
int axisValue = SDL_JoystickGetAxis(joystick, i); int axisValue = SDL_JoystickGetAxis(joystick, i);
...@@ -289,7 +283,6 @@ void JoystickInput::setActiveJoystick(int id) ...@@ -289,7 +283,6 @@ void JoystickInput::setActiveJoystick(int id)
emit axisValueChanged(i, axisValue); emit axisValueChanged(i, axisValue);
joystickAxesInverted.append(false); joystickAxesInverted.append(false);
joystickAxesRangeLimited.append(false);
} }
joystickButtons = 0; joystickButtons = 0;
for (int i = 0; i < joystickNumButtons; i++) for (int i = 0; i < joystickNumButtons; i++)
...@@ -355,14 +348,6 @@ void JoystickInput::setAxisInversion(int axis, bool inverted) ...@@ -355,14 +348,6 @@ void JoystickInput::setAxisInversion(int axis, bool inverted)
} }
} }
void JoystickInput::setAxisRangeLimit(int axis, bool rangeLimited)
{
if (axis < joystickAxesRangeLimited.size())
{
joystickAxesRangeLimited[axis] = rangeLimited;
}
}
float JoystickInput::getCurrentValueForAxis(int axis) float JoystickInput::getCurrentValueForAxis(int axis)
{ {
if (axis < joystickAxes.size()) if (axis < joystickAxes.size())
......
...@@ -158,7 +158,6 @@ protected: ...@@ -158,7 +158,6 @@ protected:
QList<float> joystickAxes; ///< The values of every axes during the last sample. QList<float> joystickAxes; ///< The values of every axes during the last sample.
QList<bool> joystickAxesInverted; ///< Whether each axis should be used inverted from what was reported. QList<bool> joystickAxesInverted; ///< Whether each axis should be used inverted from what was reported.
QList<bool> joystickAxesRangeLimited; ///< Whether each axis should be scaled into [0:1.0] instead of [-1.0:1.0].
quint16 joystickButtons; ///< The state of every button. Bitfield supporting 16 buttons with 1s indicating that the button is down. quint16 joystickButtons; ///< The state of every button. Bitfield supporting 16 buttons with 1s indicating that the button is down.
int xHat, yHat; ///< The horizontal/vertical hat directions. Values are -1, 0, 1, with (-1,-1) indicating bottom-left. int xHat, yHat; ///< The horizontal/vertical hat directions. Values are -1, 0, 1, with (-1,-1) indicating bottom-left.
...@@ -233,12 +232,6 @@ public slots: ...@@ -233,12 +232,6 @@ public slots:
* @param inverted True indicates inverted from normal. Varies by controller. * @param inverted True indicates inverted from normal. Varies by controller.
*/ */
void setAxisInversion(int axis, bool inverted); void setAxisInversion(int axis, bool inverted);
/**
* @brief Specifies whether an axis should have its range limited to only positive values.
* @param axis The index of the axis to limit
* @param rangeLimited True if the axis should be limited, false otherwise.
*/
void setAxisRangeLimit(int axis, bool rangeLimited);
}; };
#endif // _JOYSTICKINPUT_H_ #endif // _JOYSTICKINPUT_H_
...@@ -9,11 +9,9 @@ JoystickAxis::JoystickAxis(int id, QWidget *parent) : ...@@ -9,11 +9,9 @@ JoystickAxis::JoystickAxis(int id, QWidget *parent) :
ui(new Ui::JoystickAxis) ui(new Ui::JoystickAxis)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->limitRangeCheckBox->hide(); // Hide the range checkbox by default. It's only activated by switching to the Throttle axis option.
ui->label->setText(QString::number(id)); ui->label->setText(QString::number(id));
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(mappingComboBoxChanged(int))); connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(mappingComboBoxChanged(int)));
connect(ui->invertedCheckBox, SIGNAL(clicked(bool)), this, SLOT(inversionCheckBoxChanged(bool))); connect(ui->invertedCheckBox, SIGNAL(clicked(bool)), this, SLOT(inversionCheckBoxChanged(bool)));
connect(ui->limitRangeCheckBox, SIGNAL(clicked(bool)), this, SLOT(limitRangeCheckBoxChanged(bool)));
} }
JoystickAxis::~JoystickAxis() JoystickAxis::~JoystickAxis()
...@@ -28,14 +26,6 @@ void JoystickAxis::setValue(float value) ...@@ -28,14 +26,6 @@ void JoystickAxis::setValue(float value)
void JoystickAxis::mappingComboBoxChanged(int newMapping) void JoystickAxis::mappingComboBoxChanged(int newMapping)
{ {
if (newMapping == JoystickInput::JOYSTICK_INPUT_MAPPING_THROTTLE)
{
ui->limitRangeCheckBox->show();
}
else
{
ui->limitRangeCheckBox->hide();
}
emit mappingChanged(id, (JoystickInput::JOYSTICK_INPUT_MAPPING)newMapping); emit mappingChanged(id, (JoystickInput::JOYSTICK_INPUT_MAPPING)newMapping);
} }
...@@ -43,16 +33,3 @@ void JoystickAxis::inversionCheckBoxChanged(bool inverted) ...@@ -43,16 +33,3 @@ void JoystickAxis::inversionCheckBoxChanged(bool inverted)
{ {
emit inversionChanged(id, inverted); emit inversionChanged(id, inverted);
} }
void JoystickAxis::limitRangeCheckBoxChanged(bool limited)
{
if (limited)
{
ui->progressBar->setRange(0, 100);
}
else
{
ui->progressBar->setRange(-100, 100);
}
emit rangeLimitChanged(id, limited);
}
...@@ -21,8 +21,6 @@ signals: ...@@ -21,8 +21,6 @@ signals:
void mappingChanged(int id, JoystickInput::JOYSTICK_INPUT_MAPPING newMapping); void mappingChanged(int id, JoystickInput::JOYSTICK_INPUT_MAPPING newMapping);
/** @brief Signal a change in this axis' inversion status */ /** @brief Signal a change in this axis' inversion status */
void inversionChanged(int id, bool); void inversionChanged(int id, bool);
/** @brief Signal a change in this axis' range limit */
void rangeLimitChanged(int id, bool);
public slots: public slots:
/** @brief Update the displayed value of the included progressbar. /** @brief Update the displayed value of the included progressbar.
...@@ -39,8 +37,6 @@ private slots: ...@@ -39,8 +37,6 @@ private slots:
void mappingComboBoxChanged(int newMapping); void mappingComboBoxChanged(int newMapping);
/** @brief Emit signal when the inversion checkbox is changed. */ /** @brief Emit signal when the inversion checkbox is changed. */
void inversionCheckBoxChanged(bool inverted); void inversionCheckBoxChanged(bool inverted);
/** @brief Emit signal when the limit range checkbox is changed. */
void limitRangeCheckBoxChanged(bool limited);
}; };
#endif // JOYSTICKAXIS_H #endif // JOYSTICKAXIS_H
...@@ -86,13 +86,6 @@ ...@@ -86,13 +86,6 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="limitRangeCheckBox">
<property name="text">
<string>Limit range</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QProgressBar" name="progressBar"> <widget class="QProgressBar" name="progressBar">
<property name="enabled"> <property name="enabled">
......
...@@ -125,7 +125,6 @@ void JoystickWidget::updateUIForJoystick(int id) ...@@ -125,7 +125,6 @@ void JoystickWidget::updateUIForJoystick(int id)
for (int i = 0; i < newButtons; i++) for (int i = 0; i < newButtons; i++)
{ {
JoystickButton* button = new JoystickButton(i, m_ui->buttonBox); JoystickButton* button = new JoystickButton(i, m_ui->buttonBox);
// And make sure we insert BEFORE the vertical spacer.
m_ui->buttonLayout->addWidget(button); m_ui->buttonLayout->addWidget(button);
buttons.append(button); buttons.append(button);
} }
...@@ -145,7 +144,6 @@ void JoystickWidget::updateUIForJoystick(int id) ...@@ -145,7 +144,6 @@ void JoystickWidget::updateUIForJoystick(int id)
axis->setValue(joystick->getCurrentValueForAxis(i)); axis->setValue(joystick->getCurrentValueForAxis(i));
connect(axis, SIGNAL(mappingChanged(int,JoystickInput::JOYSTICK_INPUT_MAPPING)), this->joystick, SLOT(setAxisMapping(int,JoystickInput::JOYSTICK_INPUT_MAPPING))); connect(axis, SIGNAL(mappingChanged(int,JoystickInput::JOYSTICK_INPUT_MAPPING)), this->joystick, SLOT(setAxisMapping(int,JoystickInput::JOYSTICK_INPUT_MAPPING)));
connect(axis, SIGNAL(inversionChanged(int,bool)), this->joystick, SLOT(setAxisInversion(int,bool))); connect(axis, SIGNAL(inversionChanged(int,bool)), this->joystick, SLOT(setAxisInversion(int,bool)));
connect(axis, SIGNAL(rangeLimitChanged(int,bool)), this->joystick, SLOT(setAxisRangeLimit(int,bool)));
m_ui->axesLayout->addWidget(axis); m_ui->axesLayout->addWidget(axis);
axes.append(axis); axes.append(axis);
} }
......
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