Reduce gamepad mouse latency by one frame

This commit is contained in:
SerpentSpirale 2021-11-26 00:06:40 +01:00
parent 5289c0164f
commit fb21ddce9a

View File

@ -206,11 +206,24 @@ public class Gamepad {
private void updateMouseJoystick(MotionEvent event){ private void updateMouseJoystick(MotionEvent event){
GamepadJoystick currentJoystick = lastGrabbingState ? rightJoystick : leftJoystick; GamepadJoystick currentJoystick = lastGrabbingState ? rightJoystick : leftJoystick;
lastHorizontalValue = currentJoystick.getHorizontalAxis(event); float horizontalValue = currentJoystick.getHorizontalAxis(event);
lastVerticalValue = currentJoystick.getVerticalAxis(event); float verticalValue = currentJoystick.getVerticalAxis(event);
if(horizontalValue != lastHorizontalValue || verticalValue != lastVerticalValue){
lastHorizontalValue = horizontalValue;
lastVerticalValue = verticalValue;
mouseMagnitude = currentJoystick.getMagnitude(event); mouseMagnitude = currentJoystick.getMagnitude(event);
mouseAngle = currentJoystick.getAngleRadian(event); mouseAngle = currentJoystick.getAngleRadian(event);
tick(System.nanoTime());
return;
}
lastHorizontalValue = horizontalValue;
lastVerticalValue = verticalValue;
mouseMagnitude = currentJoystick.getMagnitude(event);
mouseAngle = currentJoystick.getAngleRadian(event);
} }
private void updateDirectionalJoystick(MotionEvent event){ private void updateDirectionalJoystick(MotionEvent event){