public XboxControllerSupport() { System.out.println("JInput version: " + Version.getVersion()); xboxController = getXboxController(); if (xboxController == null) { System.out.println("No Xbox controller detected, disabling game pad support"); } else { System.out.println("360 Controller Found"); dPad = xboxController.getComponent(Component.Identifier.Axis.POV); buttons = new Component[10]; buttons[A_BUTTON] = xboxController.getComponent(Component.Identifier.Button._0); buttons[B_BUTTON] = xboxController.getComponent(Component.Identifier.Button._1); buttons[X_BUTTON] = xboxController.getComponent(Component.Identifier.Button._2); buttons[Y_BUTTON] = xboxController.getComponent(Component.Identifier.Button._3); buttons[START_BUTTON] = xboxController.getComponent(Component.Identifier.Button._7); buttons[BACK_BUTTON] = xboxController.getComponent(Component.Identifier.Button._6); } }
/** * Gets position of the Hat Switch. Float number that is returned by this method correspond with * positions in the JInput class Component.POV. * * @return Float number that corresponds with the Hat Switch position. */ public float getHatSwitchPosition() { Identifier identifier = Component.Identifier.Axis.POV; return controller.getComponent(identifier).getPollData(); }
/** * Value of axis named Y Rotation. * * @return Y Rotation value. */ public float getYRotationValue() { Identifier identifier = Component.Identifier.Axis.RY; return controller.getComponent(identifier).getPollData(); }
/** * Value of axis named Z Axis. * * @return Z Axis value. */ public float getZAxisValue() { Identifier identifier = Component.Identifier.Axis.Z; return controller.getComponent(identifier).getPollData(); }
/** * Gets value of component with given identifier. * * @param identifier Identifier that correspond to component from which we need value. * @return Component value. */ public float getComponentValue(Identifier identifier) { return controller.getComponent(identifier).getPollData(); }
/** * Checks if component with given identifier exists. * * @param identifier Identifier that correspond to component. * @return True if component exists or false if not exists. */ public boolean componentExists(Identifier identifier) { Component component = controller.getComponent(identifier); if (component != null) return true; else return false; }