mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Fix return value of DriverStation::GetJoystickAxisType() (#4230)
It was returning a pointer to the axis type array cast to a bool (always 1) instead of returning the desired axis type.
This commit is contained in:
@@ -456,11 +456,15 @@ int DriverStation::GetJoystickAxisType(int stick, int axis) {
|
||||
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return -1;
|
||||
}
|
||||
if (axis < 0 || axis >= HAL_kMaxJoystickAxes) {
|
||||
FRC_ReportError(warn::BadJoystickAxis, "axis {} out of range", axis);
|
||||
return -1;
|
||||
}
|
||||
|
||||
HAL_JoystickDescriptor descriptor;
|
||||
HAL_GetJoystickDescriptor(stick, &descriptor);
|
||||
|
||||
return static_cast<bool>(descriptor.axisTypes);
|
||||
return descriptor.axisTypes[axis];
|
||||
}
|
||||
|
||||
bool DriverStation::IsJoystickConnected(int stick) {
|
||||
|
||||
Reference in New Issue
Block a user