JoyHat () problems
BlitzMax Forums/BlitzMax Programming/JoyHat () problems
| ||
Hello, I've been recently working with gamepads. I was able to get everything to work except the D-Pad. Here's the code: Twinprogrammer |
| ||
That's probably bound to fail because of floating-point inaccuracy, which is not a Blitz problem, but a limitation of floating-point representation of numbers. In short, don't expect to ever get such accurate results with floating point numbers. However, even with that taken into account, you are in fact trying to store the (fractional) result in an integer -- "Local Pad" has no type and so is therefore defaulting to integers/whole numbers. Still, see above, and be prepared to work around it. |
| ||
To add to the above, change "Local Pad" to "Local Pad:Float", but Print/DrawText the contents of "Pad" to see your actual input. Don't ever rely on floating point (fractional) values to be exact in any programming language! Modify this to use "less than/greater than" for its checks, and expect to have to provide some padding around these values. |
| ||
Couldn't you consider the hatswitch input to be a radian angle value? Assuming you're using it to move something you wouldn't need to do any greater than/less than checks. Cheers Charlie |
| ||
You're right. I just changed Pad to be a float and it works !Local Pad:Float = JoyHat ( PlayerId - 1 ) Thanks ! Twinprogrammer Last edited 2012 |