diff --git a/wpilibc/wpilibC++Devices/include/DriverStation.h b/wpilibc/wpilibC++Devices/include/DriverStation.h index 827a29f0fb..0397ca3260 100644 --- a/wpilibc/wpilibC++Devices/include/DriverStation.h +++ b/wpilibc/wpilibC++Devices/include/DriverStation.h @@ -34,6 +34,7 @@ public: float GetStickAxis(uint32_t stick, uint32_t axis); int GetStickPOV(uint32_t stick, uint32_t pov); + uint32_t GetStickButtons(uint32_t stick); bool GetStickButton(uint32_t stick, uint8_t button); int GetStickAxisCount(uint32_t stick); diff --git a/wpilibc/wpilibC++Devices/src/DriverStation.cpp b/wpilibc/wpilibC++Devices/src/DriverStation.cpp index d39728f7a9..457f9fb1ad 100644 --- a/wpilibc/wpilibC++Devices/src/DriverStation.cpp +++ b/wpilibc/wpilibC++Devices/src/DriverStation.cpp @@ -283,6 +283,24 @@ int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) { * @param stick The joystick to read. * @return The state of the buttons on the joystick. */ +uint32_t DriverStation::GetStickButtons(uint32_t stick) +{ + if (stick >= kJoystickPorts) + { + wpi_setWPIError(BadJoystickIndex); + return 0; + } + + return m_joystickButtons[stick].buttons; +} + +/** + * The state of one joystick button. Button indexes begin at 1. + * + * @param stick The joystick to read. + * @param button The button index, beginning at 1. + * @return The state of the joystick button. + */ bool DriverStation::GetStickButton(uint32_t stick, uint8_t button) { if (stick >= kJoystickPorts) diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index 870497e0fd..83bedadbfb 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -289,6 +289,21 @@ public class DriverStation implements RobotState.Interface { * @param stick The joystick to read. * @return The state of the buttons on the joystick. */ + public synchronized int getStickButtons(final int stick) { + if(stick < 0 || stick >= kJoystickPorts) { + throw new RuntimeException("Joystick index is out of range, should be 0-3"); + } + + return m_joystickButtons[stick].buttons; + } + + /** + * The state of one joystick button. Button indexes begin at 1. + * + * @param stick The joystick to read. + * @param button The button index, beginning at 1. + * @return The state of the joystick button. + */ public synchronized boolean getStickButton(final int stick, byte button) { if(stick < 0 || stick >= kJoystickPorts) { throw new RuntimeException("Joystick index is out of range, should be 0-3");