Skip to content

Commit 88a7b49

Browse files
committed
add safe joystick configuration functions which accept a GenericHID
1 parent 8326693 commit 88a7b49

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/main/java/org/carlmontrobotics/lib199/safeMode/SafeMode.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,46 @@ public static void disableButton(int joystickPort, int button) {
141141
safeDisabledButtons.get(joystickPort).add(button);
142142
}
143143

144+
public static void disableButton(GenericHID joystick, int button) {
145+
disableButton(joystick.getPort(), button);
146+
}
147+
144148
public static void disableAxis(int joystickPort, int axis) {
145149
safeDisabledAxes.putIfAbsent(joystickPort, createEmptyThreadSafeSet());
146150
safeDisabledAxes.get(joystickPort).add(axis);
147151
}
148152

153+
public static void disableAxis(GenericHID joystick, int axis) {
154+
disableAxis(joystick.getPort(), axis);
155+
}
156+
149157
public static void scaleAxis(int joystickPort, int axis, double factor) {
150158
safeScaledAxes.putIfAbsent(joystickPort, new ConcurrentHashMap<>());
151159
safeScaledAxes.get(joystickPort).put(axis, factor);
152160
}
153161

162+
public static void scaleAxis(GenericHID joystick, int axis, double factor) {
163+
scaleAxis(joystick.getPort(), axis, factor);
164+
}
165+
154166
public static void disablePOV(int joystickPort, int angle) {
155167
disablePOV(joystickPort, 0, angle);
156168
}
157169

170+
public static void disablePOV(GenericHID joystick, int angle) {
171+
disablePOV(joystick.getPort(), angle);
172+
}
173+
158174
public static void disablePOV(int joystickPort, int pov, int angle) {
159175
safeDisabledPOVs.putIfAbsent(joystickPort, new ConcurrentHashMap<>());
160176
safeDisabledPOVs.get(joystickPort).putIfAbsent(angle, createEmptyThreadSafeSet());
161177
safeDisabledPOVs.get(joystickPort).get(angle).add(angle);
162178
}
163179

180+
public static void disablePOV(GenericHID joystick, int pov, int angle) {
181+
disablePOV(joystick.getPort(), pov, angle);
182+
}
183+
164184
//#endregion
165185

166186
// NOTE: Unlike with maps, there are a few different ways to make sets thread-safe

0 commit comments

Comments
 (0)