mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
DriverStation: fix error checking for GetXXXAxis and GetXXXPov (#1469)
Fixes #1436
This commit is contained in:
committed by
Peter Johnson
parent
dcbf02a1ec
commit
b64dfacff3
@@ -160,7 +160,7 @@ bool DriverStation::GetStickButtonReleased(int stick, int button) {
|
||||
wpi_setWPIError(BadJoystickIndex);
|
||||
return false;
|
||||
}
|
||||
if (button == 0) {
|
||||
if (button <= 0) {
|
||||
ReportJoystickUnpluggedError(
|
||||
"ERROR: Button indexes begin at 1 in WPILib for C++ and Java");
|
||||
return false;
|
||||
@@ -189,7 +189,7 @@ double DriverStation::GetStickAxis(int stick, int axis) {
|
||||
wpi_setWPIError(BadJoystickIndex);
|
||||
return 0.0;
|
||||
}
|
||||
if (axis >= HAL_kMaxJoystickAxes) {
|
||||
if (axis < 0 || axis >= HAL_kMaxJoystickAxes) {
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
return 0.0;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ int DriverStation::GetStickPOV(int stick, int pov) {
|
||||
wpi_setWPIError(BadJoystickIndex);
|
||||
return -1;
|
||||
}
|
||||
if (pov >= HAL_kMaxJoystickPOVs) {
|
||||
if (pov < 0 || pov >= HAL_kMaxJoystickPOVs) {
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ public class DriverStation {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (axis >= HAL.kMaxJoystickAxes) {
|
||||
if (axis < 0 || axis >= HAL.kMaxJoystickAxes) {
|
||||
throw new IllegalArgumentException("Joystick axis is out of range");
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ public class DriverStation {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
throw new IllegalArgumentException("Joystick index is out of range, should be 0-5");
|
||||
}
|
||||
if (pov >= HAL.kMaxJoystickPOVs) {
|
||||
if (pov < 0 || pov >= HAL.kMaxJoystickPOVs) {
|
||||
throw new IllegalArgumentException("Joystick POV is out of range");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user