rajetic / auto_oculus_touch

Tools to allow AutoHotKey to read the state of the Oculus Touch controllers.
95 stars 19 forks source link

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

Open dark-swordsman opened 3 years ago

dark-swordsman commented 3 years ago

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 commented 3 years ago

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((value0.5f + 0.5f) 0x7999) + 1;

to this: long v = long((value0.5f + 0.5f) 0x8000);

rajetic commented 3 years ago

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((value0.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((value0.5f + 0.5f) 0x7fff) + 1;