wiki:ControlSystems/GameControllers/LogitechF310

The Logitech F310 game controller is an inexpensive alternative to the standard Xbox controller that can be purchased for $20 delivered. The F310 has two analog joysticks and two analog triggers but uses different constants than those defined in GenericHID.Hand to access them.

You can access the F310 joystick axes using the method xbox.getRawAxis(n) where n is the axis number:

   XboxController xbox = new XboxController(0);
   double left_X        =   xbox.getRawAxis(0); // left=-1 .. center=0 .. right=1
   double left_Y        = - xbox.getRawAxis(1); // up=-1.. center=0 .. down=1
   double left_trigger  =   xbox.getRawAxis(2); // negative values: -1..0
   double right_trigger =   xbox.getRawAxis(2); // positive values:  0..1
   double right_X       =   xbox.getRawAxis(3); // left=-1 .. center=0 .. right=1
   double right_Y       = - xbox.getRawAxis(4); // up=-1.. center=0 .. down=1
   double dirpad_X      =   xbox.getRawAxis(5); // left=-1, right=1
   double dirpad_Y      =   xbox.getRawAxis(6); // down=-1, up=1

The buttons can be accessed in the same way as a joystick. For example, in OI.java:

   XboxController xbox = new XboxController(0);
   Button aButton = new JoystickButton(xbox, 1);
   Button bButton = new JoystickButton(xbox, 2);
   Button xButton = new JoystickButton(xbox, 3);
   Button yButton = new JoystickButton(xbox, 4);

   public OI() {
      aButton.whenPressed(new ACommand());
      bButton.whenPressed(new Bcommand());
   }
Last modified 17 months ago Last modified on Dec 16, 2019, 11:24:46 PM

Attachments (1)

Download all attachments as: .zip