This code compiles without error and can be loaded into an arduino leonardo:
//
// Controller for dials for a Flight Simulator
// using an Arduino Leonardo or Arduino Micro.
// based on code from
// Matthew Heironimus
//
//------------------------------------------------------------
#include "Joystick.h"
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_MULTI_AXIS, 32, 0,
true, true, true, true, true, true,
false, false, false, false, false);
char potPins[] = {
A0,A1,A2,A3,A6,A7
};
byte swchPins[] = {
9,8,15,14,10,16,0,1,3,2,7,5
};
byte potCount = 6;
int inputPot = 0;
byte inputSwch = 0;
byte swchCount = 12;
int lastButtonState[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
void setup() {
Joystick.begin();
for (byte thisSwch = 0; thisSwch < swchCount; thisSwch++)
pinMode(swchPins[thisSwch], INPUT);
}
void loop() {
for (int thisPot = 0; thisPot < potCount; thisPot++) {
inputPot = analogRead(potPins[thisPot]);
switch (thisPot) {
case 0:
Joystick.setXAxis(inputPot);
break;
case 1:
Joystick.setYAxis(inputPot);
break;
case 2:
Joystick.setZAxis(inputPot);
break;
case 3:
Joystick.setRxAxis(inputPot);
break;
case 4:
Joystick.setRyAxis(inputPot);
break;
case 5:
Joystick.setRzAxis(inputPot);
break;
default:
break;
}//end switch
}//end for
for (byte thisSwch = 0; thisSwch < swchCount; thisSwch++) {
inputSwch = digitalRead(swchPins[thisSwch]);
int currentButtonState = !digitalRead(swchPins[thisSwch]);
/* Serial.println("currentButtonState ");
Serial.print(currentButtonState);
Serial.println(inputPot);
*/
if (currentButtonState != lastButtonState[thisSwch])
{
Joystick.setButton(thisSwch, currentButtonState);
lastButtonState[thisSwch] = currentButtonState;
}
}//end for
}
Device manager shows it in the ports section:

but it is not showing up with all my other controllers in the game control panel. I think it must have something to do with the MHeironimus ArduinoJoystickLibrary. Has anyone experienced a similar issue?
SOLUTION: From the list of issues in Hieronymus github someone mentioned that changing 'JOYSTICK_TYPE_MULTI_AXIS' to 'JOYSTICK_TYPE_JOYSTICK' was the issue. Now it's fixed.