Added C++ versions of the joystick query functions

Change-Id: I4acdb0a54493e633b2a7a9b265c3958a9ba163d1
This commit is contained in:
Brad Miller
2014-12-05 20:13:23 -05:00
parent 66622b43e7
commit b41690b387
4 changed files with 90 additions and 0 deletions

View File

@@ -144,6 +144,57 @@ void DriverStation::ReportJoystickUnpluggedError(std::string message) {
}
}
/** Returns the number of axis on a given joystick port
*
* @param stick The joystick port number
* @return the number of axis on the indicated joystick
*/
int DriverStation::GetStickAxisCount(uint32_t stick)
{
if (stick >= kJoystickPorts)
{
wpi_setWPIError(BadJoystickIndex);
return 0;
}
HALJoystickAxes joystickAxes;
HALGetJoystickAxes(stick, &joystickAxes);
return joystickAxes.count;
}
/** Returns the number of POVs on a given joystick port
*
* @param stick The joystick port number
* @return thenumber of POVs on the indicated joystick
*/
int DriverStation::GetStickPOVCount(uint32_t stick)
{
if (stick >= kJoystickPorts)
{
wpi_setWPIError(BadJoystickIndex);
return 0;
}
HALJoystickPOVs joystickPOVs;
HALGetJoystickPOVs(stick, &joystickPOVs);
return joystickPOVs.count;
}
/** Returns the number of buttons on a given joystick port
*
* @param stick The joystick port number
* @return The number of buttons on the indicated joystick
*/
int DriverStation::GetStickButtonCount(uint32_t stick)
{
if (stick >= kJoystickPorts)
{
wpi_setWPIError(BadJoystickIndex);
return 0;
}
HALJoystickButtons joystickButtons;
HALGetJoystickButtons(stick, &joystickButtons);
return joystickButtons.count;
}
/**
* Get the value of the axis on a joystick.
* This depends on the mapping of the joystick connected to the specified port.