|
6 | 6 |
|
7 | 7 | public class MayhemOperatorPad {
|
8 | 8 |
|
9 |
| - public final class OPERATOR_PAD_AXIS { |
10 |
| - public static final int OPERATOR_PAD_LEFT_X_AXIS = 0; |
11 |
| - public static final int OPERATOR_PAD_LEFT_Y_AXIS = 1; |
12 |
| - public static final int OPERATOR_PAD_RIGHT_X_AXIS = 2; |
13 |
| - public static final int OPERATOR_PAD_RIGHT_Y_AXIS = 3; |
14 |
| - } |
15 |
| - |
16 |
| - public final Joystick OPERATOR_PAD = new Joystick(Joysticks.OPERATOR_GAMEPAD); |
17 |
| - public final Button OPERATOR_PAD_BUTTON_ONE = new JoystickButton(OPERATOR_PAD, 1); |
18 |
| - public final Button OPERATOR_PAD_BUTTON_TWO = new JoystickButton(OPERATOR_PAD, 2); |
19 |
| - public final Button OPERATOR_PAD_BUTTON_THREE = new JoystickButton(OPERATOR_PAD, 3); |
20 |
| - public final Button OPERATOR_PAD_BUTTON_FOUR = new JoystickButton(OPERATOR_PAD, 4); |
21 |
| - public final Button OPERATOR_PAD_BUTTON_FIVE = new JoystickButton(OPERATOR_PAD, 5); |
22 |
| - public final Button OPERATOR_PAD_BUTTON_SIX = new JoystickButton(OPERATOR_PAD, 6); |
23 |
| - public final Button OPERATOR_PAD_BUTTON_SEVEN = new JoystickButton(OPERATOR_PAD, 7); |
24 |
| - public final Button OPERATOR_PAD_BUTTON_EIGHT = new JoystickButton(OPERATOR_PAD, 8); |
25 |
| - public final Button OPERATOR_PAD_BUTTON_NINE = new JoystickButton(OPERATOR_PAD, 9); |
26 |
| - public final Button OPERATOR_PAD_BUTTON_TEN = new JoystickButton(OPERATOR_PAD, 10); |
27 |
| - public final Button OPERATOR_PAD_BUTTON_ELEVEN = new JoystickButton(OPERATOR_PAD, 11); |
28 |
| - public final Button OPERATOR_PAD_BUTTON_TWELVE = new JoystickButton(OPERATOR_PAD, 12); |
29 |
| - public final Button FORCE_FIRE_BUTTON = new AndJoystickButton(OPERATOR_PAD, 5, OPERATOR_PAD, 7); |
30 |
| - |
31 |
| - public final JoystickPOVButton OPERATOR_PAD_D_PAD_LEFT = new JoystickPOVButton(OPERATOR_PAD, 270); |
32 |
| - public final JoystickPOVButton OPERATOR_PAD_D_PAD_RIGHT = new JoystickPOVButton(OPERATOR_PAD, 90); |
33 |
| - public final JoystickPOVButton OPERATOR_PAD_D_PAD_UP = new JoystickPOVButton(OPERATOR_PAD, 0); |
34 |
| - public final JoystickPOVButton OPERATOR_PAD_D_PAD_DOWN = new JoystickPOVButton(OPERATOR_PAD, 180); |
35 |
| - |
36 |
| - // Operator Control Buttons |
37 |
| - public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD, |
38 |
| - OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY); |
39 |
| - public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD, |
40 |
| - OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY); |
41 |
| - public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD, |
42 |
| - OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY); |
43 |
| - public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD, |
44 |
| - OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY); |
45 |
| - |
| 9 | + public final class OPERATOR_PAD_AXIS { |
46 | 10 | public static final int OPERATOR_PAD_LEFT_X_AXIS = 0;
|
47 | 11 | public static final int OPERATOR_PAD_LEFT_Y_AXIS = 1;
|
48 | 12 | public static final int OPERATOR_PAD_RIGHT_X_AXIS = 2;
|
49 | 13 | public static final int OPERATOR_PAD_RIGHT_Y_AXIS = 3;
|
| 14 | + } |
| 15 | + |
| 16 | + public final Joystick OPERATOR_PAD = new Joystick(Joysticks.OPERATOR_GAMEPAD); |
| 17 | + public final Button OPERATOR_PAD_BUTTON_ONE = new JoystickButton(OPERATOR_PAD, 1); |
| 18 | + public final Button OPERATOR_PAD_BUTTON_TWO = new JoystickButton(OPERATOR_PAD, 2); |
| 19 | + public final Button OPERATOR_PAD_BUTTON_THREE = new JoystickButton(OPERATOR_PAD, 3); |
| 20 | + public final Button OPERATOR_PAD_BUTTON_FOUR = new JoystickButton(OPERATOR_PAD, 4); |
| 21 | + public final Button OPERATOR_PAD_BUTTON_FIVE = new JoystickButton(OPERATOR_PAD, 5); |
| 22 | + public final Button OPERATOR_PAD_BUTTON_SIX = new JoystickButton(OPERATOR_PAD, 6); |
| 23 | + public final Button OPERATOR_PAD_BUTTON_SEVEN = new JoystickButton(OPERATOR_PAD, 7); |
| 24 | + public final Button OPERATOR_PAD_BUTTON_EIGHT = new JoystickButton(OPERATOR_PAD, 8); |
| 25 | + public final Button OPERATOR_PAD_BUTTON_NINE = new JoystickButton(OPERATOR_PAD, 9); |
| 26 | + public final Button OPERATOR_PAD_BUTTON_TEN = new JoystickButton(OPERATOR_PAD, 10); |
| 27 | + public final Button OPERATOR_PAD_BUTTON_ELEVEN = new JoystickButton(OPERATOR_PAD, 11); |
| 28 | + public final Button OPERATOR_PAD_BUTTON_TWELVE = new JoystickButton(OPERATOR_PAD, 12); |
| 29 | + public final Button FORCE_FIRE_BUTTON = new AndJoystickButton(OPERATOR_PAD, 5, OPERATOR_PAD, 7); |
| 30 | + |
| 31 | + public final JoystickPOVButton OPERATOR_PAD_D_PAD_LEFT = new JoystickPOVButton(OPERATOR_PAD, 270); |
| 32 | + public final JoystickPOVButton OPERATOR_PAD_D_PAD_RIGHT = new JoystickPOVButton(OPERATOR_PAD, 90); |
| 33 | + public final JoystickPOVButton OPERATOR_PAD_D_PAD_UP = new JoystickPOVButton(OPERATOR_PAD, 0); |
| 34 | + public final JoystickPOVButton OPERATOR_PAD_D_PAD_DOWN = new JoystickPOVButton(OPERATOR_PAD, 180); |
| 35 | + |
| 36 | + // Operator Control Buttons |
| 37 | + public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD, |
| 38 | + OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY); |
| 39 | + public final JoystickAxisButton OPERATOR_PAD_LEFT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD, |
| 40 | + OPERATOR_PAD_AXIS.OPERATOR_PAD_LEFT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY); |
| 41 | + public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_UP = new JoystickAxisButton(OPERATOR_PAD, |
| 42 | + OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.NEGATIVE_ONLY); |
| 43 | + public final JoystickAxisButton OPERATOR_PAD_RIGHT_Y_AXIS_DOWN = new JoystickAxisButton(OPERATOR_PAD, |
| 44 | + OPERATOR_PAD_AXIS.OPERATOR_PAD_RIGHT_Y_AXIS, JoystickAxisButton.POSITIVE_ONLY); |
| 45 | + |
| 46 | + public static final int OPERATOR_PAD_LEFT_X_AXIS = 0; |
| 47 | + public static final int OPERATOR_PAD_LEFT_Y_AXIS = 1; |
| 48 | + public static final int OPERATOR_PAD_RIGHT_X_AXIS = 2; |
| 49 | + public static final int OPERATOR_PAD_RIGHT_Y_AXIS = 3; |
| 50 | + |
| 51 | + private static final double Y_AXIS_DEAD_ZONE_PERCENT = 0.15; |
| 52 | + private static final double X_AXIS_DEAD_ZONE_PERCENT = 0.15; |
| 53 | + |
| 54 | + public double getLeftYAxis() { |
| 55 | + double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_Y_AXIS); |
| 56 | + return ApplyDeadZone(value, Y_AXIS_DEAD_ZONE_PERCENT); |
| 57 | + } |
| 58 | + |
| 59 | + public double getLeftXAxis() { |
| 60 | + double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_X_AXIS); |
| 61 | + return ApplyDeadZone(value, X_AXIS_DEAD_ZONE_PERCENT); |
| 62 | + } |
| 63 | + |
| 64 | + public double getRightYAxis() { |
| 65 | + double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_RIGHT_Y_AXIS); |
| 66 | + return ApplyDeadZone(value, Y_AXIS_DEAD_ZONE_PERCENT); |
| 67 | + } |
50 | 68 |
|
51 |
| - private static final double Y_AXIS_DEAD_ZONE_PERCENT = 0.15; |
| 69 | + public double getRightXAxis() { |
| 70 | + double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_X_AXIS); |
| 71 | + return ApplyDeadZone(value, X_AXIS_DEAD_ZONE_PERCENT); |
| 72 | + } |
52 | 73 |
|
53 |
| - public double getLeftYAxis() { |
54 |
| - // SteeringX is the "X" axis of the right stick on the Driver Gamepad. |
55 |
| - double value = OPERATOR_PAD.getRawAxis(OPERATOR_PAD_LEFT_Y_AXIS); |
56 |
| - if (Math.abs(value) < Y_AXIS_DEAD_ZONE_PERCENT) { |
57 |
| - value = 0.0; |
58 |
| - } |
| 74 | + private double ApplyDeadZone(double value, double deadZone) { |
59 | 75 |
|
60 |
| - // if the slow button is pressed, cut the steering value in half. |
61 |
| - // if (DRIVER_PAD_RIGHT_LOWER_TRIGGER_BUTTON.get()) { |
62 |
| - // value = value / 2.0; |
63 |
| - // } |
64 |
| - return value; |
| 76 | + if (Math.abs(value) < deadZone) { |
| 77 | + return 0; |
65 | 78 | }
|
| 79 | + return value; |
| 80 | + } |
66 | 81 | }
|
0 commit comments