mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[halsim_gui, wpilibc/j] Fixups for joystick outputs (#8443)
#8385 changed gamepad types to follow SDL_GamepadType, so 20 and 21 (previously `kHIDJoystick` and `kHIDGamepad`, respectively) are no longer valid constants. This meant that after leaving the disconnected state of the sim GUI, `GamepadType.getGamepadType()` would return null (since it didn't match any constants). Since there aren't analogous generic joystick and gamepad constants anymore, this PR changes GlfwSystemJoystick and KeyboardJoystick to both unconditionally report as kStandard. This also updates the GenericHID.SetRumble doc comment to reflect the two new types of rumble and changes some switch labeled statement groups to use switch rules instead. If we want to keep on using switch labeled statement groups (e.g. for consistency with C++, though GenericHID::SetRumble currently uses if-else), then I could drop the last change- I just made it since GenericHID.setRumble() previously used switch rules and general switch rules are nice since there's no risk of fall-through.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user