Package org.lwjgl.input

Examples of org.lwjgl.input.Controller


    }

    int count = Controllers.getControllerCount();
    System.out.println(count+" Controllers Found");
    for (int i=0;i<count;i++) {
      Controller controller = Controllers.getController(i);
      System.out.println(controller.getName());
    }

    if (count == 0) {
      System.exit(0);
    }
View Full Code Here


    if(!loaded)
      loadBindings();
    JoystickAim.selectedJoystickMode = aimTypes[mc.vrSettings.joystickAimType];
    joyAim = JoystickAim.selectedJoystickMode;
    for( int c = 0; c < Controllers.getControllerCount();c++) {
      Controller cont = Controllers.getController(c);
      for( int a = 0; a < cont.getAxisCount(); a++ ) {
        cont.setDeadZone(a, mc.vrSettings.joystickDeadzone);
      }
    }
        if( this.mc.currentScreen != null && (this.screenNavigator == null || this.screenNavigator.screen != this.mc.currentScreen) )
          this.screenNavigator = new GuiScreenNaviator(this.mc.currentScreen );
    Controllers.poll();
View Full Code Here

        bindingSaves.put(nextBind.key, String.format("py:%s",posVal?"+":"-"));
    }
   
    boolean bind( ControlBinding nextBind) {
      boolean bound = false;
      Controller cont = Controllers.getEventSource();
      String alreadyBound = "";
     
     
      //Unbind a value if it is being remapped
      int index = Controllers.getEventControlIndex();
      if( revAxisBinds.containsKey(nextBind)) {
        alreadyBound = cont.getAxisName(revAxisBinds.get(nextBind).getLeft())+" axis";
        if( nextBind.isBiAxis() ) {
          int axis_index =  revAxisBinds.get(nextBind).getKey();
          axisBinds.remove( Pair.of(axis_index, true ) );
          axisBinds.remove( Pair.of(axis_index, false) );
        } else {
          axisBinds.remove( revAxisBinds.get(nextBind));
        }
        revAxisBinds.remove( nextBind );
      }
      if( revButtonBinds.containsKey(nextBind)) {
        Integer button =  revButtonBinds.get(nextBind);
        alreadyBound = cont.getButtonName(button)+" button";
        buttonBinds.remove(button);
        revButtonBinds.remove( nextBind );
      }
      if( povXBindPos == nextBind ) {
        povXBindPos = null;
        alreadyBound = "POV X+";
      } else if( povYBindPos == nextBind ) {
        povYBindPos = null;
        alreadyBound = "POV Y+";
      } else if( povXBindNeg == nextBind ) {
        povXBindNeg = null;
        alreadyBound = "POV X-";
      } else if( povYBindNeg == nextBind ) {
        povYBindNeg = null;
        alreadyBound = "POV Y-";
      }

      if( !alreadyBound.isEmpty() )
        System.out.println( nextBind.getDescription()+" already bound to "+alreadyBound+". Removing.");

     
      //Bind to value
      if( Controllers.isEventAxis() ) {
        float joyVal = cont.getAxisValue(index);
        boolean posVal = joyVal>0;
        if(Math.abs(joyVal)>0.5f) {
          bindAxis( nextBind, index, posVal, cont.getAxisName(index));
          bound = true;
        }
      } else if( Controllers.isEventButton() ) {
        if( cont.isButtonPressed(index)) {
          bindButton( nextBind, index, cont.getButtonName(index) );
          bound = true;
        }
      } else if( Controllers.isEventPovX()) {
        if( cont.getPovX() != 0)
        {
          bindPovX(nextBind, cont.getPovX() > 0);
          bound = true;
        }
      } else if( Controllers.isEventPovY()) {
        if( cont.getPovY() != 0)
        {
          bindPovY(nextBind, cont.getPovY() > 0);
          bound = true;
        }
      }
      return bound;
    }
View Full Code Here

      }
      return bound;
    }
   
    void activate() {
      Controller cont = Controllers.getEventSource();
      int index = Controllers.getEventControlIndex();
      if( Controllers.isEventAxis() ) {
        float joyVal = cont.getAxisValue(index);
        ControlBinding bindPos = axisBinds.get( Pair.of(index,true ) );
        ControlBinding bindNeg = axisBinds.get( Pair.of(index,false) );
        if( bindPos == bindNeg ) {
          if( bindPos != null)
            bindPos.setValue( joyVal );
        } else {
          if( joyVal > 0 ) {
            if( bindNeg != null )
              bindNeg.setValue( 0 );
            if( bindPos != null )
              bindPos.setValue( joyVal );
          } else {
            if( bindPos != null )
              bindPos.setValue( 0 );
            if( bindNeg != null )
              bindNeg.setValue( -joyVal );
          }
        }
      } else if( Controllers.isEventButton() ) {
        ControlBinding bind = buttonBinds.get(index);
        if( bind != null ) {
          bind.setState( cont.isButtonPressed(index));
        }
      } else if( Controllers.isEventPovX()) {
        if( cont.getPovX() > 0) {
          if( povXBindPos != null)
            povXBindPos.setState(true);
        } else if ( cont.getPovX() < 0 ) {
          if( povXBindNeg != null)
            povXBindNeg.setState(true);
        } else {
          if( povXBindPos != null)
            povXBindPos.setState(false);
          if( povXBindNeg != null)
            povXBindNeg.setState(false);
        }
      } else if( Controllers.isEventPovY()) {
        if( cont.getPovY() > 0) {
          if( povYBindPos != null)
            povYBindPos.setState(true);
        } else if ( cont.getPovY() < 0 ) {
          if( povYBindNeg != null)
            povYBindNeg.setState(true);
        } else {
          if( povYBindPos != null)
            povYBindPos.setState(false);
View Full Code Here

    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");
View Full Code Here

        if (!_eventsIt.hasNext()) {
            _eventsIt = new LwjglControllerEventIterator();
        }

        while (Controllers.next()) {
            final Controller source = Controllers.getEventSource();
            if (Controllers.isEventButton()) {
                _events.add(new ControllerEvent(Controllers.getEventNanoseconds(), source.getName(), source
                        .getButtonName(Controllers.getEventControlIndex()), source.isButtonPressed(Controllers
                        .getEventControlIndex()) ? 1f : 0f));
            } else if (Controllers.isEventAxis()) {
                _events.add(new ControllerEvent(Controllers.getEventNanoseconds(), source.getName(), source
                        .getAxisName(Controllers.getEventControlIndex()), source.getAxisValue(Controllers
                        .getEventControlIndex())));
            } else if (Controllers.isEventPovX()) {
                _events.add(new ControllerEvent(Controllers.getEventNanoseconds(), source.getName(), "Pov X", source
                        .getPovX()));
            } else if (Controllers.isEventPovY()) {
                _events.add(new ControllerEvent(Controllers.getEventNanoseconds(), source.getName(), "Pov Y", source
                        .getPovY()));
            }
        }

        return _eventsIt;
View Full Code Here

            return;
        }
        try {
            Controllers.create();
            for (int i = 0, max = Controllers.getControllerCount(); i < max; i++) {
                final Controller controller = Controllers.getController(i);
                _controllers.add(getControllerInfo(controller));
                for (int j = 0; j < controller.getAxisCount(); j++) {
                    ControllerState.NOTHING.set(controller.getName(), controller.getAxisName(j), 0);
                }
                for (int j = 0; j < controller.getButtonCount(); j++) {
                    ControllerState.NOTHING.set(controller.getName(), controller.getButtonName(j), 0);
                }
            }
        } catch (final Exception e) {
            e.printStackTrace();
        } finally {
View Full Code Here

    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");
View Full Code Here

    controllers = new ArrayList<Controller>(controllerCount);

    // add all controllers with reasonable number of axes to list
    for (int i = 0; i < controllerCount; ++i) {
      Controller cur = Controllers.getController(i);
      if (cur.getAxisCount() > 0 && cur.getAxisCount() <= 32)
        controllers.add(cur);
    }

    // adjust controllerCount
    controllerCount = controllers.size();
View Full Code Here

  public String getControllerName(int index) {
    return controllers.get(index).getName();
  }

  public ControllerAction getNextControllerEvent(int controllerIndex) {
    Controller controller = controllers.get(controllerIndex);

    while (Controllers.next()) {
      int eventControllerIndex = Controllers.getEventSource().getIndex();

      if (eventControllerIndex == controller.getIndex()) {
        int eventControlIndex = Controllers.getEventControlIndex();
        ControllerAction.Type type;
        int direction = 0;
        if (Controllers.isEventAxis()) {
          type = ControllerAction.Type.AXIS;
          if (controller.getAxisValue(eventControlIndex) > 0.5f)
            direction = 1;
          else if (controller.getAxisValue(eventControlIndex) < -0.5f)
            direction = -1;
          else
            continue;
        } else if (Controllers.isEventButton()) {
          type = ControllerAction.Type.BUTTON;
        } else if (Controllers.isEventPovX()) {
          type = ControllerAction.Type.POV_X;
          if (controller.getPovX() > 0.5f)
            direction = 1;
          else if (controller.getPovX() < -0.5f)
            direction = -1;
          else
            continue;
        } else if (Controllers.isEventPovY()) {
          type = ControllerAction.Type.POV_Y;
          if (controller.getPovY() > 0.5f)
            direction = 1;
          else if (controller.getPovY() < -0.5f)
            direction = -1;
          else
            continue;
        } else
          continue;
View Full Code Here

TOP

Related Classes of org.lwjgl.input.Controller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.