Leonardo Gamepad Analog as Digital inputs?

I am pretty sure. In any event if I was attempting to load a second joystick test Arduino rejects it. I will delete all the sketch library and start again. Having said that I did read on a forum but new versions of Arduino are not always backwards compatible. I have the latest version.

Like you are don't understand why it's rejected. Perhaps you could give me the specific code that will allow the Leonardo to interface with the Joystick.

As I think I said it shows up in control panel then in Windows test program but the encoder has no effect.

Delete all traces of Joystick and tried to compile the sketch but it highlighted missing Joystick.h. So I uploaded the correct Joystick Zip. Tried to compile and got:

Your code is missing something; you haven't copied everything from wherever you got that code.
Looks like you're missing Joystick_ Joystick(0x15, JOYSTICK_TYPE_GAMEPAD,.

Instead of working on your project, first look at and try some of the examples that came with the Joystick library that you installed.

Note:
Don't post screenshots of code and don't post screenshots of errors. There is that beautiful 'copy error messages` button on your screen, specifically for those errors.

I copied it from the OP original download. I will try again. Thank you.

The example gamepad sketch that comes with the library worked for me it gave d pad and 1 fire button. I modded the sketch for more buttons then the guy a few posts up made it into an array. Ahhh
Make sure you use the sketch with the array since that will work with both the leonardo and the pro micro.

I did as you said: and got this error message:

sketch_oct14a:50:12: error: 'class Joystick_' has no member named 'setXAxisRange'; did you mean 'setXAxis'?

Joystick.setXAxisRange(-1, 1);

        ^~~~~~~~~~~~~

        setXAxis

sketch_oct14a:51:12: error: 'class Joystick_' has no member named 'setYAxisRange'; did you mean 'setYAxis'?

Joystick.setYAxisRange(-1, 1);

        ^~~~~~~~~~~~~

        setYAxis

exit status 1

'JOYSTICK_TYPE_GAMEPAD' was not declared in this scope

Joystick_ Joystick(0x15, JOYSTICK_TYPE_GAMEPAD,

Well I used the other code you suggested and once again I got the 'not declared in scope error for 'Joystick_ Joystick(0x15, JOYSTICK_TYPE_GAMEPAD,'

I give up for some reason it is clearly not going to work for me.

Very odd. It works for me fine on my leonardos and pro micros.
Must be something up

I stripped everything out and started again. I can get a gamepad showing in Windows using the Joystick Test. As soon I uploaded the basic project yours is based and with Joystick.h loaded it compiles and loads but then no Gamepad in Windows. Could this be a problem with having the latest version of Arduino. I read somewhere the versions are not backwards compatible.

This started because I couldn't get another code to work. I could see it in control panel/ then windows test software and even saw it in my flight sim calibrator but the encoder worked in Serial Monitor but not in the sim.

Not sure Arduino is for me.

That is odd. Its working here iv implemented it in to my arcade cab. I used latest arduino ide to do this in.
I have put a full bundle of this up on arcadecontrol forum. Zip file is there with schematic sketches and board id etc.

Do you have a link to actual position on on that forum. Incidentally I came across the attached code which does work after a fashion. It acts almost like a motorised trim rather than a simple Scroll Up Scroll Down action. You have to gone one click back or forward to stop the rotation.

#include <Bounce2.h>



// Requires Arduino Joystick Library https://github.com/MHeironimus/ArduinoJoystickLibrary
#include <Joystick.h>
Joystick_ Joystick;
 
int JoystickX;
int JoystickY;
int JoystickZ;
int Throttle;

int currentButtonState0;
int lastButtonState0;
int currentButtonState1;
int lastButtonState1;
int currentButtonState2;
int lastButtonState2;
int currentButtonState3;
int lastButtonState3;
int currentButtonState4;
int lastButtonState4;
int currentButtonState5;
int lastButtonState5;
int currentButtonState6;
int lastButtonState6;

void setup() {
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(A0, INPUT_PULLUP);
  pinMode(A1, INPUT_PULLUP);
  pinMode(A2, INPUT_PULLUP);
  pinMode(A3, INPUT_PULLUP);
  pinMode(A4, INPUT_PULLUP);
  pinMode(A5, INPUT_PULLUP);
  pinMode(A6, INPUT_PULLUP);
  pinMode(A7, INPUT_PULLUP);
  pinMode(A8, INPUT_PULLUP); 
  pinMode(A9, INPUT_PULLUP);
  

// Initialize Joystick Library
  Joystick.begin();
  Joystick.setXAxisRange(0, 1024); 
  Joystick.setYAxisRange(0, 1024);
  Joystick.setZAxisRange(0, 1024);
  Joystick.setThrottleRange(0, 1024);
}

void loop() {

// Read Joystick
  JoystickX = analogRead(A9); // Hall effect sensor connects to this analog pin
  JoystickY = analogRead(A8); // Hall effect sensor connects to this analog pin

// Read Rudder Pedals
  JoystickZ = analogRead(A6); // Hall effect sensor connects to this analog pin

// Read Throttle
  Throttle = analogRead(A4); // Potentiometer signal connects to this analog pin


// Read Switches
int currentButtonState0 = !digitalRead(7); // Button 0
  if (currentButtonState0 != lastButtonState0)
  {
  Joystick.setButton(0, currentButtonState0);
  lastButtonState0 = currentButtonState0;
  }

int currentButtonState1 = !digitalRead(A0); // Button 1
  if (currentButtonState1 != lastButtonState1)
  {
  Joystick.setButton(1, currentButtonState1);
  lastButtonState1 = currentButtonState1;
  }
  
int currentButtonState2 = !digitalRead(6); // Button 2
  if (currentButtonState2 != lastButtonState2)
  {
  Joystick.setButton(2, currentButtonState2);
  lastButtonState2 = currentButtonState2;
  }

int currentButtonState3 = !digitalRead(A1); // Button 3
  if (currentButtonState3 != lastButtonState3)
  {
  Joystick.setButton(3, currentButtonState3);
  lastButtonState3 = currentButtonState3;
  }
  
int currentButtonState4 = !digitalRead(A2); // Button 4
  if (currentButtonState4 != lastButtonState4)
  {
  Joystick.setButton(4, currentButtonState4);
  lastButtonState4 = currentButtonState4;
  } 

int currentButtonState5 = !digitalRead(A3); // Button 5
  if (currentButtonState5 != lastButtonState5)
  {
  Joystick.setButton(5, currentButtonState5);
  lastButtonState5 = currentButtonState5;
  } 
  
int currentButtonState6 = !digitalRead(A5); // Button 6
  if (currentButtonState6 != lastButtonState6)
  {
  Joystick.setButton(6, currentButtonState6);
  lastButtonState6 = currentButtonState6;
  }  
   
// Output Controls
  Joystick.setXAxis(JoystickX);
  Joystick.setYAxis(JoystickY);
  Joystick.setZAxis(JoystickZ);
  Joystick.setThrottle(Throttle);

  Joystick.sendState();

} 

I found it and down loaded gamepad 2 and my trim worked on 1&2 with the same scrolling effect as described. Is it possible to make it so it is increment, as in I click forward or make rather scrolling then stopping it.

i dont understand the issue your having with this. are you trying to turn the arduino into a gamepad/joystick like i did or something else?

A trim wheel for flight sim as a stand alone gamepad.

Ahh maybe thats why it's got issues. Standard microswitches inputs work great with this Arduino code.

in trying to understand this joystick codes behavior, how does it work when sending button states over usb? does it read the pins wait for the 10ms delay then send? or does it read pins, send button states over usb then wait the 10ms delay and repeat again?

@robertfm did you get it working?
Iv now started using the daemonbite code which works fine too.

No I didn't I gave up in the end. A friend of mine provided a board already programmed, he wrote a new code.

Very odd it didnt work.
Im now working on using a single raspberry pi pico to use 2 joysticks with buttons for player 1 and 2.