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

Wrong axis value [Windows 10] #201

Open LoSkana opened 3 years ago

LoSkana commented 3 years ago

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

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();

MHeironimus commented 2 years ago

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