 
     if (currentQuitButtonChordState != lastQuitButtonChordState)
     {
-      Joystick.setButton(QUIT_JOYSTICK_BUTTON, currentQuitButtonChordState);
+      if (currentQuitButtonChordState)
+      {
+        XInput.press(QUIT_JOYSTICK_BUTTON); 
+      }
+      else
+      {
+         XInput.release(QUIT_JOYSTICK_BUTTON); 
+      }
+      //Joystick.setButton(QUIT_JOYSTICK_BUTTON, currentQuitButtonChordState);
     }
 
     lastQuitButtonChordState = currentQuitButtonChordState;
   }
   //------
  ZeroUnusedAxes();
-  delay(10);
+  XInput.send();
 }
 
 void ZeroUnusedAxes()
 {
   //fishy looking, but without this line, Unity games with default input 
   //get constant spurious input
-  Joystick.setZAxis(-127);
+  //Joystick.setZAxis(0);
+  //Joystick.setRxAxis(0);
+  //Joystick.setRyAxis(0);
+  //Joystick.setHatSwitch(0, -1);
+  //Joystick.setHatSwitch(1, -1);
 }

    pinMode(pin, INPUT_PULLUP);
  }


  pinMode(A0, INPUT_PULLUP);

  // Initialize Joystick Library
  Joystick.begin();
  Joystick.setXAxisRange(-1, 1);
  Joystick.setYAxisRange(-1, 1);
  Joystick.setButton(6,0); //set button 7 off
}



//
// *** Currently setup assuming a digital (not-analog) joystick
//
// relies on these:
//https://www.partsnotincluded.com/tutorials/how-to-emulate-an-xbox-controller-with-arduino-xinput/
//https://github.com/dmadison/ArduinoXInput_AVR
//
//--------------------------------------------------------------------

#include <XInput.h>
#define pinGamepadButtonPairs_SIZE 12
int pinGamepadButtonPairs[] =
{
  6, 4,
  7, 5,
  8, 6,
  9, 1,
  10, 2,
  11, 3
};

int lastQuitButtonChordState;
#define quitButtonPinChord_LENGTH 3
int quitButtonPinChord[] = { 9, 10, 11 };
#define USE_QUIT_BUTTON_CHORD true
#define QUIT_JOYSTICK_BUTTON 8
#define ADC_MAX 4095
#define JOYMIN -32768 
#define JOYMID 0
#define JOYMAX 32767

//UP >  DOWN > LEFT > RIGHT
#define pinJoystickDirectionPins_SIZE 4
