mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Merge "Added C++ versions of the joystick query functions"
This commit is contained in:
@@ -36,6 +36,10 @@ public:
|
||||
int GetStickPOV(uint32_t stick, uint32_t pov);
|
||||
bool GetStickButton(uint32_t stick, uint8_t button);
|
||||
|
||||
int GetStickAxisCount(uint32_t stick);
|
||||
int GetStickPOVCount(uint32_t stick);
|
||||
int GetStickButtonCount(uint32_t stick);
|
||||
|
||||
bool IsEnabled();
|
||||
bool IsDisabled();
|
||||
bool IsAutonomous();
|
||||
|
||||
@@ -68,6 +68,10 @@ public:
|
||||
virtual float GetMagnitude();
|
||||
virtual float GetDirectionRadians();
|
||||
virtual float GetDirectionDegrees();
|
||||
|
||||
int GetAxisCount();
|
||||
int GetButtonCount();
|
||||
int GetPOVCount();
|
||||
|
||||
void SetRumble(RumbleType type, float value);
|
||||
void SetOutput(uint8_t outputNumber, bool value);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -262,6 +262,37 @@ bool Joystick::GetButton(ButtonType button)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of axis for a joystick
|
||||
*
|
||||
* @return the number of axis for the current joystick
|
||||
*/
|
||||
int Joystick::GetAxisCount()
|
||||
{
|
||||
return m_ds->GetStickAxisCount(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of axis for a joystick
|
||||
*
|
||||
* @return the number of buttons on the current joystick
|
||||
*/
|
||||
int Joystick::GetButtonCount()
|
||||
{
|
||||
return m_ds->GetStickButtonCount(m_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of axis for a joystick
|
||||
*
|
||||
* @return then umber of POVs for the current joystick
|
||||
*/
|
||||
int Joystick::GetPOVCount()
|
||||
{
|
||||
return m_ds->GetStickPOVCount(m_port);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the channel currently associated with the specified axis.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user