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

Correct mapping in joystick tester but wrong in game #275

Open bbuster2 opened 1 year ago

bbuster2 commented 1 year ago

I am not sure if this is a bug with the library but since i could not find any issue on the game i am asking here. I am trying to build a game button box for Farming simulator and use the library to simulate 32 button presses. Each with an on and off delay.

I start the game and map every simulated button press to a single action. Button 1 till button 16 are correct but then it jumps to button 25, 26, 27, 28, 29, 30, 31, 32 and back to 25 till 28 again. If i check the windows gamepad tester it does loop from button 1 till 32, also https://gamepad-tester.com/ does this correct. What can this be? I don't see any issue on a website asking for this problem in Farming Simulator 2022 and i would guess other joysticks use button 17 ill 26 ass well?

Technical Details

I have tested it with an Arduino Micro on Windows 10 with Arduino IDE version 2.0.4

Sketch File that Reproduces Issue

#include <Arduino.h>
#include <Joystick.h>

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
  32, 1, 
  true, true, true,
  true, true, true,
  true, true,
  true, true, true);

void setup() {
  Joystick.begin();
  Serial.begin(115200);
  delay(5000);
}

void loop() {
  for(int i = 0; i < 32; i++) {
       Serial.print("Turn on button ");
       Serial.println(i + 1);

       Joystick.setButton(i, 1);
       delay(1000);
       Joystick.setButton(i, 0);
       delay(1000);
     }
}