Skip to content

Commit

Permalink
Detects which joystick is plugged in when code is deployed, but not w…
Browse files Browse the repository at this point in the history
…hen it is enabled
  • Loading branch information
AikiKapila committed Jan 27, 2024
1 parent a59f175 commit 0f0edb9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@

import com.kauailabs.navx.frc.AHRS;

import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.GenericHID.HIDType;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.CommandGenericHID;
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;

Expand Down Expand Up @@ -54,15 +59,27 @@ public class RobotContainer {
private final SwerveDrivetrain drivetrain = new SwerveDrivetrain(gyro, swerveModuleFL, swerveModuleFR, swerveModuleBL, swerveModuleBR);

// Create joysticks
private final CommandJoystick driverJoystick = new CommandJoystick(DriverConstants.DRIVER_JOYSTICK_PORT);
private final GenericHID genericHID = new GenericHID(0);
private final HIDType genericHIDType = genericHID.getType();
private final String HIDTypeName = genericHIDType.toString();

//private final CommandJoystick driverJoystick = new CommandJoystick(DriverConstants.DRIVER_JOYSTICK_PORT);
// private final CommandJoystick operatorJoystick = new CommandJoystick(OperatorConstants.OPERATOR_JOYSTICK_PORT);
//private final CommandXboxController xboxController = new CommandXboxController(0);
/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {

SwerveDriveJoystickControl control = new SwerveDriveJoystickControl(drivetrain, driverJoystick);
//SwerveDriveXboxControl control = new SwerveDriveXboxControl(drivetrain, xboxController);
drivetrain.setDefaultCommand(control);
SmartDashboard.putString("type", HIDTypeName);

if (genericHIDType.equals(GenericHID.HIDType.kHIDJoystick)) {
final CommandJoystick driverJoystick = new CommandJoystick(DriverConstants.DRIVER_JOYSTICK_PORT);
SwerveDriveJoystickControl control = new SwerveDriveJoystickControl(drivetrain, driverJoystick);
drivetrain.setDefaultCommand(control);
} else {
final CommandXboxController xboxController = new CommandXboxController(0);
SwerveDriveXboxControl control = new SwerveDriveXboxControl(drivetrain, xboxController);
drivetrain.setDefaultCommand(control);
}

// Configure the trigger bindings
configureBindings();
Expand Down

0 comments on commit 0f0edb9

Please sign in to comment.