Exemple #1
0
  /**
   * Initializes the InputManager.
   *
   * <p>This should only be called internally in {@link Application}.
   *
   * @param mouse
   * @param keys
   * @param joystick
   * @param touch
   * @throws IllegalArgumentException If either mouseInput or keyInput are null.
   */
  public InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch) {
    if (keys == null || mouse == null) {
      throw new NullPointerException("Mouse or keyboard cannot be null");
    }

    this.keys = keys;
    this.mouse = mouse;
    this.joystick = joystick;
    this.touch = touch;

    keys.setInputListener(this);
    mouse.setInputListener(this);
    if (joystick != null) {
      joystick.setInputListener(this);
      joysticks = joystick.loadJoysticks(this);
    }
    if (touch != null) {
      touch.setInputListener(this);
    }

    firstTime = keys.getInputTimeNanos();
  }