ArduinoJoystickLibrary icon indicating copy to clipboard operation
ArduinoJoystickLibrary copied to clipboard

Second joystick not recognized correctly

Open Snail921 opened this issue 7 years ago • 0 comments

Description of Issue

When I make multiple joystick instances in a single sketch, the second joystick seems to be not recognized correctly. I can see three controllers in the installed controller list of Arduino Micro game controller in the control panel but when I try to open the property of the second controller, my pc gives me an error and it says "Game controller is not properly connected. Check if it is connected.(In Japanese, since I am running it in Japanese.)" https://imgur.com/a/8lklOtz

When I plug it to my laptop (which is not the developing machine, ) I only have two controllers in the installed controller list.

Technical Details

  • Arduino Board : What's next Pink
  • Host OS (e.g. Windows 10): Windows 10
  • Arduino IDE Version : 1.8.5

Sketch that Reproduces Issue

`#include <Joystick.h>

#define JOYSTICK_COUNT 3

Joystick_ Joystick[JOYSTICK_COUNT] = { Joystick_(0x03,JOYSTICK_TYPE_JOYSTICK, 2, 0, true, true, true, true, true, true, false, true, false, false, false), Joystick_(0x04,JOYSTICK_TYPE_JOYSTICK, 2, 0, true, true, true, true, true, true, false, true, false, false, false), Joystick_(0x05,JOYSTICK_TYPE_JOYSTICK, 2, 0, true, true, true, true, true, true, false, true, false, false, false) };

const int Analog1 = 0; const int Analog2 = 1; const int Analog3 = 2; const int Analog4 = 3; const int Analog5 = 4; const int Analog6 = 5; const int Analog7 = 6; const int Analog8 = 7;

int XValue = 0; int YValue = 0; int ZValue = 0; int RxValue = 0; int RyValue = 0; int RzValue = 0; int SxValue = 0; int SyValue = 0;

void setup() { Joystick[0].begin(); Joystick[1].begin(); Joystick[2].begin(); delay(1000); }

void loop() {

XValue = (analogRead(Analog1)); YValue = (analogRead(Analog2)); ZValue = (analogRead(Analog3)); RxValue = (analogRead(Analog4)); RyValue = (analogRead(Analog5)); RzValue = (analogRead(Analog6)); SxValue= (analogRead(Analog7));

Joystick[0].setXAxis(XValue); Joystick[0].setYAxis(YValue); Joystick[0].setZAxis(ZValue); Joystick[0].setRxAxis(RxValue); Joystick[0].setRyAxis(RyValue); Joystick[0].setRzAxis(RzValue); Joystick[0].setThrottle(SxValue);

Joystick[1].setXAxis(XValue); Joystick[1].setYAxis(YValue); Joystick[1].setZAxis(ZValue); Joystick[1].setRxAxis(RxValue); Joystick[1].setRyAxis(RyValue); Joystick[1].setRzAxis(RzValue); Joystick[1].setThrottle(SxValue);

Joystick[2].setXAxis(XValue); Joystick[2].setYAxis(YValue); Joystick[2].setZAxis(ZValue); Joystick[2].setRxAxis(RxValue); Joystick[2].setRyAxis(RyValue); Joystick[2].setRzAxis(RzValue); Joystick[2].setThrottle(SxValue); }`

Wiring Details

Three joysticks share the same 7 analog input for an experimental purpose.

Snail921 avatar May 07 '18 03:05 Snail921