@@ -335,12 +335,14 @@ public static enum AnalogOption {
335335 * use of this filter is to reject data points which errantly (due to averaging or sampling) appear within the
336336 * window when detecting transitions using the Rising Edge and Falling Edge functionality of the analog trigger
337337 */
338- FILTERED , /**
339- * The analog output is averaged and over sampled.
340- */
341- AVERAGED , /**
342- * No filtering or averaging is to be used.
343- */
338+ FILTERED ,
339+ /**
340+ * The analog output is averaged and over sampled.
341+ */
342+ AVERAGED ,
343+ /**
344+ * No filtering or averaging is to be used.
345+ */
344346 NONE ;
345347 }
346348
@@ -354,10 +356,11 @@ public static enum TriggerMode {
354356 * The switch is triggered only when the analog value is inside the range, and not triggered if it is outside (above
355357 * or below)
356358 */
357- IN_WINDOW , /**
358- * The switch is triggered only when the value is above the upper limit, and not triggered if it is below
359- * the lower limit and maintains the previous state if in between (hysteresis)
360- */
359+ IN_WINDOW ,
360+ /**
361+ * The switch is triggered only when the value is above the upper limit, and not triggered if it is below the lower
362+ * limit and maintains the previous state if in between (hysteresis)
363+ */
361364 AVERAGED ;
362365 }
363366
@@ -764,6 +767,10 @@ public static Relay relay(int channel) {
764767
765768 public static final class HumanInterfaceDevices {
766769
770+ private static void verifyJoystickConnected (Joystick joystick ) {
771+ joystick .getButtonCount ();
772+ }
773+
767774 /**
768775 * Create an generic input device controlled by the Driver Station.
769776 *
@@ -772,6 +779,7 @@ public static final class HumanInterfaceDevices {
772779 */
773780 public static InputDevice driverStationJoystick (int port ) {
774781 Joystick joystick = new Joystick (port );
782+ verifyJoystickConnected (joystick );
775783 return InputDevice .create (joystick ::getRawAxis , joystick ::getRawButton , joystick ::getPOV );
776784 }
777785
@@ -783,6 +791,7 @@ public static InputDevice driverStationJoystick(int port) {
783791 */
784792 public static FlightStick logitechAttack3D (int port ) {
785793 Joystick joystick = new Joystick (port );
794+ verifyJoystickConnected (joystick );
786795 return FlightStick .create (joystick ::getRawAxis ,
787796 joystick ::getRawButton ,
788797 joystick ::getPOV ,
@@ -802,6 +811,7 @@ public static FlightStick logitechAttack3D(int port) {
802811 */
803812 public static FlightStick logitechExtreme3D (int port ) {
804813 Joystick joystick = new Joystick (port );
814+ verifyJoystickConnected (joystick );
805815 return FlightStick .create (joystick ::getRawAxis ,
806816 joystick ::getRawButton ,
807817 joystick ::getPOV ,
@@ -821,6 +831,7 @@ public static FlightStick logitechExtreme3D(int port) {
821831 */
822832 public static FlightStick microsoftSideWinder (int port ) {
823833 Joystick joystick = new Joystick (port );
834+ verifyJoystickConnected (joystick );
824835 return FlightStick .create (joystick ::getRawAxis ,
825836 joystick ::getRawButton ,
826837 joystick ::getPOV ,
@@ -840,6 +851,7 @@ public static FlightStick microsoftSideWinder(int port) {
840851 */
841852 public static Gamepad logitechDualAction (int port ) {
842853 Joystick joystick = new Joystick (port );
854+ verifyJoystickConnected (joystick );
843855 return Gamepad .create (joystick ::getRawAxis ,
844856 joystick ::getRawButton ,
845857 joystick ::getPOV ,
@@ -869,6 +881,7 @@ public static Gamepad logitechDualAction(int port) {
869881 */
870882 public static Gamepad logitechF310 (int port ) {
871883 Joystick joystick = new Joystick (port );
884+ verifyJoystickConnected (joystick );
872885 return Gamepad .create (joystick ::getRawAxis ,
873886 joystick ::getRawButton ,
874887 joystick ::getPOV ,
@@ -889,7 +902,7 @@ public static Gamepad logitechF310(int port) {
889902 () -> joystick .getRawButton (8 ),
890903 () -> joystick .getRawButton (9 ));
891904 }
892-
905+
893906 /**
894907 * Create a Microsoft Xbox360 gamepad controlled by the Driver Station.
895908 *
@@ -898,6 +911,7 @@ public static Gamepad logitechF310(int port) {
898911 */
899912 public static Gamepad xbox360 (int port ) {
900913 Joystick joystick = new Joystick (port );
914+ verifyJoystickConnected (joystick );
901915 return Gamepad .create (joystick ::getRawAxis ,
902916 joystick ::getRawButton ,
903917 joystick ::getPOV ,
0 commit comments