|
| 1 | +package org.firstinspires.ftc.hoops.controllers; |
| 2 | + |
| 3 | +import com.technototes.library.command.CommandScheduler; |
| 4 | +import com.technototes.library.control.CommandAxis; |
| 5 | +import com.technototes.library.control.CommandButton; |
| 6 | +import com.technototes.library.control.CommandGamepad; |
| 7 | +import com.technototes.library.control.Stick; |
| 8 | +import org.firstinspires.ftc.hoops.Robot; |
| 9 | +import org.firstinspires.ftc.hoops.Setup; |
| 10 | +import org.firstinspires.ftc.hoops.commands.EZCmd; |
| 11 | +import org.firstinspires.ftc.hoops.commands.IntakeAndLaunchCommand; |
| 12 | +import org.firstinspires.ftc.hoops.commands.IntakeCommands; |
| 13 | +import org.firstinspires.ftc.hoops.commands.JoystickDriveCommand; |
| 14 | +import org.firstinspires.ftc.hoops.commands.LaunchCommands; |
| 15 | + |
| 16 | +public class AllinOneController { |
| 17 | + |
| 18 | + public Robot robot; |
| 19 | + public CommandGamepad gamepad; |
| 20 | + |
| 21 | + public Stick driveLeftStick, driveRightStick; |
| 22 | + public CommandButton resetGyroButton, turboButton, snailButton; |
| 23 | + public CommandButton override; |
| 24 | + public CommandAxis driveStraighten; |
| 25 | + public CommandButton launch; |
| 26 | + public CommandButton intake; |
| 27 | + public CommandButton intakeandlaunch; |
| 28 | + |
| 29 | + public AllinOneController(CommandGamepad g, Robot r) { |
| 30 | + this.robot = r; |
| 31 | + gamepad = g; |
| 32 | + |
| 33 | + AssignNamedControllerButton(); |
| 34 | + if (Setup.Connected.DRIVEBASE) { |
| 35 | + bindDriveControls(); |
| 36 | + } |
| 37 | + if (Setup.Connected.LAUNCHER) { |
| 38 | + bindLaunchControls(); |
| 39 | + } |
| 40 | + if (Setup.Connected.INTAKE) { |
| 41 | + bindIntakeControls(); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + private void AssignNamedControllerButton() { |
| 46 | + resetGyroButton = gamepad.ps_options; |
| 47 | + driveLeftStick = gamepad.leftStick; |
| 48 | + driveRightStick = gamepad.rightStick; |
| 49 | + driveStraighten = gamepad.rightTrigger; |
| 50 | + turboButton = gamepad.leftBumper; |
| 51 | + snailButton = gamepad.rightBumper; |
| 52 | + launch = gamepad.ps_square; |
| 53 | + intake = gamepad.ps_circle; |
| 54 | + intakeandlaunch = gamepad.ps_triangle; |
| 55 | + } |
| 56 | + |
| 57 | + public void bindDriveControls() { |
| 58 | + CommandScheduler.scheduleJoystick( |
| 59 | + new JoystickDriveCommand( |
| 60 | + robot.drivebaseSubsystem, |
| 61 | + driveLeftStick, |
| 62 | + driveRightStick, |
| 63 | + driveStraighten |
| 64 | + ) |
| 65 | + ); |
| 66 | + turboButton.whenPressed(EZCmd.Drive.TurboMode(robot.drivebaseSubsystem)); |
| 67 | + turboButton.whenReleased(EZCmd.Drive.NormalMode(robot.drivebaseSubsystem)); |
| 68 | + snailButton.whenPressed(EZCmd.Drive.SnailMode(robot.drivebaseSubsystem)); |
| 69 | + snailButton.whenReleased(EZCmd.Drive.NormalMode(robot.drivebaseSubsystem)); |
| 70 | + |
| 71 | + resetGyroButton.whenPressed(EZCmd.Drive.ResetGyro(robot.drivebaseSubsystem)); |
| 72 | + } |
| 73 | + |
| 74 | + public void bindLaunchControls() { |
| 75 | + launch.whenPressed(LaunchCommands.launchCommand(robot)); |
| 76 | + launch.whenReleased(LaunchCommands.stopLaunchCommand(robot)); |
| 77 | + intakeandlaunch.whenPressed(IntakeAndLaunchCommand.IntakeAndLaunch(robot)); |
| 78 | + intakeandlaunch.whenReleased(IntakeAndLaunchCommand.IntakeAndLaunchStop(robot)); |
| 79 | + } |
| 80 | + |
| 81 | + public void bindIntakeControls() { |
| 82 | + intake.whenPressed(IntakeCommands.intakeCommand(robot)); |
| 83 | + intake.whenReleased(IntakeCommands.stopIntakeCommand(robot)); |
| 84 | + } |
| 85 | +} |
0 commit comments