[hal,wpilib] Use new DS available API from mrccomm (#8302)

Instead of just having a max count for joystick values, there's an available mask of values. This is because in the future we're expecting there to be holes in the list of available buttons and axes. This updates everything to support that scenario.

Also, Joystick buttons, axes, and POVs all now start at 0 instead of 1.
This commit is contained in:
Thad House
2025-10-25 23:03:50 -07:00
committed by GitHub
parent 429698f508
commit 2e10f91e07
62 changed files with 6101 additions and 1066 deletions

View File

@@ -109,20 +109,30 @@ class DriverStation final {
static constexpr int kJoystickPorts = 6;
/**
* The state of one joystick button. %Button indexes begin at 1.
* The state of one joystick button. Button indexes begin at 0.
*
* @param stick The joystick to read.
* @param button The button index, beginning at 1.
* @param button The button index, beginning at 0.
* @return The state of the joystick button.
*/
static bool GetStickButton(int stick, int button);
/**
* The state of one joystick button, only if available. Button indexes begin
* at 0.
*
* @param stick The joystick to read.
* @param button The button index, beginning at 0.
* @return The state of the joystick button, or empty if unavailable.
*/
static std::optional<bool> GetStickButtonIfAvailable(int stick, int button);
/**
* Whether one joystick button was pressed since the last check. %Button
* indexes begin at 1.
*
* @param stick The joystick to read.
* @param button The button index, beginning at 1.
* @param button The button index, beginning at 0.
* @return Whether the joystick button was pressed since the last check.
*/
static bool GetStickButtonPressed(int stick, int button);
@@ -132,7 +142,7 @@ class DriverStation final {
* indexes begin at 1.
*
* @param stick The joystick to read.
* @param button The button index, beginning at 1.
* @param button The button index, beginning at 0.
* @return Whether the joystick button was released since the last check.
*/
static bool GetStickButtonReleased(int stick, int button);
@@ -149,6 +159,18 @@ class DriverStation final {
*/
static double GetStickAxis(int stick, int axis);
/**
* Get the value of the axis on a joystick, if available.
*
* This depends on the mapping of the joystick connected to the specified
* port.
*
* @param stick The joystick to read.
* @param axis The analog axis value to read from the joystick.
* @return The value of the axis on the joystick, or empty if not available.
*/
static std::optional<double> GetStickAxisIfAvailable(int stick, int axis);
/**
* Get the state of a POV on the joystick.
*
@@ -162,31 +184,55 @@ class DriverStation final {
* @param stick The joystick to read.
* @return The state of the buttons on the joystick.
*/
static int GetStickButtons(int stick);
static uint64_t GetStickButtons(int stick);
/**
* Returns the number of axes on a given joystick port.
* Returns the maximum axis index on a given joystick port.
*
* @param stick The joystick port number
* @return The number of axes on the indicated joystick
* @return The maximum axis index on the indicated joystick
*/
static int GetStickAxisCount(int stick);
static int GetStickAxesMaximumIndex(int stick);
/**
* Returns the number of POVs on a given joystick port.
* Returns the mask of available axes on a given joystick port.
*
* @param stick The joystick port number
* @return The number of POVs on the indicated joystick
* @return The mask of available axes on the indicated joystick
*/
static int GetStickPOVCount(int stick);
static int GetStickAxesAvailable(int stick);
/**
* Returns the number of buttons on a given joystick port.
* Returns the maximum POV index on a given joystick port.
*
* @param stick The joystick port number
* @return The number of buttons on the indicated joystick
* @return The maximum POV index on the indicated joystick
*/
static int GetStickButtonCount(int stick);
static int GetStickPOVsMaximumIndex(int stick);
/**
* Returns the mask of available POVs on a given joystick port.
*
* @param stick The joystick port number
* @return The mask of available POVs on the indicated joystick
*/
static int GetStickPOVsAvailable(int stick);
/**
* Returns the maximum button index on a given joystick port.
*
* @param stick The joystick port number
* @return The maximum button index on the indicated joystick
*/
static int GetStickButtonsMaximumIndex(int stick);
/**
* Returns the mask of available buttons on a given joystick port.
*
* @param stick The joystick port number
* @return The mask of available buttons on the indicated joystick
*/
static uint64_t GetStickButtonsAvailable(int stick);
/**
* Returns a boolean indicating if the controller is an xbox controller.
@@ -212,15 +258,6 @@ class DriverStation final {
*/
static std::string GetJoystickName(int stick);
/**
* Returns the types of Axes on a given joystick port.
*
* @param stick The joystick port number and the target axis
* @param axis The analog axis value to read from the joystick.
* @return What type of axis the axis is reporting to be
*/
static int GetJoystickAxisType(int stick, int axis);
/**
* Returns if a joystick is connected to the Driver Station.
*