Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining which range of values will be reported to the HID interface #104

Closed
kharar opened this issue Nov 25, 2018 · 6 comments
Closed

Defining which range of values will be reported to the HID interface #104

kharar opened this issue Nov 25, 2018 · 6 comments

Comments

@kharar
Copy link

kharar commented Nov 25, 2018

Hi, great library, seems to work pretty consistently on Windows 7 and 10, great job!!

The flight simulator (FPV Freerider) that I am using is unable to recognize joystick positions in the negative region, that is having the center point at zero.
Here is their developers explanation: "On Windows, you need to setup so that the joystick channels go from 0 at minimum to 100 at maximum
(instead of -100 to +100)."

I have been fiddling with setting the AxisRange() but that does not seem to help a lot.
What I would really like is a procedure to set what max- and minimum values will be reported to the HID interface.
Is there any way that I could change this behavior within Arduino myself?
(or did I somehow misunderstand the meaning of the AxisRange() procedures?)

Below is a screenshot showing my range settings and the values that Windows 10 seemingly reports during calibration.

screenshot 2018-11-26 00 02 51

@kharar
Copy link
Author

kharar commented Nov 26, 2018

Well, just wanted to let you know that eventually I made it work with FreeriderFPV

I was able to fix my problem by changing the -_MINIMUM values within the joystick.cpp file like this:

#define JOYSTICK_AXIS_MINIMUM 0 // was -32767
#define JOYSTICK_AXIS_MAXIMUM 32767
#define JOYSTICK_SIMULATOR_MINIMUM 0 // was -32767
#define JOYSTICK_SIMULATOR_MAXIMUM 32767

Considering this I guess it would be pretty easy to construct a procedure call to adjust the max/min values

@PsykomantaBrain
Copy link

Turns out this applies to all Unity-based games. I was having the same problems here in my project and it was driving me nuts.

Thanks for posting the solution!

Cheers

@spaelectronics
Copy link

I was also having this problem, and the suggested settings above worked!

@ghost
Copy link

ghost commented Mar 8, 2019

Actually this hack is decreasing the resolution to half on the axes and hat switches.
I have made a proper 16 bit unsigned version, which is sending values between 0-65535 (instead of 32767):
https://github.com/gregnau/ArduinoJoystickLibrary

Working nice with Unity, but idk how it plays with other games.

@ghost
Copy link

ghost commented Mar 31, 2019

After a few weeks of experimenting with this unsigned mod, it seems like maybe not the best solution. Worked like a charm under Windows 10 (1803) and OSX, but had serious issues on Ubuntu (16.04).
It is expecting values between -32767 and 32767, while the proper range is transmitter with the usb descriptor.
Modifying the range used in the library to 0-32767 and setting the descriptors according solved the issue and now it works for sure on Windows and Linux. Both Unity and a lots of other games and sims.

@MHeironimus
Copy link
Owner

Version 2.1.0 of the library should address the issues seen in Unity (and other applications).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants