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.07k stars 403 forks source link

Rudder and brake do not work at the same time #154

Open brunombc opened 4 years ago

brunombc commented 4 years ago

Description of Issue

I'm making a rudder pedal with brake, but when I set Rudder and Brake in the code, only Brake is available in the game controller properties and it work, but not the rudder.

Technical Details

Sketch File that Reproduces Issue

#include "Joystick.h"

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, 
  JOYSTICK_TYPE_MULTI_AXIS, 0, 0,
  false, false, false, false, false, false,
  true, false, false, true, false);

int rudPed = A0;
int rudValue = 0;

int brakePed = A1;
int brakeValue = 0;

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

void loop () {

  rudValue = analogRead(rudPed);
  Joystick.setRudder(rudValue);
  delay(1);

  brakeValue = analogRead(brakePed);
  Joystick.setBrake(brakeValue);
  delay(1);
}

Additional context

When I set Throttle instead of Brake, it works normally. How can I set Rudder and Brake instead of Rudder and Throttle?

FlisherOfatale commented 4 years ago

Similar issue with Z cauing the Joystick to not be detected by windows if RX or RY are enabled. Same issue if we try to add RZ and X + Y

rafaelmaiolla commented 3 years ago

I had a similar issue on Windows 10. I was trying to have Rudder, Throttle, Accelerator and Brake. But Rudder didn't work.

Testing the same code on Linux seems to work fine. I also tested using the Gamepad api from the browser (Chrome) and it is working as expected on Linux and Windows - https://gamepad-tester.com/

I'm not sure if Windows has any limitation regarding the combination you use in your joystick.

For now, I'm using Steering instead of Rudder and Windows is accepting it. However Steering + Accelerator become a kind of a x,y axis.

ALEEF02 commented 3 years ago

Having the same issue...

batbsv commented 3 years ago

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

VkTheProgrammer17 commented 3 years ago

Just use another one of the axes which is not already taken

VkTheProgrammer17 commented 3 years ago

write down which axis does what function and you'll be okay

VkTheProgrammer17 commented 3 years ago

or you could re-calibrate everything

Thick8 commented 1 year ago

I tried your code and the rudder is not showing up in the Windows test. Everything else does though. I'm wondering if there is an issue with setRudder. I tried it with JOYSTICK and MULTI_AXIS. Also used your same code structure for all the other axis. No issues except with the rudder. I just commented it out for the time being.

#include "Joystick.h"

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 
0, 0, false, false, false, true, true, true, false, false, false, false, false);                 

//int rudPed = A0;
//int rudValue = 0;

int Rx = A0;
int RxValue = 0;

int Ry = A1;
int RyValue = 0;

int Rz = A2;
int RzValue = 0;

void setup() {

  Joystick.setRxAxisRange(0, 1023);
  //Joystick.setRudderRange(-512, 512);
  Joystick.setRyAxisRange(0, 1023);
  Joystick.setRzAxisRange(0, 1023);

  Joystick.begin();
}

void loop() {

  //rudValue = analogRead(rudPed);
  //Joystick.setRudder(rudValue);
  //delay(1);

  RxValue = analogRead(Rx);
  Joystick.setRxAxis(RxValue);
  delay(1);

  RyValue = analogRead(Ry);
  Joystick.setRyAxis(RyValue);
  delay(1);

  RzValue = analogRead(Rz);
  Joystick.setRzAxis(RzValue);
  delay(1);
}