Ejemplo n.º 1
0
  /*
   * Updates the values of each button in the gui
   *
   */
  public void updateDetails() {
    for (int i = 0; i < controller.getButtonCount(); i++) {
      values[i].setText("" + controller.isButtonPressed(i));
    }
    for (int i = buttonCount; i < buttonCount + controller.getAxisCount(); i++) {
      values[i].setText("" + controller.getAxisValue(i - buttonCount));
    }

    values[itemCount - 2].setText("" + controller.getPovX());
    values[itemCount - 1].setText("" + controller.getPovY());
  }
Ejemplo n.º 2
0
 public ControllerEvent getInput(int controllerIndex) {
   Controller c = Controllers.getController(controllerIndex);
   ControllerEvent ce = new ControllerEvent();
   if (c.getXAxisValue() < -0.75 && c.getYAxisValue() > -0.75 && c.getYAxisValue() < 0.75) {
     ce.setDirection(Direction.LEFT);
   } else if (c.getXAxisValue() > 0.75 && c.getYAxisValue() > -0.75 && c.getYAxisValue() < 0.75) {
     ce.setDirection(Direction.RIGHT);
   } else if (c.getYAxisValue() < -0.75 && c.getXAxisValue() > -0.75 && c.getXAxisValue() < 0.75) {
     ce.setDirection(Direction.UP);
   } else if (c.getYAxisValue() > 0.75 && c.getXAxisValue() > -0.75 && c.getXAxisValue() < 0.75) {
     ce.setDirection(Direction.DOWN);
   }
   for (Button button : Button.values()) {
     if (c.isButtonPressed(button.buttonID)) {
       if (!buttonWasPressed[controllerIndex][button.buttonID]) {
         ce.addButtonState(button, true);
         buttonWasPressed[controllerIndex][button.buttonID] = true;
       }
     } else {
       buttonWasPressed[controllerIndex][button.buttonID] = false;
     }
   }
   return ce;
 }