SDL: Always use sub-pixel joystick pointer #914
Merged
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.
With the new joystick pointer speed adjustment in the SDL backend which can be less then one pixel per frame delay, all calls to
ProcessMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER)
with those exact second and third arguments need to be prevented from updating _km.x and _km.y since that will destroy the sub-pixel resolution and make the joystick pointer control less precise. But calls to ProcessMouseEvent with other arguments should still update _km.x and _km.y.
Before this PR, the call to ProcessMouseEvent inside handleKbdMouse was made to work correctly by first saving and, after the call, re-loading the hi-res _km.x and _km.y coordinate values. But all the other calls still exhibit the problem of overwriting _km.x and _km.y with imprecise numbers.
To fix this, in this PR, I removed the update of _km.x and _km.y from the processMouseEvent routine, and instead added explicit _km updates to the sources where they are needed. Since most calls to ProcessMouseEvent are in the form ProcessMouseEvent(_km.x / MULTIPLIER, _km.y / MULTIPLIER) this did not require many changes, and I think the result is (IMO) in clearer code since processMouseEvent does not have this side-effect of changing _km.x and _km.y anymore.