diff --git a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp index 207628cb2b..d37399bc94 100644 --- a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp @@ -426,7 +426,7 @@ void GlfwSystemJoystick::GetData(HALJoystickData* data, bool mapGamepad) const { // copy into HAL structures data->desc.isGamepad = m_isGamepad ? 1 : 0; - data->desc.gamepadType = m_isGamepad ? 21 : 20; + data->desc.gamepadType = 1; // Standard std::strncpy(data->desc.name, m_name, sizeof(data->desc.name) - 1); data->desc.name[sizeof(data->desc.name) - 1] = '\0'; int axesCount = (std::min)(m_axisCount, HAL_kMaxJoystickAxes); @@ -555,7 +555,7 @@ KeyboardJoystick::KeyboardJoystick(wpi::glass::Storage& storage, int index) // init desc structure m_data.desc.isGamepad = 0; - m_data.desc.gamepadType = 20; + m_data.desc.gamepadType = 1; // Standard std::strncpy(m_data.desc.name, m_name, 256); } diff --git a/wpilibc/src/main/native/include/wpi/driverstation/GenericHID.hpp b/wpilibc/src/main/native/include/wpi/driverstation/GenericHID.hpp index bd8116fd9c..6752a821f0 100644 --- a/wpilibc/src/main/native/include/wpi/driverstation/GenericHID.hpp +++ b/wpilibc/src/main/native/include/wpi/driverstation/GenericHID.hpp @@ -363,7 +363,8 @@ class GenericHID { /** * Set the rumble output for the HID. * - * The DS currently supports 2 rumble values, left rumble and right rumble. + * The DS currently supports 4 rumble values: left rumble, right rumble, left + * trigger rumble, and right trigger rumble. * * @param type Which rumble value to set * @param value The normalized value (0 to 1) to set the rumble to diff --git a/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java b/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java index 99fe2fcf1f..2f63a1026e 100644 --- a/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java +++ b/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java @@ -469,8 +469,8 @@ public class GenericHID { } /** - * Set the rumble output for the HID. The DS currently supports 2 rumble values, left rumble and - * right rumble. + * Set the rumble output for the HID. The DS currently supports 4 rumble values: left rumble, + * right rumble, left trigger rumble, and right trigger rumble. * * @param type Which rumble value to set * @param value The normalized value (0 to 1) to set the rumble to @@ -479,20 +479,13 @@ public class GenericHID { value = Math.clamp(value, 0, 1); int rumbleValue = (int) (value * 65535); switch (type) { - case kLeftRumble: - this.m_leftRumble = rumbleValue; - break; - case kRightRumble: - this.m_rightRumble = rumbleValue; - break; - case kLeftTriggerRumble: - this.m_leftTriggerRumble = rumbleValue; - break; - case kRightTriggerRumble: - this.m_rightTriggerRumble = rumbleValue; - break; - default: - break; + case kLeftRumble -> this.m_leftRumble = rumbleValue; + case kRightRumble -> this.m_rightRumble = rumbleValue; + case kLeftTriggerRumble -> this.m_leftTriggerRumble = rumbleValue; + case kRightTriggerRumble -> this.m_rightTriggerRumble = rumbleValue; + default -> { + // no-op + } } DriverStationJNI.setJoystickRumble( diff --git a/wpilibj/src/main/java/org/wpilib/simulation/GenericHIDSim.java b/wpilibj/src/main/java/org/wpilib/simulation/GenericHIDSim.java index dfd8337a04..cf39f8c9d6 100644 --- a/wpilibj/src/main/java/org/wpilib/simulation/GenericHIDSim.java +++ b/wpilibj/src/main/java/org/wpilib/simulation/GenericHIDSim.java @@ -171,23 +171,13 @@ public class GenericHIDSim { * @return the rumble value */ public double getRumble(GenericHID.RumbleType type) { - int intType = 0; - switch (type) { - case kLeftRumble: - intType = 0; - break; - case kRightRumble: - intType = 1; - break; - case kLeftTriggerRumble: - intType = 2; - break; - case kRightTriggerRumble: - intType = 3; - break; - default: - return 0.0; - } + int intType = + switch (type) { + case kLeftRumble -> 0; + case kRightRumble -> 1; + case kLeftTriggerRumble -> 2; + case kRightTriggerRumble -> 3; + }; int value = DriverStationSim.getJoystickRumble(m_port, intType); return value / 65535.0; }