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:
Thomas Clark
2014-10-22 11:16:39 -04:00
parent be30d3ab1d
commit a56c0eb4af
7 changed files with 24 additions and 24 deletions

View File

@@ -57,8 +57,8 @@ public class DriverStation implements RobotState.Interface {
private HALControlWord m_controlWord;
private HALAllianceStationID m_allianceStationID;
private short[][] m_joystickAxes = new short[FRCNetworkCommunicationsLibrary.kMaxJoystickAxes][kJoystickPorts];
private short[][] m_joystickPOVs = new short[FRCNetworkCommunicationsLibrary.kMaxJoystickPOVs][kJoystickPorts];
private short[][] m_joystickAxes = new short[kJoystickPorts][FRCNetworkCommunicationsLibrary.kMaxJoystickAxes];
private short[][] m_joystickPOVs = new short[kJoystickPorts][FRCNetworkCommunicationsLibrary.kMaxJoystickPOVs];
private int[] m_joystickButtons = new int[kJoystickPorts];
private Thread m_thread;
@@ -226,11 +226,11 @@ public class DriverStation implements RobotState.Interface {
throw new RuntimeException("Joystick index is out of range, should be 0-3");
}
if (axis < 1 || axis > m_joystickAxes[stick].length) {
if (axis < 0 || axis >= m_joystickAxes[stick].length) {
throw new RuntimeException("Joystick axis is out of range");
}
byte value = (byte)m_joystickAxes[stick][axis - 1];
byte value = (byte)m_joystickAxes[stick][axis];
if(value < 0) {
return value / 128.0;
@@ -249,11 +249,11 @@ public class DriverStation implements RobotState.Interface {
throw new RuntimeException("Joystick index is out of range, should be 0-3");
}
if (pov < 1 || pov > m_joystickPOVs[stick].length) {
if (pov < 0 || pov >= m_joystickPOVs[stick].length) {
throw new RuntimeException("Joystick POV is out of range");
}
return m_joystickPOVs[stick][pov - 1];
return m_joystickPOVs[stick][pov];
}
/**

View File

@@ -17,11 +17,11 @@ import edu.wpi.first.wpilibj.communication.UsageReporting;
*/
public class Joystick extends GenericHID {
static final byte kDefaultXAxis = 1;
static final byte kDefaultYAxis = 2;
static final byte kDefaultZAxis = 3;
static final byte kDefaultTwistAxis = 3;
static final byte kDefaultThrottleAxis = 4;
static final byte kDefaultXAxis = 0;
static final byte kDefaultYAxis = 1;
static final byte kDefaultZAxis = 2;
static final byte kDefaultTwistAxis = 2;
static final byte kDefaultThrottleAxis = 3;
static final int kDefaultTriggerButton = 1;
static final int kDefaultTopButton = 2;
@@ -198,7 +198,7 @@ public class Joystick extends GenericHID {
/**
* Get the value of the axis.
*
* @param axis The axis to read [1-6].
* @param axis The axis to read, starting at 0.
* @return The value of the axis.
*/
public double getRawAxis(final int axis) {