Skip to content

Commit

Permalink
Fixed Xbox controller
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebHeydon committed Jan 30, 2020
1 parent bc14caf commit 711681b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/org/aluminati3555/lib/data/AluminatiData.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public final class AluminatiData {
// Library
public static final int LIBRARY_VERSION = 9;
public static final int LIBRARY_VERSION = 10;

// Robot delay
public static double robotDelay = 0.02; // Seconds
Expand Down
38 changes: 2 additions & 36 deletions src/org/aluminati3555/lib/drive/AluminatiDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,42 +328,8 @@ public void arcadeDrive(AluminatiJoystick joystick) {
* Drives the robot using arcade drive
*/
public void arcadeDrive(AluminatiXboxController controller) {
driveHelper.aluminatiDrive(-controller.getSquaredY() * controlCoefficient,
controller.getSquaredX() * controlCoefficient, true, (shifter == null) ? true : shifter.isHigh());

if (!inverted) {
left.getMaster().set(ControlMode.PercentOutput, driveHelper.getLeftPower());
right.getMaster().set(ControlMode.PercentOutput, driveHelper.getRightPower());
} else {
left.getMaster().set(ControlMode.PercentOutput, -driveHelper.getRightPower());
right.getMaster().set(ControlMode.PercentOutput, -driveHelper.getLeftPower());
}
}

/**
* Drives the robot using cheesy drive
*/
public void cheesyDrive(AluminatiJoystick joystick, int cheesyDriveButton) {
driveHelper.aluminatiDrive(-joystick.getSquaredY() * controlCoefficient,
joystick.getSquaredX() * controlCoefficient, joystick.getRawButton(cheesyDriveButton),
(shifter == null) ? true : shifter.isHigh());

if (!inverted) {
left.getMaster().set(ControlMode.PercentOutput, driveHelper.getLeftPower());
right.getMaster().set(ControlMode.PercentOutput, driveHelper.getRightPower());
} else {
left.getMaster().set(ControlMode.PercentOutput, -driveHelper.getRightPower());
right.getMaster().set(ControlMode.PercentOutput, -driveHelper.getLeftPower());
}
}

/**
* Drives the robot using cheesy drive
*/
public void cheesyDrive(AluminatiXboxController controller, int cheesyDriveButton) {
driveHelper.aluminatiDrive(-controller.getSquaredY() * controlCoefficient,
controller.getSquaredX() * controlCoefficient, controller.getRawButton(cheesyDriveButton),
(shifter == null) ? true : shifter.isHigh());
driveHelper.aluminatiDrive(-controller.getSquaredLeftY() * controlCoefficient,
controller.getSquaredRightX() * controlCoefficient, true, (shifter == null) ? true : shifter.isHigh());

if (!inverted) {
left.getMaster().set(ControlMode.PercentOutput, driveHelper.getLeftPower());
Expand Down
28 changes: 23 additions & 5 deletions src/org/aluminati3555/lib/drivers/AluminatiXboxController.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,37 @@ private double squareOutput(double input) {
/**
* Returns the squared x
*
* @return The squared left x
*/
public double getSquaredLeftX() {
return squareOutput(this.getX(Hand.kLeft));
}

/**
* Returns the squared left y
*
* @return The squared y
*/
public double getSquaredLeftY() {
return squareOutput(this.getY(Hand.kLeft));
}

/**
* Returns the squared right x
*
* @return The squared x
*/
public double getSquaredX() {
return squareOutput(this.getX());
public double getSquaredRightX() {
return squareOutput(this.getX(Hand.kRight));
}

/**
* Returns the squared y
* Returns the squared right y
*
* @return The squared y
*/
public double getSquaredY() {
return squareOutput(this.getY());
public double getSquaredRightY() {
return squareOutput(this.getY(Hand.kRight));
}

/**
Expand Down

0 comments on commit 711681b

Please sign in to comment.