Commit 96c080fb authored by Bryant's avatar Bryant

Moved the JOYSTICK_*_MAPPING enum into JoystickInput where it belongs. Also...

Moved the JOYSTICK_*_MAPPING enum into JoystickInput where it belongs. Also renamed some local variables.
parent cff4a3b5
...@@ -57,6 +57,19 @@ public: ...@@ -57,6 +57,19 @@ public:
void run(); void run();
void shutdown(); void shutdown();
/**
* @brief The JOYSTICK_INPUT_MAPPING enum storing the values for each item in the mapping combobox.
* This should match the order of items in the mapping combobox in JoystickAxis.ui.
*/
enum JOYSTICK_INPUT_MAPPING
{
JOYSTICK_INPUT_MAPPING_NONE = 0,
JOYSTICK_INPUT_MAPPING_YAW = 1,
JOYSTICK_INPUT_MAPPING_PITCH = 2,
JOYSTICK_INPUT_MAPPING_ROLL = 3,
JOYSTICK_INPUT_MAPPING_THROTTLE = 4
};
/** /**
* @brief Load joystick settings * @brief Load joystick settings
*/ */
...@@ -130,7 +143,7 @@ protected: ...@@ -130,7 +143,7 @@ protected:
bool done; bool done;
// Store the mapping between axis numbers and the roll/pitch/yaw/throttle configuration. // Store the mapping between axis numbers and the roll/pitch/yaw/throttle configuration.
// Value is one of JoystickAxis::JOYSTICK_AXIS_MAPPING. // Value is one of JoystickAxis::JOYSTICK_INPUT_MAPPING.
int rollAxis; int rollAxis;
int pitchAxis; int pitchAxis;
int yawAxis; int yawAxis;
...@@ -205,24 +218,24 @@ public slots: ...@@ -205,24 +218,24 @@ public slots:
/** @brief Switch to a new joystick by ID number. */ /** @brief Switch to a new joystick by ID number. */
void setActiveJoystick(int id); void setActiveJoystick(int id);
void setMappingRollAxis(int mapping) void setMappingRollAxis(int axis)
{ {
rollAxis = mapping; rollAxis = axis;
} }
void setMappingPitchAxis(int mapping) void setMappingPitchAxis(int axis)
{ {
pitchAxis = mapping; pitchAxis = axis;
} }
void setMappingYawAxis(int mapping) void setMappingYawAxis(int axis)
{ {
yawAxis = mapping; yawAxis = axis;
} }
void setMappingThrottleAxis(int mapping) void setMappingThrottleAxis(int axis)
{ {
throttleAxis = mapping; throttleAxis = axis;
} }
}; };
......
...@@ -15,19 +15,6 @@ public: ...@@ -15,19 +15,6 @@ public:
explicit JoystickAxis(int id, QWidget *parent = 0); explicit JoystickAxis(int id, QWidget *parent = 0);
~JoystickAxis(); ~JoystickAxis();
/**
* @brief The JOYSTICK_MAPPING enum storing the values for each item in the mapping combobox.
* This should match the order of items in the mapping combobox in JoystickAxis.ui.
*/
enum JOYSTICK_AXIS_MAPPING
{
JOYSTICK_AXIS_MAPPING_NONE = 0,
JOYSTICK_AXIS_MAPPING_YAW = 1,
JOYSTICK_AXIS_MAPPING_PITCH = 2,
JOYSTICK_AXIS_MAPPING_ROLL = 3,
JOYSTICK_AXIS_MAPPING_THROTTLE = 4
};
signals: signals:
/** @brief Signal a change in this axis' yaw/pitch/roll mapping */ /** @brief Signal a change in this axis' yaw/pitch/roll mapping */
void mappingChanged(int id, int newMapping); void mappingChanged(int id, int newMapping);
......
...@@ -151,20 +151,20 @@ void JoystickWidget::setHat(float x, float y) ...@@ -151,20 +151,20 @@ void JoystickWidget::setHat(float x, float y)
updateStatus(tr("Hat position: x: %1, y: %2").arg(x).arg(y)); updateStatus(tr("Hat position: x: %1, y: %2").arg(x).arg(y));
} }
void JoystickWidget::setMappingAxis(int axisID, int newMapping) void JoystickWidget::setMappingAxis(int axisID, JoystickInput::JOYSTICK_INPUT_MAPPING newMapping)
{ {
switch (newMapping) switch (newMapping)
{ {
case JoystickAxis::JOYSTICK_AXIS_MAPPING_ROLL: case JoystickInput::JOYSTICK_INPUT_MAPPING_ROLL:
joystick->setMappingRollAxis(axisID); joystick->setMappingRollAxis(axisID);
break; break;
case JoystickAxis::JOYSTICK_AXIS_MAPPING_PITCH: case JoystickInput::JOYSTICK_INPUT_MAPPING_PITCH:
joystick->setMappingPitchAxis(axisID); joystick->setMappingPitchAxis(axisID);
break; break;
case JoystickAxis::JOYSTICK_AXIS_MAPPING_YAW: case JoystickInput::JOYSTICK_INPUT_MAPPING_YAW:
joystick->setMappingYawAxis(axisID); joystick->setMappingYawAxis(axisID);
break; break;
case JoystickAxis::JOYSTICK_AXIS_MAPPING_THROTTLE: case JoystickInput::JOYSTICK_INPUT_MAPPING_THROTTLE:
joystick->setMappingThrottleAxis(axisID); joystick->setMappingThrottleAxis(axisID);
break; break;
} }
......
...@@ -81,7 +81,7 @@ protected slots: ...@@ -81,7 +81,7 @@ protected slots:
/** @brief Update the UI for a new joystick based on SDL ID. */ /** @brief Update the UI for a new joystick based on SDL ID. */
void updateUIForJoystick(int id); void updateUIForJoystick(int id);
/** @brief Change the stored mapping for a given axis. */ /** @brief Change the stored mapping for a given axis. */
void setMappingAxis(int axisID, int newMapping); void setMappingAxis(int axisID, JoystickInput::JOYSTICK_INPUT_MAPPING newMapping);
private: private:
Ui::JoystickWidget *m_ui; Ui::JoystickWidget *m_ui;
......
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