package org.firstinspires.ftc.team7316.util.input;

import com.qualcomm.robotcore.hardware.Gamepad;

/**
 * Created by andrew on 9/15/16.
 */
public class GamepadWrapper {

    private Gamepad gamepad;

    public JoystickWrapper left_stick_y;
    public JoystickWrapper right_stick_y;

    public ButtonWrapper a_button, b_button, x_button, y_button;
    public TriggerWrapper leftTriggerWrapper, rightTriggerWrapper;

    public GamepadWrapper(Gamepad gamepad) {
        this.gamepad = gamepad;

        this.left_stick_y = new JoystickWrapper(JoystickWrapper.Joystick.LEFT, this);
        this.right_stick_y = new JoystickWrapper(JoystickWrapper.Joystick.RIGHT, this);
        this.a_button = new ButtonWrapper(GamepadButton.A_BUTTON, this);
        this.b_button = new ButtonWrapper(GamepadButton.B_BUTTON, this);
        this.x_button = new ButtonWrapper(GamepadButton.X_BUTTON, this);
        this.y_button = new ButtonWrapper(GamepadButton.Y_BUTTON, this);
        this.leftTriggerWrapper = new TriggerWrapper(GamepadAxis.L_TRIGGER, this);
        this.rightTriggerWrapper = new TriggerWrapper(GamepadAxis.R_TRIGGER, this);
    }

    public Boolean buttonState(GamepadButton buttonIndex) {
        if (buttonIndex == GamepadButton.A_BUTTON) {
            return gamepad.a;
        } else if (buttonIndex == GamepadButton.B_BUTTON) {
            return gamepad.b;
        } else if (buttonIndex == GamepadButton.X_BUTTON) {
            return gamepad.x;
        } else if (buttonIndex == GamepadButton.Y_BUTTON) {
            return gamepad.y;
        } else if (buttonIndex == GamepadButton.R_BUMPER) {
            return gamepad.right_bumper;
        } else if (buttonIndex == GamepadButton.L_BUMPER) {
            return gamepad.left_bumper;
        } else {
            throw new IllegalAccessError();
        }
    }

    public float axisValue(GamepadAxis axisIndex) {
        if (axisIndex == GamepadAxis.L_STICK_X) {
            return gamepad.left_stick_x;
        } else if (axisIndex == GamepadAxis.L_STICK_Y) {
            return gamepad.left_stick_y;
        } else if (axisIndex == GamepadAxis.R_STICK_X) {
            return gamepad.right_stick_x;
        } else if (axisIndex == GamepadAxis.R_STICK_Y) {
            return gamepad.right_stick_y;
        } else if (axisIndex == GamepadAxis.R_TRIGGER) {
            return gamepad.right_trigger;
        } else if (axisIndex == GamepadAxis.L_TRIGGER) {
            return gamepad.left_trigger;
        } else {
            throw new IllegalAccessError();
        }
    }

}

@@ -1142,17 +1142,17 @@
  public 
-B
+b
 oolean b
@@ -1199,18 +1199,22 @@
         
-if
+switch
  (button
@@ -1222,34 +1222,8 @@
 ndex
- == GamepadButton.A_BUTTON
 ) %7B%0A
@@ -1225,32 +1225,47 @@
 x) %7B%0A           
+ case A_BUTTON:
  return gamepad.
@@ -1279,442 +1279,217 @@
     
-%7D else if (buttonIndex == GamepadButton.B_BUTTON) %7B%0A            return gamepad.b;%0A        %7D else if (buttonIndex == GamepadButton.X_BUTTON) %7B%0A            return gamepad.x;%0A        %7D else if (buttonIndex == GamepadButton.Y_BUTTON) %7B%0A            return gamepad.y;%0A        %7D else if (buttonIndex == GamepadButton.R_BUMPER) %7B%0A            return gamepad.right_bumper;%0A        %7D else if (buttonIndex == GamepadButton.L_BUMPER) %7B%0A           
+    case B_BUTTON: return gamepad.b;%0A            case X_BUTTON: return gamepad.x;%0A            case Y_BUTTON: return gamepad.y;%0A            case R_BUMPER: return gamepad.right_bumper;%0A            case L_BUMPER:
  ret
@@ -1518,36 +1518,25 @@
 r;%0A        %7D
- else %7B%0A    
+%0A
         thro
@@ -1549,39 +1549,35 @@
 IllegalA
-ccessError();%0A        %7D
+rgumentException();
 %0A    %7D%0A%0A
@@ -1636,18 +1636,22 @@
         
-if
+switch
  (axisIn
@@ -1657,442 +1657,269 @@
 ndex
- == GamepadAxis.L_STICK_X) %7B%0A            return gamepad.left_stick_x;%0A        %7D else if (axisIndex == GamepadAxis.L_STICK_Y) %7B%0A            return gamepad.left_stick_y;%0A        %7D else if (axisIndex == GamepadAxis.R_STICK_X) %7B%0A            return gamepad.right_stick_x;%0A        %7D else if (axisIndex == GamepadAxis.R_STICK_Y) %7B%0A            return gamepad.right_stick_y;%0A        %7D else if (axisIndex == GamepadAxis.R_TRIGGER) %7B%0A           
+) %7B%0A            case L_STICK_X: return gamepad.left_stick_x;%0A            case R_STICK_X: return gamepad.left_stick_y;%0A            case L_STICK_Y: return gamepad.right_stick_x;%0A            case R_STICK_Y: return gamepad.right_stick_y;%0A            case L_TRIGGER:
  ret
@@ -1930,20 +1930,19 @@
 gamepad.
-righ
+lef
 t_trigge
@@ -1956,68 +1956,27 @@
     
-%7D else if (axisIndex == GamepadAxis.L_TRIGGER) %7B%0A           
+    case R_TRIGGER:
  ret
@@ -2014,26 +2014,17 @@
    %7D
- else %7B%0A  
+%0A
         
   th
@@ -2015,26 +2015,24 @@
   %7D%0A        
-  
 throw new Il
@@ -2041,31 +2041,27 @@
 galA
-ccessError();%0A        %7D
+rgumentException();
 %0A   

Change the code to switch-case