From e9cb2e7d3691b7a684ca96249b617a62979a51ed Mon Sep 17 00:00:00 2001 From: BenG49 Date: Sun, 7 Jan 2024 21:24:17 -0500 Subject: [PATCH] Make Xbox behave like BootlegXbox, add .flipped() --- .../stuypulse/stuylib/input/gamepads/Xbox.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/stuypulse/stuylib/input/gamepads/Xbox.java b/src/com/stuypulse/stuylib/input/gamepads/Xbox.java index c5d4729e..4f8e54ee 100644 --- a/src/com/stuypulse/stuylib/input/gamepads/Xbox.java +++ b/src/com/stuypulse/stuylib/input/gamepads/Xbox.java @@ -18,9 +18,13 @@ public class Xbox extends Gamepad { private XboxController mJoystick; + private boolean flipped; + // Constructor // public Xbox(XboxController joystick) { mJoystick = joystick; + + flipped = false; } public Xbox(int port) { @@ -46,18 +50,18 @@ public double getLeftX() { @Override public double getLeftY() { - return getJoystick().getLeftY(); + return -getJoystick().getLeftY(); } // Right Stick // @Override public double getRightX() { - return getJoystick().getRightX(); + return (flipped ? +1 : -1) * getJoystick().getRightX(); } @Override public double getRightY() { - return getJoystick().getRightY(); + return (flipped ? +1 : -1) * getJoystick().getRightY(); } // D-Pad // @@ -152,4 +156,9 @@ public void setRumble(double intensity) { mJoystick.setRumble(RumbleType.kLeftRumble, intensity); mJoystick.setRumble(RumbleType.kRightRumble, intensity); } + + public Xbox flipped() { + flipped = true; + return this; + } }