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.1k stars 409 forks source link

Joystick not recognized by games, device manager show entry #216

Open CDRXavier opened 3 years ago

CDRXavier commented 3 years ago

Description of Issue

Terraria did not detect any joystick input. Reconnecting/restarting mcu does not help. So I tried with Horizon Turbo Chase. Horizon Turbo Chase found "something", however none of the inputs are working. image Simpleplanes did it no problem. However, all the axis are unnamed (instead of X,Y,Z, you have "axis 0", "axis 2". Throttle is labeled as "axis 11") KSP have partial support, in the fact that the game can detect the normal axis (XYZ, XrYrZr), but then it stop there. (did not detect throttle input) Also, KSP treat as if all the inputs only have half the nominal range (e.g. only the upper 50% of throttle behave normally; the rest 50% it is locked at 100%)

However, the "properties" page in "game controller options" have the "correct" output, and the device manager shows the "HID compliant game controller" under "human interface devices".

Technical Details

Sketch File:

https://github.com/CDRXavier/XpandShield/tree/main/XpandShield_MK2/Sketches/XpandShield_MK2_1

All of your files are simply copied over because I keep having linking errors

Wiring Details

None -- SSD1306 display show that all input are correct, so do gamepad property.

CDRXavier commented 3 years ago

Apparently KSP does not take into account the negative axis of sticks, or that they do take into account the negative stick but they did not use the type int16_t or perhaps otherwise. Anyhow. The (temporary) fix (for KSP) is to change the logical maximum and logical minimum of the axis. To avoid issues, I went with 0 and 1023 respectively, but I think higher values (e.g. 0 and 4095 or 0 and 16383) will also work, if you need higher accuracy (remember, default accuracy, and the highest accuracy for many Arduino is 10 bit, which is between 0 and 1023). Turns out it work quite well (with the exception that my stick is not perfectly centered, but that is a problem unrelated to the library and I can solve on my own). HOWEVER, this fix still does not allow KSP to detect the dedicated "throttle" axis, and Horizon Chase still detects no inputs. Neither does Terraria.


Now, Terraria, for its primary code for joystick lie at the end of console, likely does not support HID input devices, rather, XInput devices. So this leave Horizon Chase Turbo on the table. I think it support ... maybe not. Maybe it just support HID keyboards. But it can detect that this "unknown device" is a joystick. so I think it do support HID joysticks (and we just dont know what we are doing)