mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal,wpilib] Rename DriverStation constants to all caps
This commit is contained in:
@@ -138,7 +138,7 @@ class DataLogSender {
|
||||
wpi::log::StringLogEntry m_logOpMode;
|
||||
|
||||
bool m_logJoysticks;
|
||||
std::array<JoystickLogSender, DriverStation::kJoystickPorts> m_joysticks;
|
||||
std::array<JoystickLogSender, DriverStation::JOYSTICK_PORTS> m_joysticks;
|
||||
};
|
||||
|
||||
struct Instance {
|
||||
@@ -151,10 +151,10 @@ struct Instance {
|
||||
|
||||
// Joystick button rising/falling edge flags
|
||||
wpi::util::mutex buttonEdgeMutex;
|
||||
std::array<HAL_JoystickButtons, DriverStation::kJoystickPorts>
|
||||
std::array<HAL_JoystickButtons, DriverStation::JOYSTICK_PORTS>
|
||||
previousButtonStates;
|
||||
std::array<uint32_t, DriverStation::kJoystickPorts> joystickButtonsPressed;
|
||||
std::array<uint32_t, DriverStation::kJoystickPorts> joystickButtonsReleased;
|
||||
std::array<uint32_t, DriverStation::JOYSTICK_PORTS> joystickButtonsPressed;
|
||||
std::array<uint32_t, DriverStation::JOYSTICK_PORTS> joystickButtonsReleased;
|
||||
|
||||
bool silenceJoystickWarning = false;
|
||||
|
||||
@@ -212,7 +212,7 @@ Instance::Instance() {
|
||||
|
||||
// All joysticks should default to having zero axes, povs and buttons, so
|
||||
// uninitialized memory doesn't get sent to motor controllers.
|
||||
for (unsigned int i = 0; i < DriverStation::kJoystickPorts; i++) {
|
||||
for (unsigned int i = 0; i < DriverStation::JOYSTICK_PORTS; i++) {
|
||||
joystickButtonsPressed[i] = 0;
|
||||
joystickButtonsReleased[i] = 0;
|
||||
previousButtonStates[i].available = 0;
|
||||
@@ -227,7 +227,7 @@ Instance::~Instance() {
|
||||
}
|
||||
|
||||
bool DriverStation::GetStickButton(int stick, int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return false;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ bool DriverStation::GetStickButton(int stick, int button) {
|
||||
|
||||
std::optional<bool> DriverStation::GetStickButtonIfAvailable(int stick,
|
||||
int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return false;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ std::optional<bool> DriverStation::GetStickButtonIfAvailable(int stick,
|
||||
}
|
||||
|
||||
bool DriverStation::GetStickButtonPressed(int stick, int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return false;
|
||||
}
|
||||
@@ -307,7 +307,7 @@ bool DriverStation::GetStickButtonPressed(int stick, int button) {
|
||||
}
|
||||
|
||||
bool DriverStation::GetStickButtonReleased(int stick, int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return false;
|
||||
}
|
||||
@@ -338,11 +338,11 @@ bool DriverStation::GetStickButtonReleased(int stick, int button) {
|
||||
}
|
||||
|
||||
double DriverStation::GetStickAxis(int stick, int axis) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0.0;
|
||||
}
|
||||
if (axis < 0 || axis >= HAL_kMaxJoystickAxes) {
|
||||
if (axis < 0 || axis >= HAL_MAX_JOYSTICK_AXES) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "axis {} out of range", axis);
|
||||
return 0.0;
|
||||
}
|
||||
@@ -363,16 +363,16 @@ double DriverStation::GetStickAxis(int stick, int axis) {
|
||||
|
||||
DriverStation::TouchpadFinger DriverStation::GetStickTouchpadFinger(
|
||||
int stick, int touchpad, int finger) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return TouchpadFinger{false, 0.0f, 0.0f};
|
||||
}
|
||||
if (touchpad < 0 || touchpad >= HAL_kMaxJoystickTouchpads) {
|
||||
if (touchpad < 0 || touchpad >= HAL_MAX_JOYSTICK_TOUCHPADS) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "touchpad {} out of range",
|
||||
touchpad);
|
||||
return TouchpadFinger{false, 0.0f, 0.0f};
|
||||
}
|
||||
if (finger < 0 || finger >= HAL_kMaxJoystickTouchpadFingers) {
|
||||
if (finger < 0 || finger >= HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "finger {} out of range", finger);
|
||||
return TouchpadFinger{false, 0.0f, 0.0f};
|
||||
}
|
||||
@@ -399,16 +399,16 @@ DriverStation::TouchpadFinger DriverStation::GetStickTouchpadFinger(
|
||||
|
||||
bool DriverStation::GetStickTouchpadFingerAvailable(int stick, int touchpad,
|
||||
int finger) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return false;
|
||||
}
|
||||
if (touchpad < 0 || touchpad >= HAL_kMaxJoystickTouchpads) {
|
||||
if (touchpad < 0 || touchpad >= HAL_MAX_JOYSTICK_TOUCHPADS) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "touchpad {} out of range",
|
||||
touchpad);
|
||||
return false;
|
||||
}
|
||||
if (finger < 0 || finger >= HAL_kMaxJoystickTouchpadFingers) {
|
||||
if (finger < 0 || finger >= HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "finger {} out of range", finger);
|
||||
return false;
|
||||
}
|
||||
@@ -428,11 +428,11 @@ bool DriverStation::GetStickTouchpadFingerAvailable(int stick, int touchpad,
|
||||
|
||||
std::optional<double> DriverStation::GetStickAxisIfAvailable(int stick,
|
||||
int axis) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0.0;
|
||||
}
|
||||
if (axis < 0 || axis >= HAL_kMaxJoystickAxes) {
|
||||
if (axis < 0 || axis >= HAL_MAX_JOYSTICK_AXES) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "axis {} out of range", axis);
|
||||
return 0.0;
|
||||
}
|
||||
@@ -450,13 +450,13 @@ std::optional<double> DriverStation::GetStickAxisIfAvailable(int stick,
|
||||
}
|
||||
|
||||
DriverStation::POVDirection DriverStation::GetStickPOV(int stick, int pov) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return kCenter;
|
||||
return POVDirection::CENTER;
|
||||
}
|
||||
if (pov < 0 || pov >= HAL_kMaxJoystickPOVs) {
|
||||
if (pov < 0 || pov >= HAL_MAX_JOYSTICK_POVS) {
|
||||
WPILIB_ReportError(warn::BadJoystickAxis, "POV {} out of range", pov);
|
||||
return kCenter;
|
||||
return POVDirection::CENTER;
|
||||
}
|
||||
|
||||
uint16_t mask = 1 << pov;
|
||||
@@ -467,14 +467,14 @@ DriverStation::POVDirection DriverStation::GetStickPOV(int stick, int pov) {
|
||||
if ((povs.available & mask) == 0) {
|
||||
ReportJoystickWarning(stick, "Joystick POV {} on port {} not available",
|
||||
pov, stick);
|
||||
return kCenter;
|
||||
return POVDirection::CENTER;
|
||||
}
|
||||
|
||||
return static_cast<POVDirection>(povs.povs[pov]);
|
||||
}
|
||||
|
||||
uint64_t DriverStation::GetStickButtons(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ int DriverStation::GetStickAxesMaximumIndex(int stick) {
|
||||
}
|
||||
|
||||
int DriverStation::GetStickAxesAvailable(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ int DriverStation::GetStickPOVsMaximumIndex(int stick) {
|
||||
}
|
||||
|
||||
int DriverStation::GetStickPOVsAvailable(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ int DriverStation::GetStickButtonsMaximumIndex(int stick) {
|
||||
}
|
||||
|
||||
uint64_t DriverStation::GetStickButtonsAvailable(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ uint64_t DriverStation::GetStickButtonsAvailable(int stick) {
|
||||
}
|
||||
|
||||
bool DriverStation::GetJoystickIsGamepad(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return false;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ bool DriverStation::GetJoystickIsGamepad(int stick) {
|
||||
}
|
||||
|
||||
int DriverStation::GetJoystickGamepadType(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return -1;
|
||||
}
|
||||
@@ -558,7 +558,7 @@ int DriverStation::GetJoystickGamepadType(int stick) {
|
||||
}
|
||||
|
||||
int DriverStation::GetJoystickSupportedOutputs(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
return 0;
|
||||
}
|
||||
@@ -570,7 +570,7 @@ int DriverStation::GetJoystickSupportedOutputs(int stick) {
|
||||
}
|
||||
|
||||
std::string DriverStation::GetJoystickName(int stick) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
if (stick < 0 || stick >= JOYSTICK_PORTS) {
|
||||
WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
}
|
||||
|
||||
@@ -723,14 +723,14 @@ std::optional<DriverStation::Alliance> DriverStation::GetAlliance() {
|
||||
int32_t status = 0;
|
||||
auto allianceStationID = HAL_GetAllianceStation(&status);
|
||||
switch (allianceStationID) {
|
||||
case HAL_AllianceStationID_kRed1:
|
||||
case HAL_AllianceStationID_kRed2:
|
||||
case HAL_AllianceStationID_kRed3:
|
||||
return kRed;
|
||||
case HAL_AllianceStationID_kBlue1:
|
||||
case HAL_AllianceStationID_kBlue2:
|
||||
case HAL_AllianceStationID_kBlue3:
|
||||
return kBlue;
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
return Alliance::RED;
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
return Alliance::BLUE;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
@@ -740,14 +740,14 @@ std::optional<int> DriverStation::GetLocation() {
|
||||
int32_t status = 0;
|
||||
auto allianceStationID = HAL_GetAllianceStation(&status);
|
||||
switch (allianceStationID) {
|
||||
case HAL_AllianceStationID_kRed1:
|
||||
case HAL_AllianceStationID_kBlue1:
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
return 1;
|
||||
case HAL_AllianceStationID_kRed2:
|
||||
case HAL_AllianceStationID_kBlue2:
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
return 2;
|
||||
case HAL_AllianceStationID_kRed3:
|
||||
case HAL_AllianceStationID_kBlue3:
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
return 3;
|
||||
default:
|
||||
return {};
|
||||
@@ -781,7 +781,7 @@ void DriverStation::RefreshData() {
|
||||
HAL_JoystickButtons currentButtons;
|
||||
std::unique_lock lock(inst.buttonEdgeMutex);
|
||||
|
||||
for (int32_t i = 0; i < DriverStation::kJoystickPorts; i++) {
|
||||
for (int32_t i = 0; i < DriverStation::JOYSTICK_PORTS; i++) {
|
||||
HAL_GetJoystickButtons(i, ¤tButtons);
|
||||
|
||||
// If buttons weren't pressed and are now, set flags in m_buttonsPressed
|
||||
@@ -866,23 +866,23 @@ void SendMatchData() {
|
||||
bool isRedAlliance = false;
|
||||
int stationNumber = 1;
|
||||
switch (alliance) {
|
||||
case HAL_AllianceStationID::HAL_AllianceStationID_kBlue1:
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
isRedAlliance = false;
|
||||
stationNumber = 1;
|
||||
break;
|
||||
case HAL_AllianceStationID::HAL_AllianceStationID_kBlue2:
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
isRedAlliance = false;
|
||||
stationNumber = 2;
|
||||
break;
|
||||
case HAL_AllianceStationID::HAL_AllianceStationID_kBlue3:
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
isRedAlliance = false;
|
||||
stationNumber = 3;
|
||||
break;
|
||||
case HAL_AllianceStationID::HAL_AllianceStationID_kRed1:
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
isRedAlliance = true;
|
||||
stationNumber = 1;
|
||||
break;
|
||||
case HAL_AllianceStationID::HAL_AllianceStationID_kRed2:
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
isRedAlliance = true;
|
||||
stationNumber = 2;
|
||||
break;
|
||||
@@ -989,7 +989,7 @@ void JoystickLogSender::AppendButtons(HAL_JoystickButtons buttons,
|
||||
void JoystickLogSender::AppendPOVs(const HAL_JoystickPOVs& povs,
|
||||
uint64_t timestamp) {
|
||||
int count = availableToCount(povs.available);
|
||||
int64_t povsArr[HAL_kMaxJoystickPOVs];
|
||||
int64_t povsArr[HAL_MAX_JOYSTICK_POVS];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
povsArr[i] = povs.povs[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user