public GamepadBasegetButton
> getButtongetAxis
> getAxisgetButtonAsBoolean
>boolean getButtonAsBooleangetAxisAsDouble
>double getAxisAsDoublegetAxisAsBoolean
>boolean getAxisAsBooleangetLeftStick
>> getLeftStick()
@@ -2302,7 +2302,7 @@
getRightStick
>>
getRightStick()
@@ -2328,7 +2328,7 @@
getDpad
>>
getDpad()
@@ -2348,7 +2348,7 @@
periodic
>void
periodic()
@@ -2380,7 +2380,7 @@
getGamepad
>com.qualcomm.robotcore.hardware.Gamepad
getGamepad()
@@ -2405,7 +2405,7 @@
buttonInstance
>
buttonInstanceaxisInstance
> axisInstancerumbleBlips
>void rumbleBlips(int blips)
@@ -2637,7 +2637,7 @@
rumbleBlip
>void
rumbleBlip()
@@ -2653,7 +2653,7 @@
rumble
>void
rumble(double seconds)
@@ -2675,7 +2675,7 @@
isRumbling
>boolean
isRumbling()
@@ -2695,7 +2695,7 @@
stopRumble
>void
stopRumble()
@@ -2711,7 +2711,7 @@
rumble
>void
rumble()
@@ -2737,7 +2737,7 @@
setEnabled
>>
setEnabled(boolean enable)
@@ -2783,7 +2783,7 @@
isEnabled
>boolean
isEnabled()
diff --git a/docs/TechnoLib/src-html/com/technototes/library/RobotLibrary.html b/docs/TechnoLib/src-html/com/technototes/library/RobotLibrary.html
index a0bc0702..b6253890 100644
--- a/docs/TechnoLib/src-html/com/technototes/library/RobotLibrary.html
+++ b/docs/TechnoLib/src-html/com/technototes/library/RobotLibrary.html
@@ -28,7 +28,7 @@
012 * @return Library version
013 */
014 public static String getVersion() {
-
015 return "1.9.9-alpha";
+
015 return "2.0.1";
016 }
017
018 /** Get if the library is a pre release
@@ -36,7 +36,7 @@
020 * @return If this library version is a pre release
021 */
022 public static boolean isPreRelease() {
-
023 return true;
+
023 return false;
024 }
025}
diff --git a/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Axis.html b/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Axis.html
index 3b666c2f..c434bf3b 100644
--- a/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Axis.html
+++ b/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Axis.html
@@ -30,495 +30,494 @@
014 * @param <U> The class for the axis components on the gamepad
015 * @author Alex Stedman
016 */
-
017public class GamepadBase<T extends ButtonBase, U extends AxisBase> implements Periodic, CanBeEnabled<GamepadBase<T, U>> {
-
018
-
019 private boolean enabled = true;
-
020 // normal gamepad
-
021 private Gamepad gamepad;
-
022 /**
-
023 * The button objects for the XBox game controller
-
024 */
-
025 public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
-
026 /**
-
027 * The button objects for the PS4 game controller
-
028 */
-
029 public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
-
030 /**
-
031 * The button objects for both the XBox and PS4 controllers
-
032 */
-
033 public T leftBumper, rightBumper, dpadUp, dpadDown, dpadLeft, dpadRight, leftStickButton, rightStickButton;
-
034 /**
-
035 * The axis objects
-
036 */
-
037 public U leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY;
-
038 /**
-
039 * The stick objects
-
040 */
-
041 public GamepadStick<U, T> leftStick, rightStick;
-
042 /**
-
043 * The dpad object
-
044 */
-
045 public GamepadDpad<T> dpad;
-
046
-
047 // periodics to run
-
048 private Periodic[] periodics;
-
049 private CanBeEnabled<?>[] enablables;
-
050
-
051 private Class<T> buttonClass;
-
052 private Class<U> axisClass;
-
053
-
054 /**
-
055 * Creates a gamepad with these parameters
-
056 *
-
057 * @param g The gamepad to base around
-
058 * @param bClass The class object passed for the button components (Should be the same as the one used for the class parameter T)
-
059 * @param aClass The class object passed for the axis components (Should be the same as the one used for the class parameter U)
-
060 */
-
061 public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
-
062 gamepad = g;
-
063 buttonClass = bClass;
-
064 axisClass = aClass;
-
065 try {
-
066 setComponents(g);
-
067 } catch (Exception e) {
-
068 e.printStackTrace();
-
069 }
-
070
-
071 leftStick = new GamepadStick<>(leftStickX, leftStickY, leftStickButton);
-
072 rightStick = new GamepadStick<>(rightStickX, rightStickY, rightStickButton);
-
073 dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
-
074 periodics =
-
075 new Periodic[] {
-
076 xbox_a,
-
077 xbox_b,
-
078 xbox_x,
-
079 xbox_y,
-
080 xbox_start,
-
081 xbox_back,
-
082 leftBumper,
-
083 rightBumper,
-
084 leftTrigger,
-
085 rightTrigger,
-
086 leftStick,
-
087 rightStick,
-
088 dpad,
-
089 };
-
090 enablables =
-
091 new CanBeEnabled[] {
-
092 xbox_a,
-
093 xbox_b,
-
094 xbox_x,
-
095 xbox_y,
-
096 xbox_start,
-
097 xbox_back,
-
098 leftBumper,
-
099 rightBumper,
-
100 leftTrigger,
-
101 rightTrigger,
-
102 leftStick,
-
103 rightStick,
-
104 dpad,
-
105 };
-
106 }
-
107
-
108 // to actually instantiate the objects
-
109 private void setComponents(Gamepad g)
-
110 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
111 // buttons
-
112 // a=new T();
-
113 xbox_a = buttonInstance(() -> g.a);
-
114 xbox_b = buttonInstance(() -> g.b);
-
115 xbox_x = buttonInstance(() -> g.x);
-
116 xbox_y = buttonInstance(() -> g.y);
-
117 ps_cross = xbox_a;
-
118 ps_circle = xbox_b;
-
119 ps_square = xbox_x;
-
120 ps_triangle = xbox_y;
-
121
-
122 xbox_start = buttonInstance(() -> g.start);
-
123 xbox_back = buttonInstance(() -> g.back);
-
124 ps_share = xbox_back;
-
125 ps_options = xbox_start;
-
126
-
127 // bumpers
-
128 leftBumper = buttonInstance(() -> g.left_bumper);
-
129 rightBumper = buttonInstance(() -> g.right_bumper);
-
130
-
131 // dpad
-
132 dpadUp = buttonInstance(() -> g.dpad_up);
-
133 dpadDown = buttonInstance(() -> g.dpad_down);
-
134 dpadLeft = buttonInstance(() -> g.dpad_left);
-
135 dpadRight = buttonInstance(() -> g.dpad_right);
-
136
-
137 // left stick
-
138 leftStickX = axisInstance(() -> g.left_stick_x);
-
139 leftStickY = axisInstance(() -> g.left_stick_y);
-
140 leftStickButton = buttonInstance(() -> g.left_stick_button);
-
141
-
142 // right stick
-
143 rightStickX = axisInstance(() -> g.right_stick_x);
-
144 rightStickY = axisInstance(() -> g.right_stick_y);
-
145 rightStickButton = buttonInstance(() -> g.right_stick_button);
-
146
-
147 // triggers
-
148 leftTrigger = axisInstance(() -> g.left_trigger);
-
149 rightTrigger = axisInstance(() -> g.right_trigger);
-
150 }
-
151
-
152 // enums
-
153
-
154 /**
-
155 * Button enum for all buttons on gamepad
-
156 */
-
157 public enum Button {
-
158 /**
-
159 * XBox A button
-
160 */
-
161 XBOX_A,
-
162 /**
-
163 * XBox B button
-
164 */
-
165 XBOX_B,
-
166 /**
-
167 * XBox X button
-
168 */
-
169 XBOX_X,
-
170 /**
-
171 * XBox Y button
-
172 */
-
173 XBOX_Y,
-
174 /**
-
175 * PS4 Cross (X) button
-
176 */
-
177 PS_CROSS,
-
178 /**
-
179 * PS4 Circle (O) button
-
180 */
-
181 PS_CIRCLE,
-
182 /**
-
183 * PS4 Square button
-
184 */
-
185 PS_SQUARE,
-
186 /**
-
187 * PS4 Triangle button
-
188 */
-
189 PS_TRIANGLE,
-
190 /**
-
191 * PS4 Share button
-
192 */
-
193 PS_SHARE,
-
194 /**
-
195 * PS4 Options button
-
196 */
-
197 PS_OPTIONS,
-
198 /**
-
199 * XBox Start button
-
200 */
-
201 XBOX_START,
-
202 /**
-
203 * XBox Back button
-
204 */
-
205 XBOX_BACK,
-
206 /**
-
207 * Left bumper button
-
208 */
-
209 LEFT_BUMPER,
-
210 /**
-
211 * Right bumper button
-
212 */
-
213 RIGHT_BUMPER,
-
214 /**
-
215 * Button when clicking the left stick
-
216 */
-
217 LEFT_STICK_BUTTON,
-
218 /**
-
219 * Button which clicking the right stick
-
220 */
-
221 RIGHT_STICK_BUTTON,
-
222 }
-
223
-
224 /**
-
225 * Axis enum for all axis on gamepad
-
226 */
-
227 public enum Axis {
-
228 /**
-
229 * Left stick's horizontal axis
-
230 */
-
231 LEFT_STICK_X,
-
232 /**
-
233 * Left stick's vertical axis
-
234 */
-
235 LEFT_STICK_Y,
-
236 /**
-
237 * Right stick's horizontal axis
-
238 */
-
239 RIGHT_STICK_X,
-
240 /**
-
241 * Right stick's vertical axis
-
242 */
-
243 RIGHT_STICK_Y,
-
244 /**
-
245 * Left Trigger's axis
-
246 */
-
247 LEFT_TRIGGER,
-
248 /**
-
249 * Right Trigger's axis
-
250 */
-
251 RIGHT_TRIGGER,
-
252 }
-
253
-
254 /**
-
255 * Returns a button
-
256 *
-
257 * @param bu The enum to choose which gamepad button to return
-
258 * @return The gamepad button that you choose with the enum
-
259 */
-
260 public T getButton(Button bu) {
-
261 switch (bu) {
-
262 case XBOX_A:
-
263 return xbox_a;
-
264 case XBOX_B:
-
265 return xbox_b;
-
266 case XBOX_X:
-
267 return xbox_x;
-
268 case XBOX_Y:
-
269 return xbox_y;
-
270 case PS_CROSS:
-
271 return ps_cross;
-
272 case PS_CIRCLE:
-
273 return ps_circle;
-
274 case PS_SQUARE:
-
275 return ps_square;
-
276 case PS_TRIANGLE:
-
277 return ps_triangle;
-
278 case PS_SHARE:
-
279 return ps_share;
-
280 case PS_OPTIONS:
-
281 return ps_options;
-
282 case XBOX_BACK:
-
283 return xbox_back;
-
284 case XBOX_START:
-
285 return xbox_start;
-
286 case LEFT_BUMPER:
-
287 return leftBumper;
-
288 case RIGHT_BUMPER:
-
289 return rightBumper;
-
290 case LEFT_STICK_BUTTON:
-
291 return leftStickButton;
-
292 case RIGHT_STICK_BUTTON:
-
293 return rightStickButton;
-
294 default:
-
295 return null;
-
296 }
-
297 }
-
298
-
299 /**
-
300 * Returns an axis
-
301 *
-
302 * @param as The enum for the axis that is wanted to be returned
-
303 * @return The chosen axis
-
304 */
-
305 public U getAxis(Axis as) {
-
306 switch (as) {
-
307 case LEFT_STICK_X:
-
308 return leftStickX;
-
309 case LEFT_STICK_Y:
-
310 return leftStickY;
-
311 case RIGHT_STICK_X:
-
312 return rightStickX;
-
313 case RIGHT_STICK_Y:
-
314 return rightStickY;
-
315 case LEFT_TRIGGER:
-
316 return leftTrigger;
-
317 case RIGHT_TRIGGER:
-
318 return rightTrigger;
-
319 default:
-
320 return null;
-
321 }
-
322 }
-
323
-
324 /**
-
325 * Returns a button as boolean (same as isPressed)
-
326 *
-
327 * @param bu The enum to specify which button to get as boolean
-
328 * @return The chosen button as boolean
-
329 */
-
330 public boolean getButtonAsBoolean(Button bu) {
-
331 return getButton(bu).getAsBoolean();
-
332 }
-
333
-
334 /**
-
335 * Returns an axis as double
-
336 *
-
337 * @param as The enum to specify which axis to get as double
-
338 * @return The chosen axis as double
-
339 */
-
340 public double getAxisAsDouble(Axis as) {
-
341 return getAxis(as).getAsDouble();
-
342 }
-
343
-
344 /**
-
345 * Returns an axis as boolean
-
346 *
-
347 * @param as The enum to specify which axis to get as boolean
-
348 * @return The chosen axis as boolean
-
349 */
-
350 public boolean getAxisAsBoolean(Axis as) {
-
351 return getAxis(as).getAsBoolean();
-
352 }
-
353
-
354 /**
-
355 * Returns the left stick
-
356 *
-
357 * @return The left stick on the gamepad
-
358 */
-
359 public GamepadStick<U, T> getLeftStick() {
-
360 return leftStick;
-
361 }
-
362
-
363 /**
-
364 * Returns the right stick
-
365 *
-
366 * @return The right stick on the gamepad
-
367 */
-
368 public GamepadStick<U, T> getRightStick() {
-
369 return rightStick;
-
370 }
-
371
-
372 /**
-
373 * Returns the Dpad object
-
374 *
-
375 * @return The dpad
-
376 */
-
377 public GamepadDpad<T> getDpad() {
-
378 return dpad;
-
379 }
-
380
-
381 /**
-
382 * Run the periodic functions for the controller (if the controller is enabled)
-
383 */
-
384 @Override
-
385 public void periodic() {
-
386 if (isDisabled()) {
-
387 return;
-
388 }
-
389 for (Periodic p : periodics) {
-
390 p.periodic();
-
391 }
-
392 }
-
393
-
394 /**
-
395 * Returns the encapsulated gamepad
-
396 *
-
397 * @return The gamepad
-
398 */
-
399 public Gamepad getGamepad() {
-
400 return gamepad;
-
401 }
-
402
-
403 /**
-
404 * Great a ButtonBase type from the given BooleanSupplier
-
405 *
-
406 * @param b the function to wrap in a ButtonBase
-
407 * @return the T (extends ButtonBase) which the ButtonBase will wrap
-
408 * @throws InstantiationException Couldn't create the target type
-
409 * @throws IllegalAccessException Couldn't access the constructor
-
410 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
-
411 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
-
412 */
-
413 public T buttonInstance(BooleanSupplier b)
-
414 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
415 return buttonClass.getConstructor(BooleanSupplier.class).newInstance(b);
-
416 }
-
417
-
418 /**
-
419 * Returns the U (extended from AxisBase) type wrapped around a simple DoubleSupplier
-
420 *
-
421 * @param d The function to call
-
422 * @return A U (of AxisBase type) that's wrapped around the DoubleSupplier d provided
-
423 * @throws InstantiationException Couldn't create the target type
-
424 * @throws IllegalAccessException Couldn't access the constructor
-
425 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
-
426 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
-
427 */
-
428 public U axisInstance(DoubleSupplier d)
-
429 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
430 return axisClass.getConstructor(DoubleSupplier.class).newInstance(d);
-
431 }
-
432
-
433 // rumble stuff
-
434
-
435 /**
-
436 * Run a bunch of "RumbleBlips"
-
437 *
-
438 * @param blips The number of blips
-
439 */
-
440 public void rumbleBlips(int blips) {
-
441 gamepad.rumbleBlips(blips);
-
442 }
-
443
-
444 /**
-
445 * Run a single "RumbleBlip"
-
446 */
-
447 public void rumbleBlip() {
-
448 rumbleBlips(1);
-
449 }
-
450
-
451 /**
-
452 * Rumble the gamepad for 'seconds'
-
453 *
-
454 * @param seconds The number of (fractional) seconds to rumble for
-
455 */
-
456 public void rumble(double seconds) {
-
457 gamepad.rumble((int) (seconds * 1000));
-
458 }
-
459
-
460 /**
-
461 * Is the gamepad rumbling
-
462 *
-
463 * @return true if the gamepad is rumbling
-
464 */
-
465 public boolean isRumbling() {
-
466 return gamepad.isRumbling();
-
467 }
-
468
-
469 /**
-
470 * Stop rumbling on the gamepad
-
471 */
-
472 public void stopRumble() {
-
473 gamepad.stopRumble();
-
474 }
-
475
-
476 /**
-
477 * Rumble for about 1/8th of a second
-
478 */
-
479 public void rumble() {
-
480 rumble(120);
-
481 }
-
482
-
483 /**
-
484 * Enable/disable the gamepad (and all potentially bound commands!)
-
485 *
-
486 * @param enable True for enabled, false for disabled
-
487 * @return the Gamepad (for chaining)
-
488 */
-
489 @Override
-
490 public GamepadBase<T, U> setEnabled(boolean enable) {
-
491 enabled = enable;
-
492 for (CanBeEnabled<?> enablable : enablables) enablable.setEnabled(enable);
-
493 return this;
-
494 }
-
495
-
496 /**
-
497 * Is the gamepad (and all bound commands from it!) enabled?
-
498 *
-
499 * @return true if it's enabled, false if it's disabled
-
500 */
-
501 @Override
-
502 public boolean isEnabled() {
-
503 return enabled;
-
504 }
-
505}
+
017public class GamepadBase<T extends ButtonBase, U extends AxisBase>
+
018 implements Periodic, CanBeEnabled<GamepadBase<T, U>> {
+
019
+
020 private boolean enabled = true;
+
021 // normal gamepad
+
022 private Gamepad gamepad;
+
023 /**
+
024 * The button objects for the XBox game controller
+
025 */
+
026 public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
+
027 /**
+
028 * The button objects for the PS4 game controller
+
029 */
+
030 public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
+
031 /**
+
032 * The button objects for both the XBox and PS4 controllers
+
033 */
+
034 public T leftBumper, rightBumper, dpadUp, dpadDown, dpadLeft, dpadRight, leftStickButton, rightStickButton;
+
035 /**
+
036 * The axis objects
+
037 */
+
038 public U leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY;
+
039 /**
+
040 * The stick objects
+
041 */
+
042 public GamepadStick<U, T> leftStick, rightStick;
+
043 /**
+
044 * The dpad object
+
045 */
+
046 public GamepadDpad<T> dpad;
+
047
+
048 // periodics to run
+
049 private Periodic[] periodics;
+
050 private CanBeEnabled<?>[] enablables;
+
051
+
052 private Class<T> buttonClass;
+
053 private Class<U> axisClass;
+
054
+
055 /**
+
056 * Creates a gamepad with these parameters
+
057 *
+
058 * @param g The gamepad to base around
+
059 * @param bClass The class object passed for the button components (Should be the same as the one used for the class parameter T)
+
060 * @param aClass The class object passed for the axis components (Should be the same as the one used for the class parameter U)
+
061 */
+
062 public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
+
063 gamepad = g;
+
064 buttonClass = bClass;
+
065 axisClass = aClass;
+
066 try {
+
067 setComponents(g);
+
068 } catch (Exception e) {
+
069 e.printStackTrace();
+
070 }
+
071
+
072 leftStick = new GamepadStick<>(leftStickX, leftStickY, leftStickButton);
+
073 rightStick = new GamepadStick<>(rightStickX, rightStickY, rightStickButton);
+
074 dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
+
075 periodics = new Periodic[] {
+
076 xbox_a,
+
077 xbox_b,
+
078 xbox_x,
+
079 xbox_y,
+
080 xbox_start,
+
081 xbox_back,
+
082 leftBumper,
+
083 rightBumper,
+
084 leftTrigger,
+
085 rightTrigger,
+
086 leftStick,
+
087 rightStick,
+
088 dpad,
+
089 };
+
090 enablables = new CanBeEnabled[] {
+
091 xbox_a,
+
092 xbox_b,
+
093 xbox_x,
+
094 xbox_y,
+
095 xbox_start,
+
096 xbox_back,
+
097 leftBumper,
+
098 rightBumper,
+
099 leftTrigger,
+
100 rightTrigger,
+
101 leftStick,
+
102 rightStick,
+
103 dpad,
+
104 };
+
105 }
+
106
+
107 // to actually instantiate the objects
+
108 private void setComponents(Gamepad g)
+
109 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
110 // buttons
+
111 // a=new T();
+
112 xbox_a = buttonInstance(() -> g.a);
+
113 xbox_b = buttonInstance(() -> g.b);
+
114 xbox_x = buttonInstance(() -> g.x);
+
115 xbox_y = buttonInstance(() -> g.y);
+
116 ps_cross = xbox_a;
+
117 ps_circle = xbox_b;
+
118 ps_square = xbox_x;
+
119 ps_triangle = xbox_y;
+
120
+
121 xbox_start = buttonInstance(() -> g.start);
+
122 xbox_back = buttonInstance(() -> g.back);
+
123 ps_share = xbox_back;
+
124 ps_options = xbox_start;
+
125
+
126 // bumpers
+
127 leftBumper = buttonInstance(() -> g.left_bumper);
+
128 rightBumper = buttonInstance(() -> g.right_bumper);
+
129
+
130 // dpad
+
131 dpadUp = buttonInstance(() -> g.dpad_up);
+
132 dpadDown = buttonInstance(() -> g.dpad_down);
+
133 dpadLeft = buttonInstance(() -> g.dpad_left);
+
134 dpadRight = buttonInstance(() -> g.dpad_right);
+
135
+
136 // left stick
+
137 leftStickX = axisInstance(() -> g.left_stick_x);
+
138 leftStickY = axisInstance(() -> g.left_stick_y);
+
139 leftStickButton = buttonInstance(() -> g.left_stick_button);
+
140
+
141 // right stick
+
142 rightStickX = axisInstance(() -> g.right_stick_x);
+
143 rightStickY = axisInstance(() -> g.right_stick_y);
+
144 rightStickButton = buttonInstance(() -> g.right_stick_button);
+
145
+
146 // triggers
+
147 leftTrigger = axisInstance(() -> g.left_trigger);
+
148 rightTrigger = axisInstance(() -> g.right_trigger);
+
149 }
+
150
+
151 // enums
+
152
+
153 /**
+
154 * Button enum for all buttons on gamepad
+
155 */
+
156 public enum Button {
+
157 /**
+
158 * XBox A button
+
159 */
+
160 XBOX_A,
+
161 /**
+
162 * XBox B button
+
163 */
+
164 XBOX_B,
+
165 /**
+
166 * XBox X button
+
167 */
+
168 XBOX_X,
+
169 /**
+
170 * XBox Y button
+
171 */
+
172 XBOX_Y,
+
173 /**
+
174 * PS4 Cross (X) button
+
175 */
+
176 PS_CROSS,
+
177 /**
+
178 * PS4 Circle (O) button
+
179 */
+
180 PS_CIRCLE,
+
181 /**
+
182 * PS4 Square button
+
183 */
+
184 PS_SQUARE,
+
185 /**
+
186 * PS4 Triangle button
+
187 */
+
188 PS_TRIANGLE,
+
189 /**
+
190 * PS4 Share button
+
191 */
+
192 PS_SHARE,
+
193 /**
+
194 * PS4 Options button
+
195 */
+
196 PS_OPTIONS,
+
197 /**
+
198 * XBox Start button
+
199 */
+
200 XBOX_START,
+
201 /**
+
202 * XBox Back button
+
203 */
+
204 XBOX_BACK,
+
205 /**
+
206 * Left bumper button
+
207 */
+
208 LEFT_BUMPER,
+
209 /**
+
210 * Right bumper button
+
211 */
+
212 RIGHT_BUMPER,
+
213 /**
+
214 * Button when clicking the left stick
+
215 */
+
216 LEFT_STICK_BUTTON,
+
217 /**
+
218 * Button which clicking the right stick
+
219 */
+
220 RIGHT_STICK_BUTTON,
+
221 }
+
222
+
223 /**
+
224 * Axis enum for all axis on gamepad
+
225 */
+
226 public enum Axis {
+
227 /**
+
228 * Left stick's horizontal axis
+
229 */
+
230 LEFT_STICK_X,
+
231 /**
+
232 * Left stick's vertical axis
+
233 */
+
234 LEFT_STICK_Y,
+
235 /**
+
236 * Right stick's horizontal axis
+
237 */
+
238 RIGHT_STICK_X,
+
239 /**
+
240 * Right stick's vertical axis
+
241 */
+
242 RIGHT_STICK_Y,
+
243 /**
+
244 * Left Trigger's axis
+
245 */
+
246 LEFT_TRIGGER,
+
247 /**
+
248 * Right Trigger's axis
+
249 */
+
250 RIGHT_TRIGGER,
+
251 }
+
252
+
253 /**
+
254 * Returns a button
+
255 *
+
256 * @param bu The enum to choose which gamepad button to return
+
257 * @return The gamepad button that you choose with the enum
+
258 */
+
259 public T getButton(Button bu) {
+
260 switch (bu) {
+
261 case XBOX_A:
+
262 return xbox_a;
+
263 case XBOX_B:
+
264 return xbox_b;
+
265 case XBOX_X:
+
266 return xbox_x;
+
267 case XBOX_Y:
+
268 return xbox_y;
+
269 case PS_CROSS:
+
270 return ps_cross;
+
271 case PS_CIRCLE:
+
272 return ps_circle;
+
273 case PS_SQUARE:
+
274 return ps_square;
+
275 case PS_TRIANGLE:
+
276 return ps_triangle;
+
277 case PS_SHARE:
+
278 return ps_share;
+
279 case PS_OPTIONS:
+
280 return ps_options;
+
281 case XBOX_BACK:
+
282 return xbox_back;
+
283 case XBOX_START:
+
284 return xbox_start;
+
285 case LEFT_BUMPER:
+
286 return leftBumper;
+
287 case RIGHT_BUMPER:
+
288 return rightBumper;
+
289 case LEFT_STICK_BUTTON:
+
290 return leftStickButton;
+
291 case RIGHT_STICK_BUTTON:
+
292 return rightStickButton;
+
293 default:
+
294 return null;
+
295 }
+
296 }
+
297
+
298 /**
+
299 * Returns an axis
+
300 *
+
301 * @param as The enum for the axis that is wanted to be returned
+
302 * @return The chosen axis
+
303 */
+
304 public U getAxis(Axis as) {
+
305 switch (as) {
+
306 case LEFT_STICK_X:
+
307 return leftStickX;
+
308 case LEFT_STICK_Y:
+
309 return leftStickY;
+
310 case RIGHT_STICK_X:
+
311 return rightStickX;
+
312 case RIGHT_STICK_Y:
+
313 return rightStickY;
+
314 case LEFT_TRIGGER:
+
315 return leftTrigger;
+
316 case RIGHT_TRIGGER:
+
317 return rightTrigger;
+
318 default:
+
319 return null;
+
320 }
+
321 }
+
322
+
323 /**
+
324 * Returns a button as boolean (same as isPressed)
+
325 *
+
326 * @param bu The enum to specify which button to get as boolean
+
327 * @return The chosen button as boolean
+
328 */
+
329 public boolean getButtonAsBoolean(Button bu) {
+
330 return getButton(bu).getAsBoolean();
+
331 }
+
332
+
333 /**
+
334 * Returns an axis as double
+
335 *
+
336 * @param as The enum to specify which axis to get as double
+
337 * @return The chosen axis as double
+
338 */
+
339 public double getAxisAsDouble(Axis as) {
+
340 return getAxis(as).getAsDouble();
+
341 }
+
342
+
343 /**
+
344 * Returns an axis as boolean
+
345 *
+
346 * @param as The enum to specify which axis to get as boolean
+
347 * @return The chosen axis as boolean
+
348 */
+
349 public boolean getAxisAsBoolean(Axis as) {
+
350 return getAxis(as).getAsBoolean();
+
351 }
+
352
+
353 /**
+
354 * Returns the left stick
+
355 *
+
356 * @return The left stick on the gamepad
+
357 */
+
358 public GamepadStick<U, T> getLeftStick() {
+
359 return leftStick;
+
360 }
+
361
+
362 /**
+
363 * Returns the right stick
+
364 *
+
365 * @return The right stick on the gamepad
+
366 */
+
367 public GamepadStick<U, T> getRightStick() {
+
368 return rightStick;
+
369 }
+
370
+
371 /**
+
372 * Returns the Dpad object
+
373 *
+
374 * @return The dpad
+
375 */
+
376 public GamepadDpad<T> getDpad() {
+
377 return dpad;
+
378 }
+
379
+
380 /**
+
381 * Run the periodic functions for the controller (if the controller is enabled)
+
382 */
+
383 @Override
+
384 public void periodic() {
+
385 if (isDisabled()) {
+
386 return;
+
387 }
+
388 for (Periodic p : periodics) {
+
389 p.periodic();
+
390 }
+
391 }
+
392
+
393 /**
+
394 * Returns the encapsulated gamepad
+
395 *
+
396 * @return The gamepad
+
397 */
+
398 public Gamepad getGamepad() {
+
399 return gamepad;
+
400 }
+
401
+
402 /**
+
403 * Great a ButtonBase type from the given BooleanSupplier
+
404 *
+
405 * @param b the function to wrap in a ButtonBase
+
406 * @return the T (extends ButtonBase) which the ButtonBase will wrap
+
407 * @throws InstantiationException Couldn't create the target type
+
408 * @throws IllegalAccessException Couldn't access the constructor
+
409 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
+
410 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
+
411 */
+
412 public T buttonInstance(BooleanSupplier b)
+
413 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
414 return buttonClass.getConstructor(BooleanSupplier.class).newInstance(b);
+
415 }
+
416
+
417 /**
+
418 * Returns the U (extended from AxisBase) type wrapped around a simple DoubleSupplier
+
419 *
+
420 * @param d The function to call
+
421 * @return A U (of AxisBase type) that's wrapped around the DoubleSupplier d provided
+
422 * @throws InstantiationException Couldn't create the target type
+
423 * @throws IllegalAccessException Couldn't access the constructor
+
424 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
+
425 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
+
426 */
+
427 public U axisInstance(DoubleSupplier d)
+
428 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
429 return axisClass.getConstructor(DoubleSupplier.class).newInstance(d);
+
430 }
+
431
+
432 // rumble stuff
+
433
+
434 /**
+
435 * Run a bunch of "RumbleBlips"
+
436 *
+
437 * @param blips The number of blips
+
438 */
+
439 public void rumbleBlips(int blips) {
+
440 gamepad.rumbleBlips(blips);
+
441 }
+
442
+
443 /**
+
444 * Run a single "RumbleBlip"
+
445 */
+
446 public void rumbleBlip() {
+
447 rumbleBlips(1);
+
448 }
+
449
+
450 /**
+
451 * Rumble the gamepad for 'seconds'
+
452 *
+
453 * @param seconds The number of (fractional) seconds to rumble for
+
454 */
+
455 public void rumble(double seconds) {
+
456 gamepad.rumble((int) (seconds * 1000));
+
457 }
+
458
+
459 /**
+
460 * Is the gamepad rumbling
+
461 *
+
462 * @return true if the gamepad is rumbling
+
463 */
+
464 public boolean isRumbling() {
+
465 return gamepad.isRumbling();
+
466 }
+
467
+
468 /**
+
469 * Stop rumbling on the gamepad
+
470 */
+
471 public void stopRumble() {
+
472 gamepad.stopRumble();
+
473 }
+
474
+
475 /**
+
476 * Rumble for about 1/8th of a second
+
477 */
+
478 public void rumble() {
+
479 rumble(120);
+
480 }
+
481
+
482 /**
+
483 * Enable/disable the gamepad (and all potentially bound commands!)
+
484 *
+
485 * @param enable True for enabled, false for disabled
+
486 * @return the Gamepad (for chaining)
+
487 */
+
488 @Override
+
489 public GamepadBase<T, U> setEnabled(boolean enable) {
+
490 enabled = enable;
+
491 for (CanBeEnabled<?> enablable : enablables) enablable.setEnabled(enable);
+
492 return this;
+
493 }
+
494
+
495 /**
+
496 * Is the gamepad (and all bound commands from it!) enabled?
+
497 *
+
498 * @return true if it's enabled, false if it's disabled
+
499 */
+
500 @Override
+
501 public boolean isEnabled() {
+
502 return enabled;
+
503 }
+
504}
diff --git a/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Button.html b/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Button.html
index 95c1a4f2..6d56d6fb 100644
--- a/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Button.html
+++ b/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.Button.html
@@ -30,495 +30,494 @@
014 * @param <U> The class for the axis components on the gamepad
015 * @author Alex Stedman
016 */
-
017public class GamepadBase<T extends ButtonBase, U extends AxisBase> implements Periodic, CanBeEnabled<GamepadBase<T, U>> {
-
018
-
019 private boolean enabled = true;
-
020 // normal gamepad
-
021 private Gamepad gamepad;
-
022 /**
-
023 * The button objects for the XBox game controller
-
024 */
-
025 public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
-
026 /**
-
027 * The button objects for the PS4 game controller
-
028 */
-
029 public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
-
030 /**
-
031 * The button objects for both the XBox and PS4 controllers
-
032 */
-
033 public T leftBumper, rightBumper, dpadUp, dpadDown, dpadLeft, dpadRight, leftStickButton, rightStickButton;
-
034 /**
-
035 * The axis objects
-
036 */
-
037 public U leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY;
-
038 /**
-
039 * The stick objects
-
040 */
-
041 public GamepadStick<U, T> leftStick, rightStick;
-
042 /**
-
043 * The dpad object
-
044 */
-
045 public GamepadDpad<T> dpad;
-
046
-
047 // periodics to run
-
048 private Periodic[] periodics;
-
049 private CanBeEnabled<?>[] enablables;
-
050
-
051 private Class<T> buttonClass;
-
052 private Class<U> axisClass;
-
053
-
054 /**
-
055 * Creates a gamepad with these parameters
-
056 *
-
057 * @param g The gamepad to base around
-
058 * @param bClass The class object passed for the button components (Should be the same as the one used for the class parameter T)
-
059 * @param aClass The class object passed for the axis components (Should be the same as the one used for the class parameter U)
-
060 */
-
061 public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
-
062 gamepad = g;
-
063 buttonClass = bClass;
-
064 axisClass = aClass;
-
065 try {
-
066 setComponents(g);
-
067 } catch (Exception e) {
-
068 e.printStackTrace();
-
069 }
-
070
-
071 leftStick = new GamepadStick<>(leftStickX, leftStickY, leftStickButton);
-
072 rightStick = new GamepadStick<>(rightStickX, rightStickY, rightStickButton);
-
073 dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
-
074 periodics =
-
075 new Periodic[] {
-
076 xbox_a,
-
077 xbox_b,
-
078 xbox_x,
-
079 xbox_y,
-
080 xbox_start,
-
081 xbox_back,
-
082 leftBumper,
-
083 rightBumper,
-
084 leftTrigger,
-
085 rightTrigger,
-
086 leftStick,
-
087 rightStick,
-
088 dpad,
-
089 };
-
090 enablables =
-
091 new CanBeEnabled[] {
-
092 xbox_a,
-
093 xbox_b,
-
094 xbox_x,
-
095 xbox_y,
-
096 xbox_start,
-
097 xbox_back,
-
098 leftBumper,
-
099 rightBumper,
-
100 leftTrigger,
-
101 rightTrigger,
-
102 leftStick,
-
103 rightStick,
-
104 dpad,
-
105 };
-
106 }
-
107
-
108 // to actually instantiate the objects
-
109 private void setComponents(Gamepad g)
-
110 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
111 // buttons
-
112 // a=new T();
-
113 xbox_a = buttonInstance(() -> g.a);
-
114 xbox_b = buttonInstance(() -> g.b);
-
115 xbox_x = buttonInstance(() -> g.x);
-
116 xbox_y = buttonInstance(() -> g.y);
-
117 ps_cross = xbox_a;
-
118 ps_circle = xbox_b;
-
119 ps_square = xbox_x;
-
120 ps_triangle = xbox_y;
-
121
-
122 xbox_start = buttonInstance(() -> g.start);
-
123 xbox_back = buttonInstance(() -> g.back);
-
124 ps_share = xbox_back;
-
125 ps_options = xbox_start;
-
126
-
127 // bumpers
-
128 leftBumper = buttonInstance(() -> g.left_bumper);
-
129 rightBumper = buttonInstance(() -> g.right_bumper);
-
130
-
131 // dpad
-
132 dpadUp = buttonInstance(() -> g.dpad_up);
-
133 dpadDown = buttonInstance(() -> g.dpad_down);
-
134 dpadLeft = buttonInstance(() -> g.dpad_left);
-
135 dpadRight = buttonInstance(() -> g.dpad_right);
-
136
-
137 // left stick
-
138 leftStickX = axisInstance(() -> g.left_stick_x);
-
139 leftStickY = axisInstance(() -> g.left_stick_y);
-
140 leftStickButton = buttonInstance(() -> g.left_stick_button);
-
141
-
142 // right stick
-
143 rightStickX = axisInstance(() -> g.right_stick_x);
-
144 rightStickY = axisInstance(() -> g.right_stick_y);
-
145 rightStickButton = buttonInstance(() -> g.right_stick_button);
-
146
-
147 // triggers
-
148 leftTrigger = axisInstance(() -> g.left_trigger);
-
149 rightTrigger = axisInstance(() -> g.right_trigger);
-
150 }
-
151
-
152 // enums
-
153
-
154 /**
-
155 * Button enum for all buttons on gamepad
-
156 */
-
157 public enum Button {
-
158 /**
-
159 * XBox A button
-
160 */
-
161 XBOX_A,
-
162 /**
-
163 * XBox B button
-
164 */
-
165 XBOX_B,
-
166 /**
-
167 * XBox X button
-
168 */
-
169 XBOX_X,
-
170 /**
-
171 * XBox Y button
-
172 */
-
173 XBOX_Y,
-
174 /**
-
175 * PS4 Cross (X) button
-
176 */
-
177 PS_CROSS,
-
178 /**
-
179 * PS4 Circle (O) button
-
180 */
-
181 PS_CIRCLE,
-
182 /**
-
183 * PS4 Square button
-
184 */
-
185 PS_SQUARE,
-
186 /**
-
187 * PS4 Triangle button
-
188 */
-
189 PS_TRIANGLE,
-
190 /**
-
191 * PS4 Share button
-
192 */
-
193 PS_SHARE,
-
194 /**
-
195 * PS4 Options button
-
196 */
-
197 PS_OPTIONS,
-
198 /**
-
199 * XBox Start button
-
200 */
-
201 XBOX_START,
-
202 /**
-
203 * XBox Back button
-
204 */
-
205 XBOX_BACK,
-
206 /**
-
207 * Left bumper button
-
208 */
-
209 LEFT_BUMPER,
-
210 /**
-
211 * Right bumper button
-
212 */
-
213 RIGHT_BUMPER,
-
214 /**
-
215 * Button when clicking the left stick
-
216 */
-
217 LEFT_STICK_BUTTON,
-
218 /**
-
219 * Button which clicking the right stick
-
220 */
-
221 RIGHT_STICK_BUTTON,
-
222 }
-
223
-
224 /**
-
225 * Axis enum for all axis on gamepad
-
226 */
-
227 public enum Axis {
-
228 /**
-
229 * Left stick's horizontal axis
-
230 */
-
231 LEFT_STICK_X,
-
232 /**
-
233 * Left stick's vertical axis
-
234 */
-
235 LEFT_STICK_Y,
-
236 /**
-
237 * Right stick's horizontal axis
-
238 */
-
239 RIGHT_STICK_X,
-
240 /**
-
241 * Right stick's vertical axis
-
242 */
-
243 RIGHT_STICK_Y,
-
244 /**
-
245 * Left Trigger's axis
-
246 */
-
247 LEFT_TRIGGER,
-
248 /**
-
249 * Right Trigger's axis
-
250 */
-
251 RIGHT_TRIGGER,
-
252 }
-
253
-
254 /**
-
255 * Returns a button
-
256 *
-
257 * @param bu The enum to choose which gamepad button to return
-
258 * @return The gamepad button that you choose with the enum
-
259 */
-
260 public T getButton(Button bu) {
-
261 switch (bu) {
-
262 case XBOX_A:
-
263 return xbox_a;
-
264 case XBOX_B:
-
265 return xbox_b;
-
266 case XBOX_X:
-
267 return xbox_x;
-
268 case XBOX_Y:
-
269 return xbox_y;
-
270 case PS_CROSS:
-
271 return ps_cross;
-
272 case PS_CIRCLE:
-
273 return ps_circle;
-
274 case PS_SQUARE:
-
275 return ps_square;
-
276 case PS_TRIANGLE:
-
277 return ps_triangle;
-
278 case PS_SHARE:
-
279 return ps_share;
-
280 case PS_OPTIONS:
-
281 return ps_options;
-
282 case XBOX_BACK:
-
283 return xbox_back;
-
284 case XBOX_START:
-
285 return xbox_start;
-
286 case LEFT_BUMPER:
-
287 return leftBumper;
-
288 case RIGHT_BUMPER:
-
289 return rightBumper;
-
290 case LEFT_STICK_BUTTON:
-
291 return leftStickButton;
-
292 case RIGHT_STICK_BUTTON:
-
293 return rightStickButton;
-
294 default:
-
295 return null;
-
296 }
-
297 }
-
298
-
299 /**
-
300 * Returns an axis
-
301 *
-
302 * @param as The enum for the axis that is wanted to be returned
-
303 * @return The chosen axis
-
304 */
-
305 public U getAxis(Axis as) {
-
306 switch (as) {
-
307 case LEFT_STICK_X:
-
308 return leftStickX;
-
309 case LEFT_STICK_Y:
-
310 return leftStickY;
-
311 case RIGHT_STICK_X:
-
312 return rightStickX;
-
313 case RIGHT_STICK_Y:
-
314 return rightStickY;
-
315 case LEFT_TRIGGER:
-
316 return leftTrigger;
-
317 case RIGHT_TRIGGER:
-
318 return rightTrigger;
-
319 default:
-
320 return null;
-
321 }
-
322 }
-
323
-
324 /**
-
325 * Returns a button as boolean (same as isPressed)
-
326 *
-
327 * @param bu The enum to specify which button to get as boolean
-
328 * @return The chosen button as boolean
-
329 */
-
330 public boolean getButtonAsBoolean(Button bu) {
-
331 return getButton(bu).getAsBoolean();
-
332 }
-
333
-
334 /**
-
335 * Returns an axis as double
-
336 *
-
337 * @param as The enum to specify which axis to get as double
-
338 * @return The chosen axis as double
-
339 */
-
340 public double getAxisAsDouble(Axis as) {
-
341 return getAxis(as).getAsDouble();
-
342 }
-
343
-
344 /**
-
345 * Returns an axis as boolean
-
346 *
-
347 * @param as The enum to specify which axis to get as boolean
-
348 * @return The chosen axis as boolean
-
349 */
-
350 public boolean getAxisAsBoolean(Axis as) {
-
351 return getAxis(as).getAsBoolean();
-
352 }
-
353
-
354 /**
-
355 * Returns the left stick
-
356 *
-
357 * @return The left stick on the gamepad
-
358 */
-
359 public GamepadStick<U, T> getLeftStick() {
-
360 return leftStick;
-
361 }
-
362
-
363 /**
-
364 * Returns the right stick
-
365 *
-
366 * @return The right stick on the gamepad
-
367 */
-
368 public GamepadStick<U, T> getRightStick() {
-
369 return rightStick;
-
370 }
-
371
-
372 /**
-
373 * Returns the Dpad object
-
374 *
-
375 * @return The dpad
-
376 */
-
377 public GamepadDpad<T> getDpad() {
-
378 return dpad;
-
379 }
-
380
-
381 /**
-
382 * Run the periodic functions for the controller (if the controller is enabled)
-
383 */
-
384 @Override
-
385 public void periodic() {
-
386 if (isDisabled()) {
-
387 return;
-
388 }
-
389 for (Periodic p : periodics) {
-
390 p.periodic();
-
391 }
-
392 }
-
393
-
394 /**
-
395 * Returns the encapsulated gamepad
-
396 *
-
397 * @return The gamepad
-
398 */
-
399 public Gamepad getGamepad() {
-
400 return gamepad;
-
401 }
-
402
-
403 /**
-
404 * Great a ButtonBase type from the given BooleanSupplier
-
405 *
-
406 * @param b the function to wrap in a ButtonBase
-
407 * @return the T (extends ButtonBase) which the ButtonBase will wrap
-
408 * @throws InstantiationException Couldn't create the target type
-
409 * @throws IllegalAccessException Couldn't access the constructor
-
410 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
-
411 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
-
412 */
-
413 public T buttonInstance(BooleanSupplier b)
-
414 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
415 return buttonClass.getConstructor(BooleanSupplier.class).newInstance(b);
-
416 }
-
417
-
418 /**
-
419 * Returns the U (extended from AxisBase) type wrapped around a simple DoubleSupplier
-
420 *
-
421 * @param d The function to call
-
422 * @return A U (of AxisBase type) that's wrapped around the DoubleSupplier d provided
-
423 * @throws InstantiationException Couldn't create the target type
-
424 * @throws IllegalAccessException Couldn't access the constructor
-
425 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
-
426 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
-
427 */
-
428 public U axisInstance(DoubleSupplier d)
-
429 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
430 return axisClass.getConstructor(DoubleSupplier.class).newInstance(d);
-
431 }
-
432
-
433 // rumble stuff
-
434
-
435 /**
-
436 * Run a bunch of "RumbleBlips"
-
437 *
-
438 * @param blips The number of blips
-
439 */
-
440 public void rumbleBlips(int blips) {
-
441 gamepad.rumbleBlips(blips);
-
442 }
-
443
-
444 /**
-
445 * Run a single "RumbleBlip"
-
446 */
-
447 public void rumbleBlip() {
-
448 rumbleBlips(1);
-
449 }
-
450
-
451 /**
-
452 * Rumble the gamepad for 'seconds'
-
453 *
-
454 * @param seconds The number of (fractional) seconds to rumble for
-
455 */
-
456 public void rumble(double seconds) {
-
457 gamepad.rumble((int) (seconds * 1000));
-
458 }
-
459
-
460 /**
-
461 * Is the gamepad rumbling
-
462 *
-
463 * @return true if the gamepad is rumbling
-
464 */
-
465 public boolean isRumbling() {
-
466 return gamepad.isRumbling();
-
467 }
-
468
-
469 /**
-
470 * Stop rumbling on the gamepad
-
471 */
-
472 public void stopRumble() {
-
473 gamepad.stopRumble();
-
474 }
-
475
-
476 /**
-
477 * Rumble for about 1/8th of a second
-
478 */
-
479 public void rumble() {
-
480 rumble(120);
-
481 }
-
482
-
483 /**
-
484 * Enable/disable the gamepad (and all potentially bound commands!)
-
485 *
-
486 * @param enable True for enabled, false for disabled
-
487 * @return the Gamepad (for chaining)
-
488 */
-
489 @Override
-
490 public GamepadBase<T, U> setEnabled(boolean enable) {
-
491 enabled = enable;
-
492 for (CanBeEnabled<?> enablable : enablables) enablable.setEnabled(enable);
-
493 return this;
-
494 }
-
495
-
496 /**
-
497 * Is the gamepad (and all bound commands from it!) enabled?
-
498 *
-
499 * @return true if it's enabled, false if it's disabled
-
500 */
-
501 @Override
-
502 public boolean isEnabled() {
-
503 return enabled;
-
504 }
-
505}
+
017public class GamepadBase<T extends ButtonBase, U extends AxisBase>
+
018 implements Periodic, CanBeEnabled<GamepadBase<T, U>> {
+
019
+
020 private boolean enabled = true;
+
021 // normal gamepad
+
022 private Gamepad gamepad;
+
023 /**
+
024 * The button objects for the XBox game controller
+
025 */
+
026 public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
+
027 /**
+
028 * The button objects for the PS4 game controller
+
029 */
+
030 public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
+
031 /**
+
032 * The button objects for both the XBox and PS4 controllers
+
033 */
+
034 public T leftBumper, rightBumper, dpadUp, dpadDown, dpadLeft, dpadRight, leftStickButton, rightStickButton;
+
035 /**
+
036 * The axis objects
+
037 */
+
038 public U leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY;
+
039 /**
+
040 * The stick objects
+
041 */
+
042 public GamepadStick<U, T> leftStick, rightStick;
+
043 /**
+
044 * The dpad object
+
045 */
+
046 public GamepadDpad<T> dpad;
+
047
+
048 // periodics to run
+
049 private Periodic[] periodics;
+
050 private CanBeEnabled<?>[] enablables;
+
051
+
052 private Class<T> buttonClass;
+
053 private Class<U> axisClass;
+
054
+
055 /**
+
056 * Creates a gamepad with these parameters
+
057 *
+
058 * @param g The gamepad to base around
+
059 * @param bClass The class object passed for the button components (Should be the same as the one used for the class parameter T)
+
060 * @param aClass The class object passed for the axis components (Should be the same as the one used for the class parameter U)
+
061 */
+
062 public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
+
063 gamepad = g;
+
064 buttonClass = bClass;
+
065 axisClass = aClass;
+
066 try {
+
067 setComponents(g);
+
068 } catch (Exception e) {
+
069 e.printStackTrace();
+
070 }
+
071
+
072 leftStick = new GamepadStick<>(leftStickX, leftStickY, leftStickButton);
+
073 rightStick = new GamepadStick<>(rightStickX, rightStickY, rightStickButton);
+
074 dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
+
075 periodics = new Periodic[] {
+
076 xbox_a,
+
077 xbox_b,
+
078 xbox_x,
+
079 xbox_y,
+
080 xbox_start,
+
081 xbox_back,
+
082 leftBumper,
+
083 rightBumper,
+
084 leftTrigger,
+
085 rightTrigger,
+
086 leftStick,
+
087 rightStick,
+
088 dpad,
+
089 };
+
090 enablables = new CanBeEnabled[] {
+
091 xbox_a,
+
092 xbox_b,
+
093 xbox_x,
+
094 xbox_y,
+
095 xbox_start,
+
096 xbox_back,
+
097 leftBumper,
+
098 rightBumper,
+
099 leftTrigger,
+
100 rightTrigger,
+
101 leftStick,
+
102 rightStick,
+
103 dpad,
+
104 };
+
105 }
+
106
+
107 // to actually instantiate the objects
+
108 private void setComponents(Gamepad g)
+
109 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
110 // buttons
+
111 // a=new T();
+
112 xbox_a = buttonInstance(() -> g.a);
+
113 xbox_b = buttonInstance(() -> g.b);
+
114 xbox_x = buttonInstance(() -> g.x);
+
115 xbox_y = buttonInstance(() -> g.y);
+
116 ps_cross = xbox_a;
+
117 ps_circle = xbox_b;
+
118 ps_square = xbox_x;
+
119 ps_triangle = xbox_y;
+
120
+
121 xbox_start = buttonInstance(() -> g.start);
+
122 xbox_back = buttonInstance(() -> g.back);
+
123 ps_share = xbox_back;
+
124 ps_options = xbox_start;
+
125
+
126 // bumpers
+
127 leftBumper = buttonInstance(() -> g.left_bumper);
+
128 rightBumper = buttonInstance(() -> g.right_bumper);
+
129
+
130 // dpad
+
131 dpadUp = buttonInstance(() -> g.dpad_up);
+
132 dpadDown = buttonInstance(() -> g.dpad_down);
+
133 dpadLeft = buttonInstance(() -> g.dpad_left);
+
134 dpadRight = buttonInstance(() -> g.dpad_right);
+
135
+
136 // left stick
+
137 leftStickX = axisInstance(() -> g.left_stick_x);
+
138 leftStickY = axisInstance(() -> g.left_stick_y);
+
139 leftStickButton = buttonInstance(() -> g.left_stick_button);
+
140
+
141 // right stick
+
142 rightStickX = axisInstance(() -> g.right_stick_x);
+
143 rightStickY = axisInstance(() -> g.right_stick_y);
+
144 rightStickButton = buttonInstance(() -> g.right_stick_button);
+
145
+
146 // triggers
+
147 leftTrigger = axisInstance(() -> g.left_trigger);
+
148 rightTrigger = axisInstance(() -> g.right_trigger);
+
149 }
+
150
+
151 // enums
+
152
+
153 /**
+
154 * Button enum for all buttons on gamepad
+
155 */
+
156 public enum Button {
+
157 /**
+
158 * XBox A button
+
159 */
+
160 XBOX_A,
+
161 /**
+
162 * XBox B button
+
163 */
+
164 XBOX_B,
+
165 /**
+
166 * XBox X button
+
167 */
+
168 XBOX_X,
+
169 /**
+
170 * XBox Y button
+
171 */
+
172 XBOX_Y,
+
173 /**
+
174 * PS4 Cross (X) button
+
175 */
+
176 PS_CROSS,
+
177 /**
+
178 * PS4 Circle (O) button
+
179 */
+
180 PS_CIRCLE,
+
181 /**
+
182 * PS4 Square button
+
183 */
+
184 PS_SQUARE,
+
185 /**
+
186 * PS4 Triangle button
+
187 */
+
188 PS_TRIANGLE,
+
189 /**
+
190 * PS4 Share button
+
191 */
+
192 PS_SHARE,
+
193 /**
+
194 * PS4 Options button
+
195 */
+
196 PS_OPTIONS,
+
197 /**
+
198 * XBox Start button
+
199 */
+
200 XBOX_START,
+
201 /**
+
202 * XBox Back button
+
203 */
+
204 XBOX_BACK,
+
205 /**
+
206 * Left bumper button
+
207 */
+
208 LEFT_BUMPER,
+
209 /**
+
210 * Right bumper button
+
211 */
+
212 RIGHT_BUMPER,
+
213 /**
+
214 * Button when clicking the left stick
+
215 */
+
216 LEFT_STICK_BUTTON,
+
217 /**
+
218 * Button which clicking the right stick
+
219 */
+
220 RIGHT_STICK_BUTTON,
+
221 }
+
222
+
223 /**
+
224 * Axis enum for all axis on gamepad
+
225 */
+
226 public enum Axis {
+
227 /**
+
228 * Left stick's horizontal axis
+
229 */
+
230 LEFT_STICK_X,
+
231 /**
+
232 * Left stick's vertical axis
+
233 */
+
234 LEFT_STICK_Y,
+
235 /**
+
236 * Right stick's horizontal axis
+
237 */
+
238 RIGHT_STICK_X,
+
239 /**
+
240 * Right stick's vertical axis
+
241 */
+
242 RIGHT_STICK_Y,
+
243 /**
+
244 * Left Trigger's axis
+
245 */
+
246 LEFT_TRIGGER,
+
247 /**
+
248 * Right Trigger's axis
+
249 */
+
250 RIGHT_TRIGGER,
+
251 }
+
252
+
253 /**
+
254 * Returns a button
+
255 *
+
256 * @param bu The enum to choose which gamepad button to return
+
257 * @return The gamepad button that you choose with the enum
+
258 */
+
259 public T getButton(Button bu) {
+
260 switch (bu) {
+
261 case XBOX_A:
+
262 return xbox_a;
+
263 case XBOX_B:
+
264 return xbox_b;
+
265 case XBOX_X:
+
266 return xbox_x;
+
267 case XBOX_Y:
+
268 return xbox_y;
+
269 case PS_CROSS:
+
270 return ps_cross;
+
271 case PS_CIRCLE:
+
272 return ps_circle;
+
273 case PS_SQUARE:
+
274 return ps_square;
+
275 case PS_TRIANGLE:
+
276 return ps_triangle;
+
277 case PS_SHARE:
+
278 return ps_share;
+
279 case PS_OPTIONS:
+
280 return ps_options;
+
281 case XBOX_BACK:
+
282 return xbox_back;
+
283 case XBOX_START:
+
284 return xbox_start;
+
285 case LEFT_BUMPER:
+
286 return leftBumper;
+
287 case RIGHT_BUMPER:
+
288 return rightBumper;
+
289 case LEFT_STICK_BUTTON:
+
290 return leftStickButton;
+
291 case RIGHT_STICK_BUTTON:
+
292 return rightStickButton;
+
293 default:
+
294 return null;
+
295 }
+
296 }
+
297
+
298 /**
+
299 * Returns an axis
+
300 *
+
301 * @param as The enum for the axis that is wanted to be returned
+
302 * @return The chosen axis
+
303 */
+
304 public U getAxis(Axis as) {
+
305 switch (as) {
+
306 case LEFT_STICK_X:
+
307 return leftStickX;
+
308 case LEFT_STICK_Y:
+
309 return leftStickY;
+
310 case RIGHT_STICK_X:
+
311 return rightStickX;
+
312 case RIGHT_STICK_Y:
+
313 return rightStickY;
+
314 case LEFT_TRIGGER:
+
315 return leftTrigger;
+
316 case RIGHT_TRIGGER:
+
317 return rightTrigger;
+
318 default:
+
319 return null;
+
320 }
+
321 }
+
322
+
323 /**
+
324 * Returns a button as boolean (same as isPressed)
+
325 *
+
326 * @param bu The enum to specify which button to get as boolean
+
327 * @return The chosen button as boolean
+
328 */
+
329 public boolean getButtonAsBoolean(Button bu) {
+
330 return getButton(bu).getAsBoolean();
+
331 }
+
332
+
333 /**
+
334 * Returns an axis as double
+
335 *
+
336 * @param as The enum to specify which axis to get as double
+
337 * @return The chosen axis as double
+
338 */
+
339 public double getAxisAsDouble(Axis as) {
+
340 return getAxis(as).getAsDouble();
+
341 }
+
342
+
343 /**
+
344 * Returns an axis as boolean
+
345 *
+
346 * @param as The enum to specify which axis to get as boolean
+
347 * @return The chosen axis as boolean
+
348 */
+
349 public boolean getAxisAsBoolean(Axis as) {
+
350 return getAxis(as).getAsBoolean();
+
351 }
+
352
+
353 /**
+
354 * Returns the left stick
+
355 *
+
356 * @return The left stick on the gamepad
+
357 */
+
358 public GamepadStick<U, T> getLeftStick() {
+
359 return leftStick;
+
360 }
+
361
+
362 /**
+
363 * Returns the right stick
+
364 *
+
365 * @return The right stick on the gamepad
+
366 */
+
367 public GamepadStick<U, T> getRightStick() {
+
368 return rightStick;
+
369 }
+
370
+
371 /**
+
372 * Returns the Dpad object
+
373 *
+
374 * @return The dpad
+
375 */
+
376 public GamepadDpad<T> getDpad() {
+
377 return dpad;
+
378 }
+
379
+
380 /**
+
381 * Run the periodic functions for the controller (if the controller is enabled)
+
382 */
+
383 @Override
+
384 public void periodic() {
+
385 if (isDisabled()) {
+
386 return;
+
387 }
+
388 for (Periodic p : periodics) {
+
389 p.periodic();
+
390 }
+
391 }
+
392
+
393 /**
+
394 * Returns the encapsulated gamepad
+
395 *
+
396 * @return The gamepad
+
397 */
+
398 public Gamepad getGamepad() {
+
399 return gamepad;
+
400 }
+
401
+
402 /**
+
403 * Great a ButtonBase type from the given BooleanSupplier
+
404 *
+
405 * @param b the function to wrap in a ButtonBase
+
406 * @return the T (extends ButtonBase) which the ButtonBase will wrap
+
407 * @throws InstantiationException Couldn't create the target type
+
408 * @throws IllegalAccessException Couldn't access the constructor
+
409 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
+
410 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
+
411 */
+
412 public T buttonInstance(BooleanSupplier b)
+
413 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
414 return buttonClass.getConstructor(BooleanSupplier.class).newInstance(b);
+
415 }
+
416
+
417 /**
+
418 * Returns the U (extended from AxisBase) type wrapped around a simple DoubleSupplier
+
419 *
+
420 * @param d The function to call
+
421 * @return A U (of AxisBase type) that's wrapped around the DoubleSupplier d provided
+
422 * @throws InstantiationException Couldn't create the target type
+
423 * @throws IllegalAccessException Couldn't access the constructor
+
424 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
+
425 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
+
426 */
+
427 public U axisInstance(DoubleSupplier d)
+
428 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
429 return axisClass.getConstructor(DoubleSupplier.class).newInstance(d);
+
430 }
+
431
+
432 // rumble stuff
+
433
+
434 /**
+
435 * Run a bunch of "RumbleBlips"
+
436 *
+
437 * @param blips The number of blips
+
438 */
+
439 public void rumbleBlips(int blips) {
+
440 gamepad.rumbleBlips(blips);
+
441 }
+
442
+
443 /**
+
444 * Run a single "RumbleBlip"
+
445 */
+
446 public void rumbleBlip() {
+
447 rumbleBlips(1);
+
448 }
+
449
+
450 /**
+
451 * Rumble the gamepad for 'seconds'
+
452 *
+
453 * @param seconds The number of (fractional) seconds to rumble for
+
454 */
+
455 public void rumble(double seconds) {
+
456 gamepad.rumble((int) (seconds * 1000));
+
457 }
+
458
+
459 /**
+
460 * Is the gamepad rumbling
+
461 *
+
462 * @return true if the gamepad is rumbling
+
463 */
+
464 public boolean isRumbling() {
+
465 return gamepad.isRumbling();
+
466 }
+
467
+
468 /**
+
469 * Stop rumbling on the gamepad
+
470 */
+
471 public void stopRumble() {
+
472 gamepad.stopRumble();
+
473 }
+
474
+
475 /**
+
476 * Rumble for about 1/8th of a second
+
477 */
+
478 public void rumble() {
+
479 rumble(120);
+
480 }
+
481
+
482 /**
+
483 * Enable/disable the gamepad (and all potentially bound commands!)
+
484 *
+
485 * @param enable True for enabled, false for disabled
+
486 * @return the Gamepad (for chaining)
+
487 */
+
488 @Override
+
489 public GamepadBase<T, U> setEnabled(boolean enable) {
+
490 enabled = enable;
+
491 for (CanBeEnabled<?> enablable : enablables) enablable.setEnabled(enable);
+
492 return this;
+
493 }
+
494
+
495 /**
+
496 * Is the gamepad (and all bound commands from it!) enabled?
+
497 *
+
498 * @return true if it's enabled, false if it's disabled
+
499 */
+
500 @Override
+
501 public boolean isEnabled() {
+
502 return enabled;
+
503 }
+
504}
diff --git a/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.html b/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.html
index a487922d..5959de85 100644
--- a/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.html
+++ b/docs/TechnoLib/src-html/com/technototes/library/control/GamepadBase.html
@@ -30,495 +30,494 @@
014 * @param <U> The class for the axis components on the gamepad
015 * @author Alex Stedman
016 */
-
017public class GamepadBase<T extends ButtonBase, U extends AxisBase> implements Periodic, CanBeEnabled<GamepadBase<T, U>> {
-
018
-
019 private boolean enabled = true;
-
020 // normal gamepad
-
021 private Gamepad gamepad;
-
022 /**
-
023 * The button objects for the XBox game controller
-
024 */
-
025 public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
-
026 /**
-
027 * The button objects for the PS4 game controller
-
028 */
-
029 public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
-
030 /**
-
031 * The button objects for both the XBox and PS4 controllers
-
032 */
-
033 public T leftBumper, rightBumper, dpadUp, dpadDown, dpadLeft, dpadRight, leftStickButton, rightStickButton;
-
034 /**
-
035 * The axis objects
-
036 */
-
037 public U leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY;
-
038 /**
-
039 * The stick objects
-
040 */
-
041 public GamepadStick<U, T> leftStick, rightStick;
-
042 /**
-
043 * The dpad object
-
044 */
-
045 public GamepadDpad<T> dpad;
-
046
-
047 // periodics to run
-
048 private Periodic[] periodics;
-
049 private CanBeEnabled<?>[] enablables;
-
050
-
051 private Class<T> buttonClass;
-
052 private Class<U> axisClass;
-
053
-
054 /**
-
055 * Creates a gamepad with these parameters
-
056 *
-
057 * @param g The gamepad to base around
-
058 * @param bClass The class object passed for the button components (Should be the same as the one used for the class parameter T)
-
059 * @param aClass The class object passed for the axis components (Should be the same as the one used for the class parameter U)
-
060 */
-
061 public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
-
062 gamepad = g;
-
063 buttonClass = bClass;
-
064 axisClass = aClass;
-
065 try {
-
066 setComponents(g);
-
067 } catch (Exception e) {
-
068 e.printStackTrace();
-
069 }
-
070
-
071 leftStick = new GamepadStick<>(leftStickX, leftStickY, leftStickButton);
-
072 rightStick = new GamepadStick<>(rightStickX, rightStickY, rightStickButton);
-
073 dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
-
074 periodics =
-
075 new Periodic[] {
-
076 xbox_a,
-
077 xbox_b,
-
078 xbox_x,
-
079 xbox_y,
-
080 xbox_start,
-
081 xbox_back,
-
082 leftBumper,
-
083 rightBumper,
-
084 leftTrigger,
-
085 rightTrigger,
-
086 leftStick,
-
087 rightStick,
-
088 dpad,
-
089 };
-
090 enablables =
-
091 new CanBeEnabled[] {
-
092 xbox_a,
-
093 xbox_b,
-
094 xbox_x,
-
095 xbox_y,
-
096 xbox_start,
-
097 xbox_back,
-
098 leftBumper,
-
099 rightBumper,
-
100 leftTrigger,
-
101 rightTrigger,
-
102 leftStick,
-
103 rightStick,
-
104 dpad,
-
105 };
-
106 }
-
107
-
108 // to actually instantiate the objects
-
109 private void setComponents(Gamepad g)
-
110 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
111 // buttons
-
112 // a=new T();
-
113 xbox_a = buttonInstance(() -> g.a);
-
114 xbox_b = buttonInstance(() -> g.b);
-
115 xbox_x = buttonInstance(() -> g.x);
-
116 xbox_y = buttonInstance(() -> g.y);
-
117 ps_cross = xbox_a;
-
118 ps_circle = xbox_b;
-
119 ps_square = xbox_x;
-
120 ps_triangle = xbox_y;
-
121
-
122 xbox_start = buttonInstance(() -> g.start);
-
123 xbox_back = buttonInstance(() -> g.back);
-
124 ps_share = xbox_back;
-
125 ps_options = xbox_start;
-
126
-
127 // bumpers
-
128 leftBumper = buttonInstance(() -> g.left_bumper);
-
129 rightBumper = buttonInstance(() -> g.right_bumper);
-
130
-
131 // dpad
-
132 dpadUp = buttonInstance(() -> g.dpad_up);
-
133 dpadDown = buttonInstance(() -> g.dpad_down);
-
134 dpadLeft = buttonInstance(() -> g.dpad_left);
-
135 dpadRight = buttonInstance(() -> g.dpad_right);
-
136
-
137 // left stick
-
138 leftStickX = axisInstance(() -> g.left_stick_x);
-
139 leftStickY = axisInstance(() -> g.left_stick_y);
-
140 leftStickButton = buttonInstance(() -> g.left_stick_button);
-
141
-
142 // right stick
-
143 rightStickX = axisInstance(() -> g.right_stick_x);
-
144 rightStickY = axisInstance(() -> g.right_stick_y);
-
145 rightStickButton = buttonInstance(() -> g.right_stick_button);
-
146
-
147 // triggers
-
148 leftTrigger = axisInstance(() -> g.left_trigger);
-
149 rightTrigger = axisInstance(() -> g.right_trigger);
-
150 }
-
151
-
152 // enums
-
153
-
154 /**
-
155 * Button enum for all buttons on gamepad
-
156 */
-
157 public enum Button {
-
158 /**
-
159 * XBox A button
-
160 */
-
161 XBOX_A,
-
162 /**
-
163 * XBox B button
-
164 */
-
165 XBOX_B,
-
166 /**
-
167 * XBox X button
-
168 */
-
169 XBOX_X,
-
170 /**
-
171 * XBox Y button
-
172 */
-
173 XBOX_Y,
-
174 /**
-
175 * PS4 Cross (X) button
-
176 */
-
177 PS_CROSS,
-
178 /**
-
179 * PS4 Circle (O) button
-
180 */
-
181 PS_CIRCLE,
-
182 /**
-
183 * PS4 Square button
-
184 */
-
185 PS_SQUARE,
-
186 /**
-
187 * PS4 Triangle button
-
188 */
-
189 PS_TRIANGLE,
-
190 /**
-
191 * PS4 Share button
-
192 */
-
193 PS_SHARE,
-
194 /**
-
195 * PS4 Options button
-
196 */
-
197 PS_OPTIONS,
-
198 /**
-
199 * XBox Start button
-
200 */
-
201 XBOX_START,
-
202 /**
-
203 * XBox Back button
-
204 */
-
205 XBOX_BACK,
-
206 /**
-
207 * Left bumper button
-
208 */
-
209 LEFT_BUMPER,
-
210 /**
-
211 * Right bumper button
-
212 */
-
213 RIGHT_BUMPER,
-
214 /**
-
215 * Button when clicking the left stick
-
216 */
-
217 LEFT_STICK_BUTTON,
-
218 /**
-
219 * Button which clicking the right stick
-
220 */
-
221 RIGHT_STICK_BUTTON,
-
222 }
-
223
-
224 /**
-
225 * Axis enum for all axis on gamepad
-
226 */
-
227 public enum Axis {
-
228 /**
-
229 * Left stick's horizontal axis
-
230 */
-
231 LEFT_STICK_X,
-
232 /**
-
233 * Left stick's vertical axis
-
234 */
-
235 LEFT_STICK_Y,
-
236 /**
-
237 * Right stick's horizontal axis
-
238 */
-
239 RIGHT_STICK_X,
-
240 /**
-
241 * Right stick's vertical axis
-
242 */
-
243 RIGHT_STICK_Y,
-
244 /**
-
245 * Left Trigger's axis
-
246 */
-
247 LEFT_TRIGGER,
-
248 /**
-
249 * Right Trigger's axis
-
250 */
-
251 RIGHT_TRIGGER,
-
252 }
-
253
-
254 /**
-
255 * Returns a button
-
256 *
-
257 * @param bu The enum to choose which gamepad button to return
-
258 * @return The gamepad button that you choose with the enum
-
259 */
-
260 public T getButton(Button bu) {
-
261 switch (bu) {
-
262 case XBOX_A:
-
263 return xbox_a;
-
264 case XBOX_B:
-
265 return xbox_b;
-
266 case XBOX_X:
-
267 return xbox_x;
-
268 case XBOX_Y:
-
269 return xbox_y;
-
270 case PS_CROSS:
-
271 return ps_cross;
-
272 case PS_CIRCLE:
-
273 return ps_circle;
-
274 case PS_SQUARE:
-
275 return ps_square;
-
276 case PS_TRIANGLE:
-
277 return ps_triangle;
-
278 case PS_SHARE:
-
279 return ps_share;
-
280 case PS_OPTIONS:
-
281 return ps_options;
-
282 case XBOX_BACK:
-
283 return xbox_back;
-
284 case XBOX_START:
-
285 return xbox_start;
-
286 case LEFT_BUMPER:
-
287 return leftBumper;
-
288 case RIGHT_BUMPER:
-
289 return rightBumper;
-
290 case LEFT_STICK_BUTTON:
-
291 return leftStickButton;
-
292 case RIGHT_STICK_BUTTON:
-
293 return rightStickButton;
-
294 default:
-
295 return null;
-
296 }
-
297 }
-
298
-
299 /**
-
300 * Returns an axis
-
301 *
-
302 * @param as The enum for the axis that is wanted to be returned
-
303 * @return The chosen axis
-
304 */
-
305 public U getAxis(Axis as) {
-
306 switch (as) {
-
307 case LEFT_STICK_X:
-
308 return leftStickX;
-
309 case LEFT_STICK_Y:
-
310 return leftStickY;
-
311 case RIGHT_STICK_X:
-
312 return rightStickX;
-
313 case RIGHT_STICK_Y:
-
314 return rightStickY;
-
315 case LEFT_TRIGGER:
-
316 return leftTrigger;
-
317 case RIGHT_TRIGGER:
-
318 return rightTrigger;
-
319 default:
-
320 return null;
-
321 }
-
322 }
-
323
-
324 /**
-
325 * Returns a button as boolean (same as isPressed)
-
326 *
-
327 * @param bu The enum to specify which button to get as boolean
-
328 * @return The chosen button as boolean
-
329 */
-
330 public boolean getButtonAsBoolean(Button bu) {
-
331 return getButton(bu).getAsBoolean();
-
332 }
-
333
-
334 /**
-
335 * Returns an axis as double
-
336 *
-
337 * @param as The enum to specify which axis to get as double
-
338 * @return The chosen axis as double
-
339 */
-
340 public double getAxisAsDouble(Axis as) {
-
341 return getAxis(as).getAsDouble();
-
342 }
-
343
-
344 /**
-
345 * Returns an axis as boolean
-
346 *
-
347 * @param as The enum to specify which axis to get as boolean
-
348 * @return The chosen axis as boolean
-
349 */
-
350 public boolean getAxisAsBoolean(Axis as) {
-
351 return getAxis(as).getAsBoolean();
-
352 }
-
353
-
354 /**
-
355 * Returns the left stick
-
356 *
-
357 * @return The left stick on the gamepad
-
358 */
-
359 public GamepadStick<U, T> getLeftStick() {
-
360 return leftStick;
-
361 }
-
362
-
363 /**
-
364 * Returns the right stick
-
365 *
-
366 * @return The right stick on the gamepad
-
367 */
-
368 public GamepadStick<U, T> getRightStick() {
-
369 return rightStick;
-
370 }
-
371
-
372 /**
-
373 * Returns the Dpad object
-
374 *
-
375 * @return The dpad
-
376 */
-
377 public GamepadDpad<T> getDpad() {
-
378 return dpad;
-
379 }
-
380
-
381 /**
-
382 * Run the periodic functions for the controller (if the controller is enabled)
-
383 */
-
384 @Override
-
385 public void periodic() {
-
386 if (isDisabled()) {
-
387 return;
-
388 }
-
389 for (Periodic p : periodics) {
-
390 p.periodic();
-
391 }
-
392 }
-
393
-
394 /**
-
395 * Returns the encapsulated gamepad
-
396 *
-
397 * @return The gamepad
-
398 */
-
399 public Gamepad getGamepad() {
-
400 return gamepad;
-
401 }
-
402
-
403 /**
-
404 * Great a ButtonBase type from the given BooleanSupplier
-
405 *
-
406 * @param b the function to wrap in a ButtonBase
-
407 * @return the T (extends ButtonBase) which the ButtonBase will wrap
-
408 * @throws InstantiationException Couldn't create the target type
-
409 * @throws IllegalAccessException Couldn't access the constructor
-
410 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
-
411 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
-
412 */
-
413 public T buttonInstance(BooleanSupplier b)
-
414 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
415 return buttonClass.getConstructor(BooleanSupplier.class).newInstance(b);
-
416 }
-
417
-
418 /**
-
419 * Returns the U (extended from AxisBase) type wrapped around a simple DoubleSupplier
-
420 *
-
421 * @param d The function to call
-
422 * @return A U (of AxisBase type) that's wrapped around the DoubleSupplier d provided
-
423 * @throws InstantiationException Couldn't create the target type
-
424 * @throws IllegalAccessException Couldn't access the constructor
-
425 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
-
426 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
-
427 */
-
428 public U axisInstance(DoubleSupplier d)
-
429 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
430 return axisClass.getConstructor(DoubleSupplier.class).newInstance(d);
-
431 }
-
432
-
433 // rumble stuff
-
434
-
435 /**
-
436 * Run a bunch of "RumbleBlips"
-
437 *
-
438 * @param blips The number of blips
-
439 */
-
440 public void rumbleBlips(int blips) {
-
441 gamepad.rumbleBlips(blips);
-
442 }
-
443
-
444 /**
-
445 * Run a single "RumbleBlip"
-
446 */
-
447 public void rumbleBlip() {
-
448 rumbleBlips(1);
-
449 }
-
450
-
451 /**
-
452 * Rumble the gamepad for 'seconds'
-
453 *
-
454 * @param seconds The number of (fractional) seconds to rumble for
-
455 */
-
456 public void rumble(double seconds) {
-
457 gamepad.rumble((int) (seconds * 1000));
-
458 }
-
459
-
460 /**
-
461 * Is the gamepad rumbling
-
462 *
-
463 * @return true if the gamepad is rumbling
-
464 */
-
465 public boolean isRumbling() {
-
466 return gamepad.isRumbling();
-
467 }
-
468
-
469 /**
-
470 * Stop rumbling on the gamepad
-
471 */
-
472 public void stopRumble() {
-
473 gamepad.stopRumble();
-
474 }
-
475
-
476 /**
-
477 * Rumble for about 1/8th of a second
-
478 */
-
479 public void rumble() {
-
480 rumble(120);
-
481 }
-
482
-
483 /**
-
484 * Enable/disable the gamepad (and all potentially bound commands!)
-
485 *
-
486 * @param enable True for enabled, false for disabled
-
487 * @return the Gamepad (for chaining)
-
488 */
-
489 @Override
-
490 public GamepadBase<T, U> setEnabled(boolean enable) {
-
491 enabled = enable;
-
492 for (CanBeEnabled<?> enablable : enablables) enablable.setEnabled(enable);
-
493 return this;
-
494 }
-
495
-
496 /**
-
497 * Is the gamepad (and all bound commands from it!) enabled?
-
498 *
-
499 * @return true if it's enabled, false if it's disabled
-
500 */
-
501 @Override
-
502 public boolean isEnabled() {
-
503 return enabled;
-
504 }
-
505}
+
017public class GamepadBase<T extends ButtonBase, U extends AxisBase>
+
018 implements Periodic, CanBeEnabled<GamepadBase<T, U>> {
+
019
+
020 private boolean enabled = true;
+
021 // normal gamepad
+
022 private Gamepad gamepad;
+
023 /**
+
024 * The button objects for the XBox game controller
+
025 */
+
026 public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
+
027 /**
+
028 * The button objects for the PS4 game controller
+
029 */
+
030 public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
+
031 /**
+
032 * The button objects for both the XBox and PS4 controllers
+
033 */
+
034 public T leftBumper, rightBumper, dpadUp, dpadDown, dpadLeft, dpadRight, leftStickButton, rightStickButton;
+
035 /**
+
036 * The axis objects
+
037 */
+
038 public U leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY;
+
039 /**
+
040 * The stick objects
+
041 */
+
042 public GamepadStick<U, T> leftStick, rightStick;
+
043 /**
+
044 * The dpad object
+
045 */
+
046 public GamepadDpad<T> dpad;
+
047
+
048 // periodics to run
+
049 private Periodic[] periodics;
+
050 private CanBeEnabled<?>[] enablables;
+
051
+
052 private Class<T> buttonClass;
+
053 private Class<U> axisClass;
+
054
+
055 /**
+
056 * Creates a gamepad with these parameters
+
057 *
+
058 * @param g The gamepad to base around
+
059 * @param bClass The class object passed for the button components (Should be the same as the one used for the class parameter T)
+
060 * @param aClass The class object passed for the axis components (Should be the same as the one used for the class parameter U)
+
061 */
+
062 public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
+
063 gamepad = g;
+
064 buttonClass = bClass;
+
065 axisClass = aClass;
+
066 try {
+
067 setComponents(g);
+
068 } catch (Exception e) {
+
069 e.printStackTrace();
+
070 }
+
071
+
072 leftStick = new GamepadStick<>(leftStickX, leftStickY, leftStickButton);
+
073 rightStick = new GamepadStick<>(rightStickX, rightStickY, rightStickButton);
+
074 dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
+
075 periodics = new Periodic[] {
+
076 xbox_a,
+
077 xbox_b,
+
078 xbox_x,
+
079 xbox_y,
+
080 xbox_start,
+
081 xbox_back,
+
082 leftBumper,
+
083 rightBumper,
+
084 leftTrigger,
+
085 rightTrigger,
+
086 leftStick,
+
087 rightStick,
+
088 dpad,
+
089 };
+
090 enablables = new CanBeEnabled[] {
+
091 xbox_a,
+
092 xbox_b,
+
093 xbox_x,
+
094 xbox_y,
+
095 xbox_start,
+
096 xbox_back,
+
097 leftBumper,
+
098 rightBumper,
+
099 leftTrigger,
+
100 rightTrigger,
+
101 leftStick,
+
102 rightStick,
+
103 dpad,
+
104 };
+
105 }
+
106
+
107 // to actually instantiate the objects
+
108 private void setComponents(Gamepad g)
+
109 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
110 // buttons
+
111 // a=new T();
+
112 xbox_a = buttonInstance(() -> g.a);
+
113 xbox_b = buttonInstance(() -> g.b);
+
114 xbox_x = buttonInstance(() -> g.x);
+
115 xbox_y = buttonInstance(() -> g.y);
+
116 ps_cross = xbox_a;
+
117 ps_circle = xbox_b;
+
118 ps_square = xbox_x;
+
119 ps_triangle = xbox_y;
+
120
+
121 xbox_start = buttonInstance(() -> g.start);
+
122 xbox_back = buttonInstance(() -> g.back);
+
123 ps_share = xbox_back;
+
124 ps_options = xbox_start;
+
125
+
126 // bumpers
+
127 leftBumper = buttonInstance(() -> g.left_bumper);
+
128 rightBumper = buttonInstance(() -> g.right_bumper);
+
129
+
130 // dpad
+
131 dpadUp = buttonInstance(() -> g.dpad_up);
+
132 dpadDown = buttonInstance(() -> g.dpad_down);
+
133 dpadLeft = buttonInstance(() -> g.dpad_left);
+
134 dpadRight = buttonInstance(() -> g.dpad_right);
+
135
+
136 // left stick
+
137 leftStickX = axisInstance(() -> g.left_stick_x);
+
138 leftStickY = axisInstance(() -> g.left_stick_y);
+
139 leftStickButton = buttonInstance(() -> g.left_stick_button);
+
140
+
141 // right stick
+
142 rightStickX = axisInstance(() -> g.right_stick_x);
+
143 rightStickY = axisInstance(() -> g.right_stick_y);
+
144 rightStickButton = buttonInstance(() -> g.right_stick_button);
+
145
+
146 // triggers
+
147 leftTrigger = axisInstance(() -> g.left_trigger);
+
148 rightTrigger = axisInstance(() -> g.right_trigger);
+
149 }
+
150
+
151 // enums
+
152
+
153 /**
+
154 * Button enum for all buttons on gamepad
+
155 */
+
156 public enum Button {
+
157 /**
+
158 * XBox A button
+
159 */
+
160 XBOX_A,
+
161 /**
+
162 * XBox B button
+
163 */
+
164 XBOX_B,
+
165 /**
+
166 * XBox X button
+
167 */
+
168 XBOX_X,
+
169 /**
+
170 * XBox Y button
+
171 */
+
172 XBOX_Y,
+
173 /**
+
174 * PS4 Cross (X) button
+
175 */
+
176 PS_CROSS,
+
177 /**
+
178 * PS4 Circle (O) button
+
179 */
+
180 PS_CIRCLE,
+
181 /**
+
182 * PS4 Square button
+
183 */
+
184 PS_SQUARE,
+
185 /**
+
186 * PS4 Triangle button
+
187 */
+
188 PS_TRIANGLE,
+
189 /**
+
190 * PS4 Share button
+
191 */
+
192 PS_SHARE,
+
193 /**
+
194 * PS4 Options button
+
195 */
+
196 PS_OPTIONS,
+
197 /**
+
198 * XBox Start button
+
199 */
+
200 XBOX_START,
+
201 /**
+
202 * XBox Back button
+
203 */
+
204 XBOX_BACK,
+
205 /**
+
206 * Left bumper button
+
207 */
+
208 LEFT_BUMPER,
+
209 /**
+
210 * Right bumper button
+
211 */
+
212 RIGHT_BUMPER,
+
213 /**
+
214 * Button when clicking the left stick
+
215 */
+
216 LEFT_STICK_BUTTON,
+
217 /**
+
218 * Button which clicking the right stick
+
219 */
+
220 RIGHT_STICK_BUTTON,
+
221 }
+
222
+
223 /**
+
224 * Axis enum for all axis on gamepad
+
225 */
+
226 public enum Axis {
+
227 /**
+
228 * Left stick's horizontal axis
+
229 */
+
230 LEFT_STICK_X,
+
231 /**
+
232 * Left stick's vertical axis
+
233 */
+
234 LEFT_STICK_Y,
+
235 /**
+
236 * Right stick's horizontal axis
+
237 */
+
238 RIGHT_STICK_X,
+
239 /**
+
240 * Right stick's vertical axis
+
241 */
+
242 RIGHT_STICK_Y,
+
243 /**
+
244 * Left Trigger's axis
+
245 */
+
246 LEFT_TRIGGER,
+
247 /**
+
248 * Right Trigger's axis
+
249 */
+
250 RIGHT_TRIGGER,
+
251 }
+
252
+
253 /**
+
254 * Returns a button
+
255 *
+
256 * @param bu The enum to choose which gamepad button to return
+
257 * @return The gamepad button that you choose with the enum
+
258 */
+
259 public T getButton(Button bu) {
+
260 switch (bu) {
+
261 case XBOX_A:
+
262 return xbox_a;
+
263 case XBOX_B:
+
264 return xbox_b;
+
265 case XBOX_X:
+
266 return xbox_x;
+
267 case XBOX_Y:
+
268 return xbox_y;
+
269 case PS_CROSS:
+
270 return ps_cross;
+
271 case PS_CIRCLE:
+
272 return ps_circle;
+
273 case PS_SQUARE:
+
274 return ps_square;
+
275 case PS_TRIANGLE:
+
276 return ps_triangle;
+
277 case PS_SHARE:
+
278 return ps_share;
+
279 case PS_OPTIONS:
+
280 return ps_options;
+
281 case XBOX_BACK:
+
282 return xbox_back;
+
283 case XBOX_START:
+
284 return xbox_start;
+
285 case LEFT_BUMPER:
+
286 return leftBumper;
+
287 case RIGHT_BUMPER:
+
288 return rightBumper;
+
289 case LEFT_STICK_BUTTON:
+
290 return leftStickButton;
+
291 case RIGHT_STICK_BUTTON:
+
292 return rightStickButton;
+
293 default:
+
294 return null;
+
295 }
+
296 }
+
297
+
298 /**
+
299 * Returns an axis
+
300 *
+
301 * @param as The enum for the axis that is wanted to be returned
+
302 * @return The chosen axis
+
303 */
+
304 public U getAxis(Axis as) {
+
305 switch (as) {
+
306 case LEFT_STICK_X:
+
307 return leftStickX;
+
308 case LEFT_STICK_Y:
+
309 return leftStickY;
+
310 case RIGHT_STICK_X:
+
311 return rightStickX;
+
312 case RIGHT_STICK_Y:
+
313 return rightStickY;
+
314 case LEFT_TRIGGER:
+
315 return leftTrigger;
+
316 case RIGHT_TRIGGER:
+
317 return rightTrigger;
+
318 default:
+
319 return null;
+
320 }
+
321 }
+
322
+
323 /**
+
324 * Returns a button as boolean (same as isPressed)
+
325 *
+
326 * @param bu The enum to specify which button to get as boolean
+
327 * @return The chosen button as boolean
+
328 */
+
329 public boolean getButtonAsBoolean(Button bu) {
+
330 return getButton(bu).getAsBoolean();
+
331 }
+
332
+
333 /**
+
334 * Returns an axis as double
+
335 *
+
336 * @param as The enum to specify which axis to get as double
+
337 * @return The chosen axis as double
+
338 */
+
339 public double getAxisAsDouble(Axis as) {
+
340 return getAxis(as).getAsDouble();
+
341 }
+
342
+
343 /**
+
344 * Returns an axis as boolean
+
345 *
+
346 * @param as The enum to specify which axis to get as boolean
+
347 * @return The chosen axis as boolean
+
348 */
+
349 public boolean getAxisAsBoolean(Axis as) {
+
350 return getAxis(as).getAsBoolean();
+
351 }
+
352
+
353 /**
+
354 * Returns the left stick
+
355 *
+
356 * @return The left stick on the gamepad
+
357 */
+
358 public GamepadStick<U, T> getLeftStick() {
+
359 return leftStick;
+
360 }
+
361
+
362 /**
+
363 * Returns the right stick
+
364 *
+
365 * @return The right stick on the gamepad
+
366 */
+
367 public GamepadStick<U, T> getRightStick() {
+
368 return rightStick;
+
369 }
+
370
+
371 /**
+
372 * Returns the Dpad object
+
373 *
+
374 * @return The dpad
+
375 */
+
376 public GamepadDpad<T> getDpad() {
+
377 return dpad;
+
378 }
+
379
+
380 /**
+
381 * Run the periodic functions for the controller (if the controller is enabled)
+
382 */
+
383 @Override
+
384 public void periodic() {
+
385 if (isDisabled()) {
+
386 return;
+
387 }
+
388 for (Periodic p : periodics) {
+
389 p.periodic();
+
390 }
+
391 }
+
392
+
393 /**
+
394 * Returns the encapsulated gamepad
+
395 *
+
396 * @return The gamepad
+
397 */
+
398 public Gamepad getGamepad() {
+
399 return gamepad;
+
400 }
+
401
+
402 /**
+
403 * Great a ButtonBase type from the given BooleanSupplier
+
404 *
+
405 * @param b the function to wrap in a ButtonBase
+
406 * @return the T (extends ButtonBase) which the ButtonBase will wrap
+
407 * @throws InstantiationException Couldn't create the target type
+
408 * @throws IllegalAccessException Couldn't access the constructor
+
409 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
+
410 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
+
411 */
+
412 public T buttonInstance(BooleanSupplier b)
+
413 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
414 return buttonClass.getConstructor(BooleanSupplier.class).newInstance(b);
+
415 }
+
416
+
417 /**
+
418 * Returns the U (extended from AxisBase) type wrapped around a simple DoubleSupplier
+
419 *
+
420 * @param d The function to call
+
421 * @return A U (of AxisBase type) that's wrapped around the DoubleSupplier d provided
+
422 * @throws InstantiationException Couldn't create the target type
+
423 * @throws IllegalAccessException Couldn't access the constructor
+
424 * @throws NoSuchMethodException Couldn't find a constructor with a BooleanSupplier parameter
+
425 * @throws InvocationTargetException Couldn't invoke the constructor for other reasons
+
426 */
+
427 public U axisInstance(DoubleSupplier d)
+
428 throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
429 return axisClass.getConstructor(DoubleSupplier.class).newInstance(d);
+
430 }
+
431
+
432 // rumble stuff
+
433
+
434 /**
+
435 * Run a bunch of "RumbleBlips"
+
436 *
+
437 * @param blips The number of blips
+
438 */
+
439 public void rumbleBlips(int blips) {
+
440 gamepad.rumbleBlips(blips);
+
441 }
+
442
+
443 /**
+
444 * Run a single "RumbleBlip"
+
445 */
+
446 public void rumbleBlip() {
+
447 rumbleBlips(1);
+
448 }
+
449
+
450 /**
+
451 * Rumble the gamepad for 'seconds'
+
452 *
+
453 * @param seconds The number of (fractional) seconds to rumble for
+
454 */
+
455 public void rumble(double seconds) {
+
456 gamepad.rumble((int) (seconds * 1000));
+
457 }
+
458
+
459 /**
+
460 * Is the gamepad rumbling
+
461 *
+
462 * @return true if the gamepad is rumbling
+
463 */
+
464 public boolean isRumbling() {
+
465 return gamepad.isRumbling();
+
466 }
+
467
+
468 /**
+
469 * Stop rumbling on the gamepad
+
470 */
+
471 public void stopRumble() {
+
472 gamepad.stopRumble();
+
473 }
+
474
+
475 /**
+
476 * Rumble for about 1/8th of a second
+
477 */
+
478 public void rumble() {
+
479 rumble(120);
+
480 }
+
481
+
482 /**
+
483 * Enable/disable the gamepad (and all potentially bound commands!)
+
484 *
+
485 * @param enable True for enabled, false for disabled
+
486 * @return the Gamepad (for chaining)
+
487 */
+
488 @Override
+
489 public GamepadBase<T, U> setEnabled(boolean enable) {
+
490 enabled = enable;
+
491 for (CanBeEnabled<?> enablable : enablables) enablable.setEnabled(enable);
+
492 return this;
+
493 }
+
494
+
495 /**
+
496 * Is the gamepad (and all bound commands from it!) enabled?
+
497 *
+
498 * @return true if it's enabled, false if it's disabled
+
499 */
+
500 @Override
+
501 public boolean isEnabled() {
+
502 return enabled;
+
503 }
+
504}
diff --git a/docs/TechnoLib/src-html/com/technototes/library/hardware/motor/CRServo.html b/docs/TechnoLib/src-html/com/technototes/library/hardware/motor/CRServo.html
index dc214349..e9c0bf03 100644
--- a/docs/TechnoLib/src-html/com/technototes/library/hardware/motor/CRServo.html
+++ b/docs/TechnoLib/src-html/com/technototes/library/hardware/motor/CRServo.html
@@ -29,7 +29,7 @@
013 * Not Yet Implemented!
014 * TODO: Implement this
015 */
-
016public class CRServo extends HardwareDevice<com.qualcomm.robotcore.hardware.CRServo> implements Supplier<Double> {
+
016public class CRServo extends HardwareDevice<com.qualcomm.robotcore.hardware.CRServo> implements Supplier<Double> {
017
018 private double min = -1, max = 1;
019 protected double power;
@@ -153,8 +153,7 @@
137 public Double get() {
138 return getPower();
139 }
-
140
-
141}
+
140}