Changed joystick port numbers to be zero-based for C++ and Java.

Change-Id: Ifd55e8654be3b15abbe7460d2e9e6fff8acd9977
This commit is contained in:
Brad Miller
2014-10-01 11:25:51 -04:00
parent 7e2c68214d
commit 1cef27134e
11 changed files with 26 additions and 22 deletions

View File

@@ -224,15 +224,15 @@ public class DriverStation implements RobotState.Interface {
* @return The value of the axis on the joystick.
*/
public double getStickAxis(int stick, int axis) {
if(stick < 1 || stick > kJoystickPorts) {
throw new RuntimeException("Joystick index is out of range, should be 1-4");
if(stick < 0 || stick >= kJoystickPorts) {
throw new RuntimeException("Joystick index is out of range, should be 0-3");
}
if (axis < 1 || axis > kJoystickAxes) {
throw new RuntimeException("Joystick axis is out of range");
}
byte value = (byte)m_joystickAxes[stick - 1][axis - 1];
byte value = (byte)m_joystickAxes[stick][axis - 1];
if(value < 0) {
return value / 128.0;
@@ -249,11 +249,11 @@ public class DriverStation implements RobotState.Interface {
* @return The state of the buttons on the joystick.
*/
public int getStickButtons(final int stick) {
if(stick < 1 || stick > kJoystickPorts) {
throw new RuntimeException("Joystick index is out of range, should be 1-4");
if(stick < 0 || stick >= kJoystickPorts) {
throw new RuntimeException("Joystick index is out of range, should be 0-3");
}
return (int)m_joystickButtons[stick - 1];
return (int)m_joystickButtons[stick];
}
/**