mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[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:
@@ -210,22 +210,54 @@ void DriverStationSim::SetJoystickPOV(int stick, int pov,
|
||||
HALSIM_SetJoystickPOV(stick, pov, static_cast<HAL_JoystickPOV>(value));
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickButtons(int stick, uint32_t buttons) {
|
||||
HALSIM_SetJoystickButtonsValue(stick, buttons);
|
||||
void DriverStationSim::SetJoystickAxesMaximumIndex(int stick,
|
||||
int maximumIndex) {
|
||||
SetJoystickAxesAvailable(stick, (1 << maximumIndex) - 1);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickAxisCount(int stick, int count) {
|
||||
HALSIM_SetJoystickAxisCount(stick, count);
|
||||
void DriverStationSim::SetJoystickAxesAvailable(int stick, int count) {
|
||||
HALSIM_SetJoystickAxesAvailable(stick, count);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickPOVCount(int stick, int count) {
|
||||
HALSIM_SetJoystickPOVCount(stick, count);
|
||||
void DriverStationSim::SetJoystickPOVsMaximumIndex(int stick,
|
||||
int maximumIndex) {
|
||||
SetJoystickPOVsAvailable(stick, (1 << maximumIndex) - 1);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickButtonCount(int stick, int count) {
|
||||
HALSIM_SetJoystickButtonCount(stick, count);
|
||||
void DriverStationSim::SetJoystickPOVsAvailable(int stick, int count) {
|
||||
HALSIM_SetJoystickPOVsAvailable(stick, count);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickButtonsMaximumIndex(int stick,
|
||||
int maximumIndex) {
|
||||
if (maximumIndex >= 64) {
|
||||
SetJoystickButtonsAvailable(stick, 0xFFFFFFFFFFFFFFFFL);
|
||||
} else {
|
||||
SetJoystickButtonsAvailable(stick, (1L << maximumIndex) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickButtonsAvailable(int stick,
|
||||
uint64_t available) {
|
||||
HALSIM_SetJoystickButtonsAvailable(stick, available);
|
||||
}
|
||||
|
||||
// void DriverStationSim::SetJoystickButtons(int stick, uint32_t buttons) {
|
||||
// HALSIM_SetJoystickButtonsValue(stick, buttons);
|
||||
// }
|
||||
|
||||
// void DriverStationSim::SetJoystickAxisCount(int stick, int count) {
|
||||
// HALSIM_SetJoystickAxisCount(stick, count);
|
||||
// }
|
||||
|
||||
// void DriverStationSim::SetJoystickPOVCount(int stick, int count) {
|
||||
// HALSIM_SetJoystickPOVCount(stick, count);
|
||||
// }
|
||||
|
||||
// void DriverStationSim::SetJoystickButtonCount(int stick, int count) {
|
||||
// HALSIM_SetJoystickButtonCount(stick, count);
|
||||
// }
|
||||
|
||||
void DriverStationSim::SetJoystickIsGamepad(int stick, bool isGamepad) {
|
||||
HALSIM_SetJoystickIsGamepad(stick, isGamepad);
|
||||
}
|
||||
@@ -239,10 +271,6 @@ void DriverStationSim::SetJoystickName(int stick, std::string_view name) {
|
||||
HALSIM_SetJoystickName(stick, &str);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickAxisType(int stick, int axis, int type) {
|
||||
HALSIM_SetJoystickAxisType(stick, axis, type);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetGameSpecificMessage(std::string_view message) {
|
||||
auto str = wpi::make_string(message);
|
||||
HALSIM_SetGameSpecificMessage(&str);
|
||||
|
||||
Reference in New Issue
Block a user