Conversation
Multiplication was just a short-hand for the 'if' statement logic anyways, counting on the compiler to do the optimization. Better to just write it out.
If for whatever reason you only want to set one axis, you can now do so without having to figure out where the middle of the pre-scaled range is. For now the X/Y range is still being treated the same because this is an edge case, not the main use (i.e. most users will still use joysticks as joysticks).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two functions for manipulating the joystick axes separately:
setJoystickXandsetJoystickY. For those rare cases where you want to only set one axis, you don't need to determine the pre-scaled 'center' value for the other axis.Note that both axes still share the same input range values (and I have no plans to change that). But I think these will be useful functions for those mapping non-joystick devices to the joystick outputs.
This pull request also changes the 4-button joystick function to use 'if' statements rather than multiplication in the back-end. It's more literally what I was trying to do, and it avoids requiring the compiler to optimize away the multiplication operation.