mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Fix joystick issues [artf3707]
Make axes and POVs 0-based like they are on the DS Correct default joystick axis numbers to be 0-based Fix array dimensions for joystick axis values Increase the number of joystick ports to the maximum 6 that the DS supports Change-Id: I16d0e6e636188cbdd9cd7bfa0453a62466a55093
This commit is contained in:
@@ -192,13 +192,13 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (axis < 1 || axis > m_joystickAxes[stick].count)
|
||||
if (axis >= m_joystickAxes[stick].count)
|
||||
{
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
int8_t value = m_joystickAxes[stick].axes[axis - 1];
|
||||
int8_t value = m_joystickAxes[stick].axes[axis];
|
||||
|
||||
if(value < 0)
|
||||
{
|
||||
@@ -222,13 +222,13 @@ int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pov < 1 || pov > m_joystickPOVs[stick].count)
|
||||
if (pov >= m_joystickPOVs[stick].count)
|
||||
{
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_joystickPOVs[stick].povs[pov - 1];
|
||||
return m_joystickPOVs[stick].povs[pov];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user