@@ -0,0 +1,1909 @@
+package org.usfirst.frc2832.Robot_2015;%0A%0Aimport edu.wpi.first.wpilibj.Joystick;%0A%0Apublic class GamepadDeadzoned extends Joystick %7B%0A%09%0A%09private double range = 0.15;%0A%09%0A%09private int%5B%5D leftstickAxis = %7B0, 1%7D;%0A%09private int%5B%5D rightstickAxis = %7B4, 5%7D;%0A%09%0A%09public GamepadDeadzoned(int port) %7B%0A%09%09super(port);%0A%09%7D%0A%0A%09private double deadzone(double in) %7B%0A%09%09return (Math.abs(in) %3C range ? 0 : in);%0A%09%7D%0A%09%0A%09private boolean arrContains(int%5B%5D arr, int x) %7B%0A%09%09for(int a : arr) %7B%0A%09%09%09if (a == x)%0A%09%09%09%09return (true);%0A%09%09%7D%0A%09%09%0A%09%09return (false);%0A%09%7D%0A%09%0A%09%0A%09/**%0A%09 * Use getRawAxis with your axis ID instead of this method%0A%09 * 0 and 1 for left stick%0A%09 * 2 and 3 for triggers%0A%09 * 4 and 5 for right stick%0A%09 */%0A%09@Deprecated%0A%09@Override%0A%09public double getAxis(AxisType axis) %7B%0A%09%09return (getRawAxis(axis.value));%0A%09%7D%0A%09%0A%09/**%0A%09 * Radial deadzoning helper method%0A%09 * @param x%0A%09 * @param y%0A%09 * @return%0A%09 */%0A%09private Coordinate deadzone2D(double x, double y) %7B%0A%09%09double magnitude = Math.sqrt(x * x + y * y);%0A%09%09if (magnitude %3C= range)%0A%09%09%09return new Coordinate(0,0);%0A%09%09double scale = (magnitude - range) / (1 - range);%0A%09%09return (new Coordinate(x / magnitude * scale, y / magnitude * scale));%0A%09%7D%0A%09%0A%09@Override%0A%09public double getRawAxis(int axis) %7B%0A%09%09if (arrContains(leftstickAxis, axis)) %7B%0A%09%09%09Coordinate p = (deadzone2D(%0A%09%09%09%09%09super.getRawAxis(leftstickAxis%5B0%5D), %0A%09%09%09%09%09super.getRawAxis(leftstickAxis%5B1%5D)));%0A%09%09%09if (leftstickAxis%5B0%5D == axis)%0A%09%09%09%09return (p.x);%0A%09%09%09else%0A%09%09%09%09return (p.y);%0A%09%09%7D%0A%09%09if (arrContains(rightstickAxis, axis)) %7B%0A%09%09%09Coordinate p = (deadzone2D(%0A%09%09%09%09%09super.getRawAxis(rightstickAxis%5B0%5D), %0A%09%09%09%09%09super.getRawAxis(rightstickAxis%5B1%5D)));%0A%09%09%09if (rightstickAxis%5B0%5D == axis)%0A%09%09%09%09return (p.x);%0A%09%09%09else%0A%09%09%09%09return (p.y);%0A%09%09%7D%0A%09%09%0A%09%09return (deadzone(super.getRawAxis(axis)));%0A%09%7D%0A%09%0A%09public double getDebugAxis(int axis) %7B%0A%09%09return super.getRawAxis(axis);%0A%09%7D%0A%7D%0AStatus API Training Shop Blog About Pricing%0A%C2%A9 2016 GitHub, Inc. Terms Privacy Security Contact Help%0A

Create GamepadDeadzoned.java