From 6de5cf89259dc2fc26205dc156ea7891763f6bf1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 25 Jan 2015 17:02:00 -0500 Subject: [PATCH] Disable deadzone scaling because it's pretty broken --- .../nvstream/input/ControllerPacket.java | 53 +++---------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/moonlight-common/src/com/limelight/nvstream/input/ControllerPacket.java b/moonlight-common/src/com/limelight/nvstream/input/ControllerPacket.java index f1ca1d13..73e25ebb 100644 --- a/moonlight-common/src/com/limelight/nvstream/input/ControllerPacket.java +++ b/moonlight-common/src/com/limelight/nvstream/input/ControllerPacket.java @@ -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