mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal,wpilib] Add support for joystick outputs (#8385)
Support joystick outputs, including Rumble and LEDs. Also requires an update to Joystick descriptors, as that has also changed in mrccomm to support showing what outputs are supported.
This commit is contained in:
@@ -180,20 +180,31 @@ void DriverStationSim::SetSendConsoleLine(bool shouldSend) {
|
||||
}
|
||||
}
|
||||
|
||||
int64_t DriverStationSim::GetJoystickOutputs(int stick) {
|
||||
int64_t outputs = 0;
|
||||
int32_t leftRumble;
|
||||
int32_t rightRumble;
|
||||
HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
|
||||
return outputs;
|
||||
int32_t DriverStationSim::GetJoystickLeds(int stick) {
|
||||
int32_t leds = 0;
|
||||
HALSIM_GetJoystickLeds(stick, &leds);
|
||||
return leds;
|
||||
}
|
||||
|
||||
int DriverStationSim::GetJoystickRumble(int stick, int rumbleNum) {
|
||||
int64_t outputs;
|
||||
int32_t leftRumble = 0;
|
||||
int32_t rightRumble = 0;
|
||||
HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
|
||||
return rumbleNum == 0 ? leftRumble : rightRumble;
|
||||
int32_t leftTriggerRumble = 0;
|
||||
int32_t rightTriggerRumble = 0;
|
||||
HALSIM_GetJoystickRumbles(stick, &leftRumble, &rightRumble,
|
||||
&leftTriggerRumble, &rightTriggerRumble);
|
||||
switch (rumbleNum) {
|
||||
case 0:
|
||||
return leftRumble;
|
||||
case 1:
|
||||
return rightRumble;
|
||||
case 2:
|
||||
return leftTriggerRumble;
|
||||
case 3:
|
||||
return rightTriggerRumble;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickButton(int stick, int button, bool state) {
|
||||
@@ -261,8 +272,13 @@ void DriverStationSim::SetJoystickIsGamepad(int stick, bool isGamepad) {
|
||||
HALSIM_SetJoystickIsGamepad(stick, isGamepad);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickType(int stick, int type) {
|
||||
HALSIM_SetJoystickType(stick, type);
|
||||
void DriverStationSim::SetJoystickGamepadType(int stick, int type) {
|
||||
HALSIM_SetJoystickGamepadType(stick, type);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickSupportedOutputs(int stick,
|
||||
int supportedOutputs) {
|
||||
HALSIM_SetJoystickSupportedOutputs(stick, supportedOutputs);
|
||||
}
|
||||
|
||||
void DriverStationSim::SetJoystickName(int stick, std::string_view name) {
|
||||
|
||||
Reference in New Issue
Block a user