Skip to content

Commit

Permalink
Fix Xbox .flipped(), right Y instead of right X
Browse files Browse the repository at this point in the history
  • Loading branch information
BenG49 committed Jan 8, 2024
1 parent 32c4cf9 commit 636f285
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/com/stuypulse/stuylib/input/gamepads/Xbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ public class Xbox extends Gamepad {

private XboxController mJoystick;

private boolean flipped;
private final boolean flipped;

// Constructor //
public Xbox(XboxController joystick) {
this(joystick, false);
}

protected Xbox(XboxController joystick, boolean flipped) {
mJoystick = joystick;

flipped = false;
this.flipped = flipped;
}

public Xbox(int port) {
Expand All @@ -50,13 +54,13 @@ public double getLeftX() {

@Override
public double getLeftY() {
return -getJoystick().getLeftY();
return (flipped ? +1 : -1) * getJoystick().getLeftY();
}

// Right Stick //
@Override
public double getRightX() {
return (flipped ? +1 : -1) * getJoystick().getRightX();
return getJoystick().getRightX();
}

@Override
Expand Down Expand Up @@ -158,7 +162,6 @@ public void setRumble(double intensity) {
}

public Xbox flipped() {
flipped = true;
return this;
return new Xbox(mJoystick, true);
}
}

0 comments on commit 636f285

Please sign in to comment.