コード例 #1
0
  public static void setInputEnabled(int joyIndex, boolean b) {
    unpressAll();
    if (!b) {
      JoypadMouse.AxisReader.setXY(0, 0);
      VirtualMouse.setXY(0, 0);
      inputEnabled = false;
      config.updatePreferedJoy(-1, null);
      return;
    }

    if (joyNo != joyIndex) {
      setController(joyIndex);
      return;
    }

    inputEnabled = true;
    config.updatePreferedJoy(joyIndex, Controllers.getController(joyIndex).getName());
    JoypadMouse.AxisReader.centerCrosshairs();
  }
コード例 #2
0
  public void init() {
    LogHelper.Info(
        "Minecraft Joypad (Controller) Mod v"
            + ModVersionHelper.VERSION
            + " by Ljubomir Simin & Andrew Hickey\n---");

    if (config.preferedJoyName == "disabled") {
      LogHelper.Warn(
          "Controller input disabled due to joypad value 'preferedJoyName' set to disabled");
      inputEnabled = false;
      ControllerSettings.modDisabled = true;
      return;
    }

    LogHelper.Info("Initializing Controllers");

    // only set a controller as in use on init if they have previously gone
    // into controls to set it up
    // and it is detected as present

    int nControllers = detectControllers();
    int selectedController = -1;
    if (nControllers > 0 && config.preferedJoyNo >= 0) {
      selectedController = checkForControllerAtIndex(config.preferedJoyName, config.preferedJoyNo);
      if (selectedController >= 0) {
        setController(selectedController);
        Controllers.clearEvents();
      } else {
        LogHelper.Info("No joypad set up for this session.  Must enter controller menu to enable");
      }
    }

    if (selectedController < 0) {
      LogHelper.Warn(
          "No joypad set up for this session."
              + (nControllers > 0 ? " Must enter controller menu to enable." : ""));
      inputEnabled = false;
    }
  }