MHeironimus / ArduinoJoystickLibrary

An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.
GNU Lesser General Public License v3.0
2.06k stars 403 forks source link

Windows and MSFS2020 unable to recognize all analog inputs #193

Closed thomasnield closed 3 years ago

thomasnield commented 3 years ago

I have tried running this code to see if Windows 10 and Microsoft Flight Simulator would pick up all analog inputs this library allows. It simply iterates the values 0 through 1023. Unfortunately both platforms only seem to pick up 7 analog inputs.

Is this a bug or a known limitation?

#include <Joystick.h>

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
  0, 0,                  // Button Count, Hat Switch Count
  true, true, true,     // X, Y, Z Axis
  true, true, true,    // Rx, Ry, Rz
  true, true,         // rudder, throttle
  true, true, true); // accelerator, brake, steering

void setup() {
    Joystick.begin();
}

void loop() {

  for (int i = 0; i < 1024; i++) {
    Joystick.setXAxis(i);
    Joystick.setYAxis(i);
    Joystick.setZAxis(i);
    Joystick.setThrottle(i);
    Joystick.setRudder(i);
    Joystick.setRxAxis(i);
    Joystick.setRyAxis(i);
    Joystick.setRzAxis(i);
    Joystick.setAccelerator(i);
    Joystick.setBrake(i);

    delay(50);
  }
}

image

Technical Details

thomasnield commented 3 years ago

I get stranger results when I try different combinations. Here I am only able to get 5 inputs.

#include <Joystick.h>

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
  0, 0,                  // Button Count, Hat Switch Count
  true, true, true,     // X, Y, Z Axis
  false, false, false,   // No Rx, Ry, or Rz
  true, true,          // rudder, throttle
  true, true, true);  // accelerator, brake, steering

void setup() {
    Joystick.begin();
}

void loop() {

  for (int i = 0; i < 1024; i++) {
    Joystick.setXAxis(i);
    Joystick.setYAxis(i);
    Joystick.setZAxis(i);
    Joystick.setThrottle(i);
    Joystick.setRudder(i);
    //Joystick.setRxAxis(i);
    //Joystick.setRyAxis(i);
    //Joystick.setRzAxis(i);
    Joystick.setAccelerator(i);
    Joystick.setBrake(i);

    delay(50);
  }
}

image

thomasnield commented 3 years ago

Alright I think this issue was resolved on another thread. I have made this change in my own fork.

https://github.com/MHeironimus/ArduinoJoystickLibrary/issues/177