Android: Ignore joystick axis movements in the flat area.

Now that all inputs are corrected to zero-centered, we can use getFlat()
to ignore movements that are just noise.

This eliminates a lot of drift when the controller is at rest, notably
on the character select screen in Melee.
This commit is contained in:
Mike 2017-11-01 18:29:33 -07:00
parent 6787fcb712
commit 1f81e13d81
1 changed files with 10 additions and 1 deletions

View File

@ -735,7 +735,16 @@ public final class EmulationActivity extends AppCompatActivity
int axis = range.getAxis();
float origValue = event.getAxisValue(axis);
float value = mControllerMappingHelper.scaleAxis(input, axis, origValue);
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, value);
// If the input is still in the "flat" area, that means it's really zero.
// This is used to compensate for imprecision in joysticks.
if (Math.abs(value) > range.getFlat())
{
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, value);
}
else
{
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, 0.0f);
}
}
return true;