Closed RustyRaptor closed 6 years ago
Thanks for the report. Do the joystick axes move correctly in the "joysticks" tab of the DS? This is to know if the problem is with SDL/QJoysticks or the LibDS protocol implementation.
They do seem to move correctly in the joysticks tab. speaking of which I tried using the virtual joystick and setting it's range to 99 and it didn't work.
Same problem here. I'll take a look to see if I can find the source of the problem.
@jacksondm33 Thanks! Let me know if you have any questions about the source code of LibDS.
uint8_t DS_FloatToByte (const float value, const float max)
{
if (value != 0 && max != 0 && value <= max) {
int percent = (int) (value / max) * (0xFF / 2);
return (uint8_t) (percent & 0xFF);
}
return 0;
}
The problem is here. When calculating the percent, it converts value / max
to an integer before multiplying it by 0xFF / 2
.
Fixed in #9
Awesome. Thanks. Now we can stop having to put up with the monster known as labview DS :) . I wish they would legalize this station in competitions honestly.
This problem isn't present in the LabView driverstation. When I use a joystick it seems to not return any value until the joystick is pushed all the way to 1 or -1. I am guessing it's converting the float to an integer so you end up with 0 until you hit 1. I've tried multiple joysticks from different vendors.
Could this be the function causing it? I am not entirely certain how it works.