コード例 #1
0
 public static List<Integer> getJoypadList(boolean includeInvalid) {
   List<Integer> joypadList = ControllerSettings.flattenMap(ControllerSettings.validControllers);
   if (includeInvalid) {
     joypadList.addAll(ControllerSettings.flattenMap(ControllerSettings.inValidControllers));
   }
   return joypadList;
 }
コード例 #2
0
 public ControllerSettings(File configFile) {
   config = new ConfigFile(configFile);
   config.init();
   controllerUtils = new ControllerUtils();
   validControllers = new HashMap<String, List<Integer>>();
   inValidControllers = new HashMap<String, List<Integer>>();
   joyBindingsMap = new HashMap<String, ControllerBinding>();
   userDefinedBindings = new ArrayList<ControllerBinding>();
   grabMouse = ControllerSettings.getGameOption("-Global-.GrabMouse").equals("true");
   try {
     Controllers.create();
   } catch (Exception ex) {
     LogHelper.Error("Failed creating controller object. " + ex.toString());
   }
 }
コード例 #3
0
  public static boolean setController(int controllerNo) {
    LogHelper.Info("Attempting to use controller " + controllerNo);
    try {
      if (!Controllers.isCreated()) Controllers.create();

      LogHelper.Info("Controllers.getControllerCount == " + Controllers.getControllerCount());

      if (controllerNo < 0 || controllerNo >= Controllers.getControllerCount()) {
        LogHelper.Error(
            "Attempting to set controller index "
                + controllerNo
                + " there are currently "
                + Controllers.getControllerCount()
                + " controllers detected.");
        return false;
      }

      ControllerSettings.setDefaultJoyBindingMap(controllerNo, true);
      joyNo = controllerNo;
      controllerUtils.printDeadZones(Controllers.getController(controllerNo));
      inputEnabled = true;

      applySavedDeadZones(joyNo);

      config.updatePreferedJoy(controllerNo, Controllers.getController(controllerNo).getName());

      Minecraft.getMinecraft().gameSettings.pauseOnLostFocus = false;
      JoypadMouse.AxisReader.centerCrosshairs();
      checkIfBindingsNeedUpdating();
      unpressAll();
      return true;
    } catch (Exception e) {
      LogHelper.Error("Couldn't initialize Controllers: " + e.toString());
      inputEnabled = false;
    }
    return false;
  }