public void setDeadZones(float xDeadZone, float yDeadZone) {
   for (int i = 0; i < Controllers.getControllerCount(); i++) {
     Controller c = Controllers.getController(i);
     c.setXAxisDeadZone(xDeadZone);
     c.setYAxisDeadZone(yDeadZone);
   }
 }
Beispiel #2
0
  /**
   * Initialise the controllers system
   *
   * @throws SlickException Indicates a failure to use the hardware
   */
  public void initControllers() throws SlickException {
    if (controllersInited) {
      return;
    }

    controllersInited = true;
    try {
      Controllers.create();
      int count = Controllers.getControllerCount();

      for (int i = 0; i < count; i++) {
        Controller controller = Controllers.getController(i);

        if ((controller.getButtonCount() >= 3) && (controller.getButtonCount() < MAX_BUTTONS)) {
          controllers.add(controller);
        }
      }

      Log.info("Found " + controllers.size() + " controllers");
      for (int i = 0; i < controllers.size(); i++) {
        Log.info(i + " : " + ((Controller) controllers.get(i)).getName());
      }
    } catch (LWJGLException e) {
      if (e.getCause() instanceof ClassNotFoundException) {
        throw new SlickException(
            "Unable to create controller - no jinput found - add jinput.jar to your classpath");
      }
      throw new SlickException("Unable to create controllers");
    } catch (NoClassDefFoundError | UnsatisfiedLinkError e) {
      // forget it, no jinput availble
    }
  }
  public static void resetBindings(int joyIndex) {
    if (joyIndex >= 0 && joyIndex < Controllers.getControllerCount()) {
      currentDisplayedMap = -1;
      setDefaultJoyBindingMap(joyIndex, false);
      for (Map.Entry<String, ControllerBinding> entry : joyBindingsMap.entrySet()) {
        if (!entry.getKey().contains("user."))
          config.saveControllerBinding(
              Controllers.getController(joyIndex).getName(), entry.getValue());
      }
    }

    unpressAll();
  }
  static void pollDevices() {
    // Poll the input devices while we're here
    if (Mouse.isCreated()) {
      Mouse.poll();
      Mouse.updateCursor();
    }

    if (Keyboard.isCreated()) {
      Keyboard.poll();
    }

    if (Controllers.isCreated()) {
      Controllers.poll();
    }
  }
  public static void applySavedDeadZones(int joyId) {
    if (joyId < 0) return;

    LogHelper.Info("Applying configurated deadzones");

    config.applySavedDeadZones(Controllers.getController(joyId));
  }
 public static void unsetControllerBinding(int joyIndex, String key) {
   ControllerBinding binding = joyBindingsMap.get(key);
   if (binding != null) {
     binding.inputEvent = new ButtonInputEvent(0, -1, 1);
     config.saveControllerBinding(Controllers.getController(joyIndex).getName(), binding);
     unpressAll();
   }
 }
  public static void saveDeadZones(int joyId) {
    Controller controller = Controllers.getController(joyId);
    DecimalFormat df = new DecimalFormat("#0.00");

    for (int i = 0; i < controller.getAxisCount(); i++) {
      config.setConfigFileSetting(
          "-Deadzones-." + controller.getName(),
          controller.getAxisName(i),
          df.format(controller.getDeadZone(i)));
    }
    config.addComment(
        "-Deadzones-", "Deadzone values here will override values in individual bindings");
    LogHelper.Info("Saved deadzones for " + controller.getName());
  }
 public void createControllers() {
   Controllers.destroy();
   try {
     Controllers.create();
     for (int i = 0; i < Controllers.getControllerCount(); i++) {
       Controller c = Controllers.getController(i);
       c.setXAxisDeadZone(DEFAULT_DEAD_ZONE);
       c.setYAxisDeadZone(DEFAULT_DEAD_ZONE);
     }
     buttonWasPressed =
         new boolean[getControllerCount()][Controllers.getController(0).getButtonCount()];
     // c = controller index
     for (int c = 0; c < buttonWasPressed.length; c++) {
       // b = buttonID index
       for (int b = 0; b < buttonWasPressed[0].length; b++) {
         buttonWasPressed[c][b] = false;
       }
     }
   } catch (LWJGLException e) {
     // TODO Auto-generated catch block
     // Sys.alert("Something went wrong!", e.getMessage());
   }
 }
 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());
   }
 }
  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();
  }
  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;
    }
  }
 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;
 }
  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;
  }
  private int detectControllers() {
    validControllers.clear();
    inValidControllers.clear();

    try {
      if (!Controllers.isCreated()) Controllers.create();

      if (Controllers.getControllerCount() > 0) {
        LogHelper.Info("Found " + Controllers.getControllerCount() + " controller(s) in total.");
        for (int joyIndex = 0; joyIndex < Controllers.getControllerCount(); joyIndex++) {
          Controller thisController = Controllers.getController(joyIndex);

          logControllerInfo(thisController);

          if (controllerUtils.meetsInputRequirements(
              thisController, requiredButtonCount, requiredMinButtonCount, requiredAxisCount)) {
            LogHelper.Info(
                "Controller #"
                    + joyIndex
                    + " ( "
                    + thisController.getName()
                    + ") meets the input requirements");
            addControllerToList(validControllers, thisController.getName(), joyIndex);
          } else {
            LogHelper.Info("This controller does not meet the input requirements");
            addControllerToList(inValidControllers, thisController.getName(), joyIndex);
          }
          LogHelper.Info("---");
        }
      }
    } catch (org.lwjgl.LWJGLException e) {
      System.err.println("Couldn't initialize Controllers: " + e.getMessage());
    }

    LogHelper.Info("Found " + validControllers.size() + " valid controllers!");
    return validControllers.size();
  }
Beispiel #15
0
  // Constructor - Creates a Controller object for every controller detected
  public TestControllers(int index) {

    // Get the controller index from the Controllers group
    controller = Controllers.getController(index);
    // Gui LayoutManager
    setLayout(null);

    // Get the number of buttons on the controller
    buttonCount = controller.getButtonCount();
    // Get the number of buttons + the number of hat pads
    itemCount = controller.getButtonCount() + controller.getAxisCount() + 2;
    // Create a Gui Box for every button / hat pad
    values = new JTextField[itemCount];
    names = new JTextField[itemCount];

    for (int i = 0; i < controller.getButtonCount(); i++) {
      names[i] = new JTextField();
      names[i].setEditable(false);
      names[i].setBounds(0, i * 30, 100, 30);
      names[i].setText(controller.getButtonName(i));
      add(names[i]);
      values[i] = new JTextField();
      values[i].setEditable(false);
      values[i].setBounds(100, i * 30, 100, 30);
      add(values[i]);
    }
    for (int i = buttonCount; i < buttonCount + controller.getAxisCount(); i++) {
      names[i] = new JTextField();
      names[i].setEditable(false);
      names[i].setBounds(0, i * 30, 100, 30);
      names[i].setText(controller.getAxisName(i - buttonCount));
      add(names[i]);
      values[i] = new JTextField();
      values[i].setEditable(false);
      values[i].setBounds(100, i * 30, 100, 30);
      add(values[i]);
    }

    int i = itemCount - 2;
    names[i] = new JTextField();
    names[i].setEditable(false);
    names[i].setBounds(0, i * 30, 100, 30);
    names[i].setText("POV X");
    add(names[i]);
    values[i] = new JTextField();
    values[i].setEditable(false);
    values[i].setBounds(100, i * 30, 100, 30);
    add(values[i]);

    i = itemCount - 1;
    names[i] = new JTextField();
    names[i].setEditable(false);
    names[i].setBounds(0, i * 30, 100, 30);
    names[i].setText("POV Y");
    add(names[i]);
    values[i] = new JTextField();
    values[i].setEditable(false);
    values[i].setBounds(100, i * 30, 100, 30);
    add(values[i]);

    total++;

    setPreferredSize(new Dimension(200, 30 * itemCount));
    JFrame frame = new JFrame(controller.getName());
    frame.setContentPane(new JScrollPane(this));
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            total--;
            if (total == 0) {
              System.exit(0);
            }
          }
        });
    frame.setSize(230, 400);
    frame.setLocation(index * 30, index * 30);
    frame.setVisible(true);
  }
Beispiel #16
0
  public static void main(String[] argv) {

    // Create the environment of controllers
    try {
      Controllers.create();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }

    // Print how many controllers there are
    int count = Controllers.getControllerCount();
    System.out.println(count + " Controllers Found");

    // Print the name of each controller
    for (int i = 0; i < count; i++) {
      Controller controller = Controllers.getController(i);
      System.out.println(controller.getName() + " ");
      System.out.println("Number of Rumblers " + controller.getRumblerCount());
      System.out.println("Index Number " + controller.getIndex());
    }

    // If there are no controllers, exit program
    if (count == 0) {
      System.exit(0);
    }

    TestControllers[] controllerWindows = new TestControllers[count];
    for (int i = 0; i < count; i++) {
      controllerWindows[i] = new TestControllers(i);
    }

    // Start the "Game"
    boolean running = true;
    while (running) {
      // Sleep for 100 milliseonds, no need to poll too fast
      try {
        Thread.sleep(100);
      } catch (Exception e) {
      }
      ;

      // Poll all the controllers
      Controllers.poll();

      /*
       * Controllers have an event listener
       * Whenever a button is pushed it add the event
       * it to the buffer of the controller instance
       * As long as the buffer has something in it
       * we print it out                                 *
       */
      while (Controllers.next()) {
        //	                                System.out.println("Event Fired: ");
        //
        // System.out.println("\t"+Controllers.getEventNanoseconds());
        //
        // System.out.println("\t"+Controllers.getEventSource()+":"+Controllers.getEventControlIndex()+":"+Controllers.isEventButton());
        //
        // System.out.println("\t"+Controllers.isEventXAxis()+":"+Controllers.isEventYAxis());

        // Controller number
        int controllerNumber = Controllers.getEventSource().getIndex();
        // Button number
        int buttonNumber = Controllers.getEventControlIndex();
        /*
         * Pressing a button on an xBox controller slightly alters the analog values
         * This causes multiple unwanted events on button push
         * By checking to see if the event was a button we can strip out the uneeded events
         */
        if (Controllers.isEventButton() == true) {
          handleButtonPush(controllerNumber, buttonNumber);
        }
      }

      for (int i = 0; i < count; i++) {
        controllerWindows[i].updateDetails();
      }
    }
  } // end main
Beispiel #17
0
 public void startGame() throws LWJGLException {
   if (mcCanvas != null) {
     Graphics g = mcCanvas.getGraphics();
     if (g != null) {
       g.setColor(Color.BLACK);
       g.fillRect(0, 0, displayWidth, displayHeight);
       g.dispose();
     }
     Display.setParent(mcCanvas);
   } else if (fullscreen) {
     Display.setFullscreen(true);
     displayWidth = Display.getDisplayMode().getWidth();
     displayHeight = Display.getDisplayMode().getHeight();
     if (displayWidth <= 0) {
       displayWidth = 1;
     }
     if (displayHeight <= 0) {
       displayHeight = 1;
     }
   } else {
     Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
   }
   Display.setTitle("Minecraft Minecraft Beta 1.7.3");
   try {
     Display.create();
   } catch (LWJGLException lwjglexception) {
     lwjglexception.printStackTrace();
     try {
       Thread.sleep(1000L);
     } catch (InterruptedException interruptedexception) {
     }
     Display.create();
   }
   mcDataDir = getMinecraftDir();
   saveLoader = new SaveConverterMcRegion(new File(mcDataDir, "saves"));
   gameSettings = new GameSettings(this, mcDataDir);
   texturePackList = new TexturePackList(this, mcDataDir);
   renderEngine = new RenderEngine(texturePackList, gameSettings);
   fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine);
   ColorizerWater.func_28182_a(renderEngine.func_28149_a("/misc/watercolor.png"));
   ColorizerGrass.func_28181_a(renderEngine.func_28149_a("/misc/grasscolor.png"));
   ColorizerFoliage.func_28152_a(renderEngine.func_28149_a("/misc/foliagecolor.png"));
   entityRenderer = new EntityRenderer(this);
   RenderManager.instance.itemRenderer = new ItemRenderer(this);
   statFileWriter = new StatFileWriter(session, mcDataDir);
   AchievementList.openInventory.setStatStringFormatter(new StatStringFormatKeyInv(this));
   loadScreen();
   Keyboard.create();
   Mouse.create();
   mouseHelper = new MouseHelper(mcCanvas);
   try {
     Controllers.create();
   } catch (Exception exception) {
     exception.printStackTrace();
   }
   checkGLError("Pre startup");
   GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
   GL11.glShadeModel(7425 /*GL_SMOOTH*/);
   GL11.glClearDepth(1.0D);
   GL11.glEnable(2929 /*GL_DEPTH_TEST*/);
   GL11.glDepthFunc(515);
   GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
   GL11.glAlphaFunc(516, 0.1F);
   GL11.glCullFace(1029 /*GL_BACK*/);
   GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
   GL11.glLoadIdentity();
   GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
   checkGLError("Startup");
   glCapabilities = new OpenGlCapsChecker();
   sndManager.loadSoundSettings(gameSettings);
   renderEngine.registerTextureFX(textureLavaFX);
   renderEngine.registerTextureFX(textureWaterFX);
   renderEngine.registerTextureFX(new TexturePortalFX());
   renderEngine.registerTextureFX(new TextureCompassFX(this));
   renderEngine.registerTextureFX(new TextureWatchFX(this));
   renderEngine.registerTextureFX(new TextureWaterFlowFX());
   renderEngine.registerTextureFX(new TextureLavaFlowFX());
   renderEngine.registerTextureFX(new TextureFlamesFX(0));
   renderEngine.registerTextureFX(new TextureFlamesFX(1));
   renderGlobal = new RenderGlobal(this, renderEngine);
   GL11.glViewport(0, 0, displayWidth, displayHeight);
   effectRenderer = new EffectRenderer(theWorld, renderEngine);
   try {
     downloadResourcesThread = new ThreadDownloadResources(mcDataDir, this);
     downloadResourcesThread.start();
   } catch (Exception exception1) {
   }
   checkGLError("Post startup");
   ingameGUI = new GuiIngame(this);
   if (serverName != null) {
     displayGuiScreen(new GuiConnecting(this, serverName, serverPort));
   } else {
     displayGuiScreen(new GuiMainMenu());
   }
 }
 private static void saveCurrentJoyBindings() {
   String joyName = Controllers.getController(currentDisplayedMap).getName();
   for (Map.Entry<String, ControllerBinding> entry : joyBindingsMap.entrySet()) {
     config.saveControllerBinding(joyName, entry.getValue());
   }
 }
  public static void setDefaultJoyBindingMap(int joyIndex, boolean updateWithConfigFile) {
    if (currentDisplayedMap == joyIndex) {
      LogHelper.Info(
          "Skipping setting up the joybinding map as it is already set up for this joypad");
      return;
    }

    currentDisplayedMap = joyIndex;

    GameSettings settings = Minecraft.getMinecraft().gameSettings;
    LogHelper.Info("Setting default joy binding map");

    joyBindingsMap.clear();

    int yAxisIndex = ControllerUtils.findYAxisIndex(joyIndex);
    int xAxisIndex = ControllerUtils.findXAxisIndex(joyIndex);

    joyBindingsMap.put(
        "joy.jump",
        new ControllerBinding(
            "joy.jump",
            "Jump",
            new ButtonInputEvent(joyIndex, 0, 1),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindJump)},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_MOVEMENT)));

    joyBindingsMap.put(
        "joy.inventory",
        new ControllerBinding(
            "joy.inventory",
            "Open inventory",
            new ButtonInputEvent(joyIndex, 3, 1),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindInventory)},
            100,
            EnumSet.of(BindingOptions.GAME_BINDING, BindingOptions.CATEGORY_INVENTORY)));

    joyBindingsMap.put(
        "joy.drop",
        new ControllerBinding(
            "joy.drop",
            "Drop",
            new ButtonInputEvent(joyIndex, 6, 1),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindDrop)},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.sneak",
        new ControllerBinding(
            "joy.sneak",
            "Sneak",
            new ButtonInputEvent(joyIndex, 8, 1),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindSneak)},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_MOVEMENT)));

    joyBindingsMap.put(
        "joy.attack",
        new ControllerBinding(
            "joy.attack",
            "Attack",
            new AxisInputEvent(joyIndex, 4, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            new int[] {-100},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.use",
        new ControllerBinding(
            "joy.use",
            "Use",
            new AxisInputEvent(joyIndex, 4, defaultAxisThreshhold, defaultAxisDeadZone),
            new int[] {-99},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.interact",
        new ControllerBinding(
            "joy.interact",
            "Interact",
            new ButtonInputEvent(joyIndex, 2, 1),
            new int[] {-99},
            0,
            EnumSet.of(BindingOptions.GAME_BINDING, BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.guiLeftClick",
        new ControllerBinding(
            "joy.guiLeftClick",
            "Left click",
            new ButtonInputEvent(joyIndex, 0, 1),
            new int[] {-100},
            0,
            EnumSet.of(BindingOptions.MENU_BINDING, BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.guiRightClick",
        new ControllerBinding(
            "joy.guiRightClick",
            "Right click",
            new ButtonInputEvent(joyIndex, 2, 1),
            new int[] {-99},
            0,
            EnumSet.of(BindingOptions.MENU_BINDING, BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.prevItem",
        new ControllerBinding(
            "joy.prevItem",
            "Previous item",
            new ButtonInputEvent(joyIndex, 4, 1),
            new int[] {-199},
            0,
            EnumSet.of(BindingOptions.GAME_BINDING, BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.nextItem",
        new ControllerBinding(
            "joy.nextItem",
            "Next item",
            new ButtonInputEvent(joyIndex, 5, 1),
            new int[] {-201},
            0,
            EnumSet.of(BindingOptions.GAME_BINDING, BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.sprint",
        new ControllerBinding(
            "joy.sprint",
            "Sprint",
            new ButtonInputEvent(joyIndex, 9, 1),
            new int[] {Keyboard.KEY_LCONTROL},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.menu",
        new ControllerBinding(
            "joy.menu",
            "Open menu",
            new ButtonInputEvent(joyIndex, 7, 1),
            new int[] {Keyboard.KEY_ESCAPE},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.MENU_BINDING,
                BindingOptions.CATEGORY_MISC)));

    joyBindingsMap.put(
        "joy.shiftClick",
        new ControllerBinding(
            "joy.shiftClick",
            "Shift-click",
            new ButtonInputEvent(joyIndex, 1, 1),
            new int[] {Keyboard.KEY_LSHIFT, -100},
            0,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_INVENTORY)));

    joyBindingsMap.put(
        "joy.cameraX+",
        new ControllerBinding(
            "joy.cameraX+",
            "Look right",
            new AxisInputEvent(
                joyIndex, xAxisIndex + 2, defaultAxisThreshhold, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.cameraX-",
        new ControllerBinding(
            "joy.cameraX-",
            "Look left",
            new AxisInputEvent(
                joyIndex, xAxisIndex + 2, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.cameraY-",
        new ControllerBinding(
            "joy.cameraY-",
            "Look up",
            new AxisInputEvent(
                joyIndex, xAxisIndex + 1, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.cameraY+",
        new ControllerBinding(
            "joy.cameraY+",
            "Look down",
            new AxisInputEvent(
                joyIndex, xAxisIndex + 1, defaultAxisThreshhold, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_GAMEPLAY)));

    joyBindingsMap.put(
        "joy.right",
        new ControllerBinding(
            "joy.right",
            "Strafe right",
            new AxisInputEvent(joyIndex, xAxisIndex, defaultAxisThreshhold, defaultAxisDeadZone),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindRight)},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_MOVEMENT)));

    joyBindingsMap.put(
        "joy.left",
        new ControllerBinding(
            "joy.left",
            "Strafe left",
            new AxisInputEvent(
                joyIndex, xAxisIndex, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindLeft)},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_MOVEMENT)));

    joyBindingsMap.put(
        "joy.back",
        new ControllerBinding(
            "joy.back",
            "Move backward",
            new AxisInputEvent(joyIndex, yAxisIndex, defaultAxisThreshhold, defaultAxisDeadZone),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindBack)},
            yAxisIndex,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_MOVEMENT)));

    joyBindingsMap.put(
        "joy.forward",
        new ControllerBinding(
            "joy.forward",
            "Move forward",
            new AxisInputEvent(
                joyIndex, yAxisIndex, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindForward)},
            0,
            EnumSet.of(
                BindingOptions.GAME_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_MOVEMENT)));

    joyBindingsMap.put(
        "joy.guiX+",
        new ControllerBinding(
            "joy.guiX+",
            "GUI right",
            new AxisInputEvent(joyIndex, xAxisIndex, defaultAxisThreshhold, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.guiX-",
        new ControllerBinding(
            "joy.guiX-",
            "GUI left",
            new AxisInputEvent(
                joyIndex, xAxisIndex, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.guiY+",
        new ControllerBinding(
            "joy.guiY+",
            "GUI down",
            new AxisInputEvent(joyIndex, yAxisIndex, defaultAxisThreshhold, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.guiY-",
        new ControllerBinding(
            "joy.guiY-",
            "GUI up",
            new AxisInputEvent(
                joyIndex, yAxisIndex, defaultAxisThreshhold * -1, defaultAxisDeadZone),
            null,
            0,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.closeInventory",
        new ControllerBinding(
            "joy.closeInventory",
            "Close container",
            new ButtonInputEvent(joyIndex, 3, 1),
            new int[] {McObfuscationHelper.keyCode(settings.keyBindInventory)},
            100,
            EnumSet.of(BindingOptions.MENU_BINDING, BindingOptions.CATEGORY_INVENTORY)));

    joyBindingsMap.put(
        "joy.scrollDown",
        new ControllerBinding(
            "joy.scrollDown",
            "Scroll down",
            new ButtonInputEvent(joyIndex, 5, 1),
            new int[] {-201},
            scrollDelay,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.RENDER_TICK,
                BindingOptions.CATEGORY_UI)));

    joyBindingsMap.put(
        "joy.scrollUp",
        new ControllerBinding(
            "joy.scrollUp",
            "Scroll up",
            new ButtonInputEvent(joyIndex, 4, 1),
            new int[] {-199},
            scrollDelay,
            EnumSet.of(
                BindingOptions.MENU_BINDING,
                BindingOptions.REPEAT_IF_HELD,
                BindingOptions.RENDER_TICK,
                BindingOptions.CATEGORY_UI)));

    if (updateWithConfigFile)
      config.getJoypadSavedBindings(joyIndex, Controllers.getController(joyIndex).getName());

    List<ControllerBinding> userBindings = config.getUserDefinedBindings(joyIndex);

    for (ControllerBinding b : userBindings) {
      joyBindingsMap.put(b.inputString, b);
    }
  }
 public int getControllerCount() {
   return Controllers.getControllerCount();
 }
 public void pollControllers() {
   for (int i = 0; i < Controllers.getControllerCount(); i++) {
     Controller c = Controllers.getController(i);
     c.poll();
   }
 }
 public static void setControllerBinding(
     int joyIndex, String bindingKey, ControllerBinding binding) {
   ControllerSettings.joyBindingsMap.put(bindingKey, binding);
   config.saveControllerBinding(Controllers.getController(joyIndex).getName(), binding);
 }
 public Controller getController(int index) {
   return Controllers.getController(index);
 }