diff --git a/wpilibc/athena/include/Joystick.h b/wpilibc/athena/include/Joystick.h index 36d557a593..a7dfb40b12 100644 --- a/wpilibc/athena/include/Joystick.h +++ b/wpilibc/athena/include/Joystick.h @@ -96,7 +96,7 @@ class Joystick : public GenericHID, public ErrorBase { Joystick::HIDType GetType() const; std::string GetName() const; int GetPort() const; - int GetAxisType(uint8_t axis) const; + int GetAxisType(int axis) const; int GetAxisCount() const; int GetButtonCount() const; diff --git a/wpilibc/athena/src/Joystick.cpp b/wpilibc/athena/src/Joystick.cpp index 4d186827d9..8b93cb7ed1 100644 --- a/wpilibc/athena/src/Joystick.cpp +++ b/wpilibc/athena/src/Joystick.cpp @@ -284,10 +284,14 @@ std::string Joystick::GetName() const { return m_ds.GetJoystickName(m_port); } */ int Joystick::GetPort() const { return m_port; } -// int Joystick::GetAxisType(uint8_t axis) const -//{ -// return m_ds.GetJoystickAxisType(m_port, axis); -//} +/** + * Get the axis type of a joystick axis. + * + * @return the axis type of a joystick axis. + */ +int Joystick::GetAxisType(int axis) const { + return m_ds.GetJoystickAxisType(m_port, axis); +} /** * Get the number of axis for a joystick. diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java index d18c6a0843..885aa8072f 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java @@ -436,6 +436,25 @@ public class DriverStation implements RobotState.Interface { return retVal; } + /** + * Returns the types of Axes on a given joystick port. + * + * @param stick The joystick port number + * @param axis The target axis + * @return What type of axis the axis is reporting to be + */ + public int getJoystickAxisType(int stick, int axis) { + if (stick < 0 || stick >= kJoystickPorts) { + throw new RuntimeException("Joystick index is out of range, should be 0-5"); + } + + int retVal = -1; + synchronized (m_joystickMutex) { + retVal = HAL.getJoystickAxisType((byte) stick, (byte) axis); + } + return retVal; + } + /** * Gets a value indicating whether the Driver Station requires the robot to be enabled. * diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java index 2a77f8492f..f994b46a75 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java @@ -387,6 +387,15 @@ public class Joystick extends GenericHID { return m_port; } + /** + * Get the axis type of a joystick axis. + * + * @return the axis type of a joystick axis. + */ + public int getAxisType(int axis) { + return m_ds.getJoystickAxisType(m_port, axis); + } + /** * Set the rumble output for the joystick. The DS currently supports 2 rumble values, left rumble * and right rumble.