-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogitechController.java
107 lines (81 loc) · 2.45 KB
/
LogitechController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package org.usfirst.frc.team5112.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.buttons.Trigger;
public class LogitechController extends Joystick {
public JoystickButton buttonA = new JoystickButton(this, 1);
public JoystickButton buttonB = new JoystickButton(this, 2);
public JoystickButton buttonX = new JoystickButton(this, 3);
public JoystickButton buttonY = new JoystickButton(this, 4);
public JoystickButton leftBumper = new JoystickButton(this, 5);
public JoystickButton rightBumper = new JoystickButton(this, 6);
public JoystickButton buttonBack = new JoystickButton(this, 7);
public JoystickButton buttonStart = new JoystickButton(this, 8);
public JoystickButton buttonJoystickLeft = new JoystickButton(this, 9);
public JoystickButton buttonJoystickRight = new JoystickButton(this, 10);
public LogitechController(int port) {
super(port);
}
public double getDPadXAxis() {
return getRawAxis(0);
}
public double getDPadYAxis() {
return getRawAxis(1);
}
public double getLeftTrigger() {
return getRawAxis(2);
}
public double getRightTrigger() {
return getRawAxis(3);
}
public double getRightXAxis() {
return getRawAxis(4);
}
public double getRightYAxis() {
return getRawAxis(5);
}
public final Trigger leftTrigger = new Trigger() {
@Override
public boolean get() {
return Math.round(getLeftTrigger()) == 1;
}
};
public final Trigger rightTrigger = new Trigger() {
@Override
public boolean get() {
return Math.round(getRightTrigger()) == 1;
}
};
public static final int LJOYSTICK_NORTH = 0;
public static final int LJOYSTICK_NORTHEAST = 45;
public static final int LJOYSTICK_EAST = 90;
public static final int LJOYSTICK_SOUTHEAST = 135;
public static final int LJOYSTICK_SOUTH = 180;
public static final int LJOYSTICK_SOUTHWEST = 225;
public static final int LJOYSTICK_WEST = 270;
public static final int LJOYSTICK_NORTHWEST = 315;
public final Trigger DPAD_UP = new Trigger() {
@Override
public boolean get() {
return getPOV() == 0;
}
};
public final Trigger DPAD_DOWN = new Trigger() {
@Override
public boolean get() {
return getPOV() == 180;
}
};
public final Trigger DPAD_RIGHT = new Trigger() {
@Override
public boolean get() {
return getPOV() == 90;
}
};
public final Trigger DPAD_LEFT = new Trigger() {
@Override
public boolean get() {
return getPOV() == 270;
}
};
}