 
 #include <Joystick.h>
 
-/*
-//pin values from keyboard version of sketch
-int upPin = 2;
-int downPin = 3;
-int leftPin = 4;
-int rightPin = 5;
-int buttonOnePin = 6;
-int buttonTwoPin = 7;
-int buttonThreePin = 8;
-int buttonFourPin = 9;
-int buttonFivePin = 10;
-int buttonSixPin = 11;
-int playerSelectBitOnePin = 12;
-int playerSelectBitTwoPin = 13;
+Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK,
+  8, 0,                  // Button Count, Hat Switch Count
+  true, true, true,     // X and Y, but no Z Axis
+  false, false, false,   // No Rx, Ry, or Rz
+  false, false,          // No rudder or throttle
+  false, false, false);  // No accelerator, brake, or steering
 
-*/
+
+  /*//pin values from keyboard version of sketch
+  int upPin = 2;
+  int downPin = 3;
+  int leftPin = 4;
+  int rightPin = 5;
+  int buttonOnePin = 6;
+  int buttonTwoPin = 7;
+  int buttonThreePin = 8;
+  int buttonFourPin = 9;
+  int buttonFivePin = 10;
+  int buttonSixPin = 11;
+  int playerSelectBitOnePin = 12;
+  int playerSelectBitTwoPin = 13;
+  */
 #define pinGamepadButtonPairs_SIZE 12
-int pinGamepadButtonPairs[] = 
+int pinGamepadButtonPairs[] =
 {
   6, 3,
   7, 4,

void loop() {

  // Read pin values
  for (int i = 0; i < pinGamepadButtonPairs_SIZE; i+=2)
  {
    int pin = pinGamepadButtonPairs[i];
    int joystickButton = pinGamepadButtonPairs[i + 1];


  for (int i = 0; i < pinJoystickDirectionPins_SIZE / 2; i++)
  {
    int posPin = !digitalRead(pinJoystickDirectionPins[(2 * i) + 1]);
    int negativePin = !digitalRead(pinJoystickDirectionPins[(2 * i)]);
    
    int finalAxisVal = 0;
    
    bool isHorizontal = i == 1;
    
    if (posPin)
    {

      finalAxisVal = 127;

    }
    else if (negativePin)
    {
      finalAxisVal = -127;
    }
    

    if (isHorizontal)
    {
      Joystick.setXAxis(finalAxisVal);
    }
    else
    {
      Joystick.setYAxis(finalAxisVal);
    }
  }

  //--- QUIT BUTTON SIMULATED ----
  if (USE_QUIT_BUTTON_CHORD)
  {
    bool currentQuitButtonChordState = true;

    for (int i = 0; i < quitButtonPinChord_LENGTH; i++)
    {
      currentQuitButtonChordState &= !digitalRead(quitButtonPinChord[i]);
    }

    if (currentQuitButtonChordState != lastQuitButtonChordState)
    {
      Joystick.setButton(QUIT_JOYSTICK_BUTTON, currentQuitButtonChordState);
    }

    lastQuitButtonChordState = currentQuitButtonChordState;
  }
  //------

  delay(10);
}

void ZeroUnusedAxes()
{
  //Joystick.setHatSwitch(0, -1);
  //Joystick.setHatSwitch(1, -1);
}
