From 636f2853314f702b7008c018942876f473434585 Mon Sep 17 00:00:00 2001 From: BenG49 Date: Sun, 7 Jan 2024 22:20:36 -0500 Subject: [PATCH] Fix Xbox .flipped(), right Y instead of right X --- .../stuypulse/stuylib/input/gamepads/Xbox.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/stuypulse/stuylib/input/gamepads/Xbox.java b/src/com/stuypulse/stuylib/input/gamepads/Xbox.java index be836b51..a541fd0b 100644 --- a/src/com/stuypulse/stuylib/input/gamepads/Xbox.java +++ b/src/com/stuypulse/stuylib/input/gamepads/Xbox.java @@ -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) { @@ -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 @@ -158,7 +162,6 @@ public void setRumble(double intensity) { } public Xbox flipped() { - flipped = true; - return this; + return new Xbox(mJoystick, true); } }