mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Disable deadzone scaling because it's pretty broken
This commit is contained in:
parent
52e5817327
commit
6de5cf8925
@ -3,8 +3,6 @@ package com.limelight.nvstream.input;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import com.limelight.utils.Vector2d;
|
||||
|
||||
public class ControllerPacket extends InputPacket {
|
||||
public static final byte[] HEADER =
|
||||
{
|
||||
@ -48,11 +46,11 @@ public class ControllerPacket extends InputPacket {
|
||||
public static final short PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
InputPacket.HEADER_LENGTH;
|
||||
|
||||
// This is the highest value that is read as zero on the PC
|
||||
public static final short MIN_MAGNITUDE = 7000;
|
||||
|
||||
// Set this flag if you want ControllerPacket to handle scaling for you
|
||||
// Note: You MUST properly handle deadzones to use this flag
|
||||
// You MUST properly handle deadzones to use this flag
|
||||
//
|
||||
// Note: This flag does nothing right now. It causes some controllers
|
||||
// to behave badly.
|
||||
public static boolean enableAxisScaling = false;
|
||||
|
||||
short buttonFlags;
|
||||
@ -73,46 +71,11 @@ public class ControllerPacket extends InputPacket {
|
||||
this.leftTrigger = leftTrigger;
|
||||
this.rightTrigger = rightTrigger;
|
||||
|
||||
Vector2d leftStick = handleDeadZone(leftStickX, leftStickY);
|
||||
this.leftStickX = (short) leftStick.getX();
|
||||
this.leftStickY = (short) leftStick.getY();
|
||||
this.leftStickX = leftStickX;
|
||||
this.leftStickY = leftStickY;
|
||||
|
||||
Vector2d rightStick = handleDeadZone(rightStickX, rightStickY);
|
||||
this.rightStickX = (short) rightStick.getX();
|
||||
this.rightStickY = (short) rightStick.getY();
|
||||
}
|
||||
|
||||
private static Vector2d inputVector = new Vector2d();
|
||||
private static Vector2d normalizedInputVector = new Vector2d();
|
||||
|
||||
// This function is NOT THREAD SAFE!
|
||||
private static Vector2d handleDeadZone(short x, short y) {
|
||||
// Get out fast if we're in the dead zone
|
||||
if (x == 0 && y == 0) {
|
||||
return Vector2d.ZERO;
|
||||
}
|
||||
|
||||
// Reinitialize our cached Vector2d object
|
||||
inputVector.initialize(x, y);
|
||||
|
||||
if (enableAxisScaling) {
|
||||
// Remember our original magnitude for scaling later
|
||||
double magnitude = inputVector.getMagnitude();
|
||||
|
||||
// Scale to hit a minimum magnitude
|
||||
inputVector.getNormalized(normalizedInputVector);
|
||||
|
||||
normalizedInputVector.setX(normalizedInputVector.getX() * MIN_MAGNITUDE);
|
||||
normalizedInputVector.setY(normalizedInputVector.getY() * MIN_MAGNITUDE);
|
||||
|
||||
// Now scale the rest of the way
|
||||
normalizedInputVector.scalarMultiply((32766.0 / MIN_MAGNITUDE) / (32768.0 / magnitude));
|
||||
|
||||
return normalizedInputVector;
|
||||
}
|
||||
else {
|
||||
return inputVector;
|
||||
}
|
||||
this.rightStickX = rightStickX;
|
||||
this.rightStickY = rightStickY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user