Got the code for anyone that needs it. Just remember to have the switches turned off when starting the sim.
// This example makes an on off toggle switch act like a joystick button. A quick pulse is sent rather than a continual pulse.
//
// NOTE: This sketch file is for use with Arduino Leonardo and
// Arduino Micro only.
//
//
//--------------------------------------------------------------------
#include
Joystick_ Joystick;
void setup() {
// Initialize Button Pins - Mine starts with pin D3 because the D2 pin was burned out.
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
// Constant that maps the phyical pin to the joystick button. Again, I use pin 3.
const int pinToButtonMap = 3;
// Last state of the button
int buttonState = HIGH ;
int lastButtonState = LOW ;
int index = 0 ;
int buttonPushCounter = 0 ;
void loop() {
// read the pushbutton input pin: Again, I use pin 3.
buttonState = digitalRead(3);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button went from off to on:
// "press" the joystick button for 10 milliseconds
Joystick.setButton(0, HIGH);
delay(50);
Joystick.setButton(0, LOW);
} else {
// "press" the joystick button for 10 milliseconds
Joystick.setButton(0, HIGH);
delay(50);
Joystick.setButton(0, LOW);
}
delay(50);
}
// NOTE: save the current state as the last state, for next time through the loop
lastButtonState = buttonState;
}