Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
ControllerInterface/DolphinQt: Improve input detection. #7829
As you may know, all
Axes receive two inputs (one for each direction) (e.g. X- and X+). Input backends were expected to make each return a value from 0.0 to 1.0 by clamping off negative values (so a negative X does not affect the X+ Input).
Unfortunately some silly devices like to represent inputs (usually triggers) across an entire axis so a neutral state is seen as a fully activated X- or X+.
FullAnalogSurface was introduced to solve this which maps the complete range of an axis from 0.0 to 1.0.
These workaround "full surface" inputs are added in addition to the regular ones because we have no way of knowing which representation is sensible until the user tries to use them.
Input detection logic unfortunately did poorly at determining which virtual input is desired because when a user physically moves an axis both the regular "X+" and "full surface" "X-+" are seen moving from 0.0 to 1.0 (just at slightly different rates).
What this change does is allow input backends to return negative values when opposing inputs are activated (negatives are clamped later).
Mapping logic can observe these negatives to properly detect the difference between a user moving an axis from neutral vs. a move from full negative to full positive.
The negatives are still clamped off before they reach expression parser (everything should remain the same other than mapping detection logic).
It appears by an oversight of what was expected, Android never clamped negative values. I suspect this change will fix all axes on Android from being overly sensitive because of bad math.
Note: I have purposely not "unclamped" Axis::GetState in a few backends because of some other pending cleanups.
I should mention providing the unclamped value is not required. It just allows mapping logic to detect false positives.
I hope that all makes sense. ;P
I also removed the std::async hackery in DolphinQt when mapping "All Devices".