@Override
  public void aileronAndElevatorDeadBandValueDidChange(float newValue) {
    JoystickBase rollAndPitchJoyStick = getRollAndPitchJoystick();

    rollAndPitchJoyStick.setXDeadBand(newValue);
    rollAndPitchJoyStick.setYDeadBand(newValue);
  }
  // glView onTouch Event handler
  public boolean onTouch(View v, MotionEvent event) {
    boolean result = false;

    for (int i = 0; i < buttons.length; ++i) {
      if (buttons[i].processTouch(v, event)) {
        result = true;
        break;
      }
    }

    if (result != true) {
      gestureDetector.onTouchEvent(event);

      for (int i = 0; i < joysticks.length; ++i) {
        JoystickBase joy = joysticks[i];
        if (joy != null) {
          if (joy.processTouch(v, event)) {
            result = true;
          }
        }
      }
    }

    return result;
  }
  private void initJoysticks(JoystickType rollAndPitchType) {
    JoystickBase rollAndPitchJoystick = getRollAndPitchJoystick();
    JoystickBase rudderAndThrottleJoystick = getRudderAndThrottleJoystick();

    if (rollAndPitchType == JoystickType.ANALOGUE) {
      if (rollAndPitchJoystick == null || !(rollAndPitchJoystick instanceof AnalogueJoystick)) {
        rollAndPitchJoystick =
            JoystickFactory.createAnalogueJoystick(
                this.getContext(), false, rollPitchListener, true);
        rollAndPitchJoystick.setXDeadBand(settings.getAileronDeadBand());
        rollAndPitchJoystick.setYDeadBand(settings.getElevatorDeadBand());
      } else {
        rollAndPitchJoystick.setOnAnalogueChangedListener(rollPitchListener);
      }
    } else if (rollAndPitchType == JoystickType.ACCELERO) {
      if (rollAndPitchJoystick == null || !(rollAndPitchJoystick instanceof AcceleratorJoystick)) {
        rollAndPitchJoystick =
            JoystickFactory.createAcceleroJoystick(
                this.getContext(), false, rollPitchListener, true);
        // rollAndPitchJoystick.setXDeadBand(settings.getAileronDeadBand());
        // rollAndPitchJoystick.setYDeadBand(settings.getElevatorDeadBand());
      } else {
        rollAndPitchJoystick.setOnAnalogueChangedListener(rollPitchListener);
      }
    }

    if (rudderAndThrottleJoystick == null
        || !(rudderAndThrottleJoystick instanceof AnalogueJoystick)) {
      rudderAndThrottleJoystick =
          JoystickFactory.createAnalogueJoystick(
              this.getContext(), false, rudderThrottleListener, false);
      rudderAndThrottleJoystick.setXDeadBand(settings.getRudderDeadBand());
    } else {
      rudderAndThrottleJoystick.setOnAnalogueChangedListener(rudderThrottleListener);
    }

    rollAndPitchJoystick.setIsRollPitchJoystick(true);
    rudderAndThrottleJoystick.setIsRollPitchJoystick(false);

    joysticks[0] = rollAndPitchJoystick;
    joysticks[1] = rudderAndThrottleJoystick;

    setJoysticks();

    getRudderAndThrottleJoystick().setYValue(-1);
  }
  public void setJoysticks() {
    JoystickBase rollAndPitchJoystick = joysticks[0];
    JoystickBase rudderAndThrottleJoystick = joysticks[1];

    if (rollAndPitchJoystick != null) {
      if (isLeftHanded) {
        joysticks[0].setAlign(Align.BOTTOM_RIGHT);
        joysticks[0].setAlpha(joypadOpacity);
      } else {
        joysticks[0].setAlign(Align.BOTTOM_LEFT);
        joysticks[0].setAlpha(joypadOpacity);
      }

      rollAndPitchJoystick.setNeedsUpdate();
    }

    if (rudderAndThrottleJoystick != null) {
      if (isLeftHanded) {
        joysticks[1].setAlign(Align.BOTTOM_LEFT);
        joysticks[1].setAlpha(joypadOpacity);
      } else {
        joysticks[1].setAlign(Align.BOTTOM_RIGHT);
        joysticks[1].setAlpha(joypadOpacity);
      }

      rudderAndThrottleJoystick.setNeedsUpdate();
    }

    for (int i = 0; i < joysticks.length; ++i) {
      JoystickBase joystick = joysticks[i];

      if (joystick != null) {
        joystick.setInverseYWhenDraw(true);

        int margin = context.getResources().getDimensionPixelSize(R.dimen.hud_joy_margin);

        joystick.setMargin(0, margin, bottomBarBg.getHeight() + margin, margin);
      }
    }

    renderer.removeSprite(JOY_ID_LEFT);
    renderer.removeSprite(JOY_ID_RIGHT);

    if (rollAndPitchJoystick != null) {
      if (isLeftHanded) {
        renderer.addSprite(JOY_ID_RIGHT, rollAndPitchJoystick);
      } else {
        renderer.addSprite(JOY_ID_LEFT, rollAndPitchJoystick);
      }
    }

    if (rudderAndThrottleJoystick != null) {
      if (isLeftHanded) {
        renderer.addSprite(JOY_ID_LEFT, rudderAndThrottleJoystick);
      } else {
        renderer.addSprite(JOY_ID_RIGHT, rudderAndThrottleJoystick);
      }
    }
  }
  @Override
  public void rudderDeadBandValueDidChange(float newValue) {
    JoystickBase rudderAndThrottleStick = getRudderAndThrottleJoystick();

    rudderAndThrottleStick.setXDeadBand(newValue);
  }