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

vJoy axis not going all the way to 100% #19

Open
dark-swordsman opened this issue Sep 6, 2020 · 2 comments
Open

vJoy axis not going all the way to 100% #19

dark-swordsman opened this issue Sep 6, 2020 · 2 comments

Comments

@dark-swordsman
Copy link

dark-swordsman commented Sep 6, 2020

Hello,

I used this mod to implement custom joysticks into Flight Simulator. Re-writing one of the scripts, I was able to effectively create a "slider" that goes from -1 to 1 to work as throttle.

However, I noticed that my throttle was only going to 95% (or 90% on the slider, since it's -100% to 100%).

Here's a screenshot showing the slider and its max state:
image

Even manually setting the vJoy to 1 or a value higher than 1 (SetvJoyAxis(HID_USAGE_SL0, 1.1)), it only goes to 90%.

I noticed that it also does this for all the other axis. Basically any axis is limited to 90%. I believe this is an issue with the vJoyInterface.dll, but I am not sure. Is there something else I am missing or need to check?

@DawsSangio
Copy link

DawsSangio commented Apr 16, 2021

Yes, I found this bug too.
I think the axix math calculation is wrong.
I was able to fix it changing line #177 in dllmain.cpp:

from this:
long v = long((value*0.5f + 0.5f) * 0x7999) + 1;

to this:
long v = long((value*0.5f + 0.5f) * 0x8000);

@rajetic
Copy link
Owner

rajetic commented Apr 17, 2021

Oops, not sure how I missed that one.
Somehow I used 0x7999 instead of 0x7fff. :( (No, I really understand hex! I swear)

long v = long((value*0.5f + 0.5f) * 0x8000); is incorrect though (but closer to correct than my first version.
This would convert a (-1.0, 1.0) range to (0, 32768).
But the vJoy documentation states that axes must be 1 to 32768, not 0 to 32768.

So the final code should be:
long v = long((value*0.5f + 0.5f) * 0x7fff) + 1;

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

3 participants