ArduinoJoystickLibrary icon indicating copy to clipboard operation
ArduinoJoystickLibrary copied to clipboard

Wrong axis value [Windows 10]

Open LoSkana opened this issue 4 years ago • 1 comments

Description of Issue

Hi! Fantastic library. I have a physical joystick, I'm using it to emulate a gamepad. I take the analogRead, put the value on X/Y axis, and updateState. Under linux it worked on the first try. Under Windows10 it recognizes the gamepad, but the axis value received are wrong (when I move the joystick to the max it only reaches a value of 0.008 instead of 1). Using "setXRange" didn't work, and also mapping the value of the analogRead had no effect.

Technical Details

  • Arduino Micro
  • Windows 10
  • 1.8.13

Sketch File that Reproduces Issue

Joystick.begin(false);
Joystick.setXAxisRange(0, 1023);
Joystick.setYAxisRange(0, 1023);

(loop)

int x_pos = analogRead(joyVerPin); int y_pos = analogRead(joyHorPin); Joystick.setXAxis(x_pos); Joystick.setYAxis(y_pos); Joystick.sendState();

LoSkana avatar Apr 25 '21 16:04 LoSkana

Try verifying the maximum value returned from analogRead is 1023. Depending on the hardware, this value is sometimes less than 1023.

MHeironimus avatar Mar 30 '22 17:03 MHeironimus