[hal,wpilib] Add Touchpad support (#8401)

This commit is contained in:
Thad House
2025-11-21 13:57:11 -08:00
committed by GitHub
parent 8546d301e3
commit 32fc543dc8
34 changed files with 1319 additions and 437 deletions

View File

@@ -72,6 +72,12 @@ class DriverStation final {
kUpLeft = HAL_JoystickPOV_kLeftUp,
};
struct TouchpadFinger final {
bool down = false;
float x = 0.0f;
float y = 0.0f;
};
/**
* Gets the angle of a POVDirection.
*
@@ -159,6 +165,28 @@ class DriverStation final {
*/
static double GetStickAxis(int stick, int axis);
/**
* Get the finger data of a touchpad on a joystick, if available.
*
* @param stick The joystick to read.
* @param touchpad The touchpad index to read from the joystick.
* @param finger The finger index to read from the touchpad.
* @return The finger data of the touchpad on the joystick.
*/
static TouchpadFinger GetStickTouchpadFinger(int stick, int touchpad,
int finger);
/**
* Whether a finger on a touchpad is available.
*
* @param stick The joystick to read.
* @param touchpad The touchpad index to read from the joystick.
* @param finger The finger index to read from the touchpad.
* @return True if the finger data is available.
*/
static bool GetStickTouchpadFingerAvailable(int stick, int touchpad,
int finger);
/**
* Get the value of the axis on a joystick, if available.
*

View File

@@ -370,6 +370,23 @@ class GenericHID {
*/
void SetRumble(RumbleType type, double value);
/**
* Check if a touchpad finger is available.
* @param touchpad The touchpad to check.
* @param finger The finger to check.
* @return true if the touchpad finger is available.
*/
bool GetTouchpadFingerAvailable(int touchpad, int finger) const;
/**
* Get the touchpad finger data.
* @param touchpad The touchpad to read.
* @param finger The finger to read.
* @return The touchpad finger data.
*/
DriverStation::TouchpadFinger GetTouchpadFinger(int touchpad,
int finger) const;
private:
int m_port;
uint16_t m_leftRumble = 0;