Package net.java.games.input.Component

Examples of net.java.games.input.Component.Identifier


            log = button.getIdentifier().getName();
        }
        int ID = (val == -1f || val == 1f) ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED;
        if (button.getIdentifier() instanceof net.java.games.input.Component.Identifier.Axis) {
            String direction = "";
            Identifier axisX = Player._gamepadCodeMap.get(Player.key.valueOf(player + "_backwards"));
            Identifier axisY = Player._gamepadCodeMap.get(Player.key.valueOf(player + "_up"));
            if (axisY instanceof Identifier && axisX instanceof Identifier) {
                if (axisX.getName().equals(button.getIdentifier().getName())) {
                    if (Player.id.ONE.equals(player)) {
                        direction = (val == -1f) ? "backwards" : ((val == 1f) ? "forwards" : ((lastPollX == -1f) ? "backwards" : ((lastPollX == 1f) ? "forwards" : "")));
                    } else if (Player.id.TWO.equals(player)) {
                        direction = (val == 1f) ? "backwards" : ((val == -1f) ? "forwards" : ((lastPollX == 1f) ? "backwards" : ((lastPollX == -1f) ? "forwards" : "")));
                    }
                    lastPollX = val;
                } else if (axisY.getName().equals(button.getIdentifier().getName())) {
                    direction = (val == 1f) ? "down" : ((val == -1f) ? "up" : ((lastPollY == 1f) ? "down" : ((lastPollY == -1f) ? "up" : "")));
                    lastPollY = val;
                }
                if (!direction.equals("")) {
                    keyboardKey = Player.key.valueOf(player + "_" + direction);
                    if (JXAenvUtils._debug) {
                        log = " Player  " + player + " gamepad " + keyboardKey + ((ID == KeyEvent.KEY_PRESSED) ? "pressed" : "released");
                    }
                }
            }
        } else {
            synchronized (Player._gamepadCodeMap) {
                    for (Player.key key : Player._gamepadCodeMap.keySet()) {
                            if (key.player.equals(player)) {
                                    Identifier name = Player._gamepadCodeMap.get(key);
                                    if (button.getIdentifier().getName().equals(name.getName())) {
                                            keyboardKey = key;
                                            break;
                                    }
                            }
                    }
View Full Code Here


       
            int joyId = stick.getJoyId();
                   
            EventQueue q = c.getEventQueue();
            while (q.getNextEvent(e)){
                Identifier id = e.getComponent().getIdentifier();
                if (id == Identifier.Axis.POV){
                    float x = 0, y = 0;
                    float v = e.getValue();
                    if (v == POV.CENTER){
View Full Code Here

            this.povY = nullAxis;                                                    
        }

        protected void addComponent( Component comp ) {
           
            Identifier id = comp.getIdentifier();
            if( id instanceof Button ) {
                addButton(comp);
            } else if( id instanceof Axis ) {
                addAxis(comp);
            } else {
View Full Code Here

        protected void addButton( Component comp ) {
       
            logger.log(Level.FINE, "Adding button: \"{0}\" id:" + comp.getIdentifier(), comp);
           
            Identifier id = comp.getIdentifier();           
            if( !(id instanceof Button) ) {
                throw new IllegalArgumentException( "Component is not an axis:" + comp );
            }

            String name = comp.getName();
            String original = id.getName();
            String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original );
            if( name != original ) {
                logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId);
            }
View Full Code Here

       
        protected void addAxis( Component comp ) {

            logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + comp.getIdentifier(), comp );
                           
            Identifier id = comp.getIdentifier();
            if( !(id instanceof Axis) ) {
                throw new IllegalArgumentException( "Component is not an axis:" + comp );
            }
           
            String name = comp.getName();
            String original = id.getName();
            String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original );
            if( name != original ) {
                logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId);
            }
           
            JoystickAxis axis = new DefaultJoystickAxis( getInputManager(),
                                                         this, getAxisCount(), name, logicalId,
                                                         comp.isAnalog(), comp.isRelative(),
                                                         comp.getDeadZone() );
            addAxis(axis);                                                         
            axisIndex.put( comp, axis );
                      
            // Support the X/Y axis indexes
            if( id == Axis.X ) {
                xAxis = axis;
            } else if( id == Axis.Y ) {
                yAxis = axis;
            } else if( id == Axis.POV ) {
               
                // Add two fake axes for the JME provided convenience
                // axes: AXIS_POV_X, AXIS_POV_Y
                povX = new DefaultJoystickAxis( getInputManager(),
                                                this, getAxisCount(), JoystickAxis.POV_X,
                                                id.getName() + "_x",
                                                comp.isAnalog(), comp.isRelative(), comp.getDeadZone() );
                logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + id.getName() + "_x", povX.getName() );
                addAxis(povX);
                povY = new DefaultJoystickAxis( getInputManager(),
                                                this, getAxisCount(), JoystickAxis.POV_Y,
                                                id.getName() + "_y",
                                                comp.isAnalog(), comp.isRelative(), comp.getDeadZone() );
                logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + id.getName() + "_y", povY.getName() );
                addAxis(povY);
            }
           
        }
View Full Code Here

        // FIXME - switch statement (it's Java 7 !)
        for (int i = 0; i < components.length; i++) {


          Component component = components[i];
          Identifier id = component.getIdentifier();

          String n = components[i].getName();
          float data = components[i].getPollData();

          // buffer.append(n);
          // TODO - invoke based on
          // invoke(String.trim(component.getName()),
          // mapMultiplier(getName()), mapOffset(getName()) - REFACTOR
          // REFACTOR !!! use switch statement
         
                                         if (Identifier.Axis.Z.equals(id)) {
            if (lastValues[i] != data) {
              if (ZAxisTransform) {
                invoke("ZAxis", (int) (ZAxisMultiplier * data) + ZAxisOffset);
              } else {
                invoke("ZAxisRaw", data);
              }
            }

          } else if (Identifier.Axis.RZ.equals(id)) {
            if (lastValues[i] != data) {
              if (ZRotTransform) {
                invoke("ZRotation", (int) (ZRotMultiplier * data) + ZRotOffset);
              } else {
                invoke("ZRotationRaw", data);
              }
            }
          } else if (Identifier.Axis.X.equals(id)) {
            if (lastValues[i] != data) {
              if (XAxisTransform) {
                invoke("XAxis", (int) (XAxisMultiplier * data) + XAxisOffset);
              } else {
                invoke("XAxisRaw", data);
              }
            }
          } else if (Identifier.Axis.Y.equals(id)) {
            if (lastValues[i] != data) {
              if (YAxisTransform) {
                invoke("YAxis", (int) (YAxisMultiplier * data) + YAxisOffset);
              } else {
                invoke("YAxisRaw", data);
              }
            }
          } else if (Identifier.Axis.POV.equals(id)) {
            if (lastValues[i] != data) {
              if (hatTransform) {
                invoke("hatSwitch", (int) (hatMultiplier * data) + hatOffset);
              } else {
                invoke("hatSwitchRaw", data);
              }
            }
                                               
                                               
                                               
                                                } else if (Identifier.Axis.SLIDER.equals(id)) {
            if (lastValues[i] != data) {
              if (sliderTransform) {
                invoke("slider", (int) (sliderMultiplier * data) + sliderOffset);
              } else {
                invoke("sliderRaw", data);
                                                                System.out.println("sliderRaw" + data);
              }
            }
                                               
                                               
            // WTF ??? - A on Linux _0 on Windows, really? I mean
            // really? Why?
          } else if (Identifier.Button.A.equals(id) || Identifier.Button._0.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button1", pos);
            }
          } else if (Identifier.Button.B.equals(id) || Identifier.Button._1.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button2", pos);
            }
          } else if (Identifier.Button.C.equals(id) || Identifier.Button._2.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button3", pos);
            }
          } else if (Identifier.Button.X.equals(id) || Identifier.Button._3.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button4", pos);
            }
          } else if (Identifier.Button.Y.equals(id) || Identifier.Button._4.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button5", pos);
            }
          } else if (Identifier.Button.Z.equals(id) || Identifier.Button._5.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button6", pos);
            }
          } else if (Identifier.Button.LEFT_THUMB.equals(id) || Identifier.Button._6.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button7", pos);
            }
          } else if (Identifier.Button.RIGHT_THUMB.equals(id) || Identifier.Button._7.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button8", pos);
            }
          } else if (Identifier.Button.LEFT_THUMB2.equals(id) || Identifier.Button._8.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button9", pos);
            }
          } else if (Identifier.Button.RIGHT_THUMB2.equals(id) || Identifier.Button._9.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button10", pos);
            }
          } else if (Identifier.Button.SELECT.equals(id) || Identifier.Button._10.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button11", pos);
            }
          } else if (Identifier.Button.UNKNOWN.equals(id) || Identifier.Button._11.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button12", pos);
            }
          } else if (Identifier.Button._12.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button13", pos);
            }
         
                                        } else if (Identifier.Button._13.equals(id)) {
            int pos = (int) data;
            if (lastValues[i] != data) {
              invoke("button14", pos);
            }                                         
                                               
                                       
                                        } else {
            System.out.println(String.format("unknown identifier %s", id.toString()));
          }

          lastValues[i] = data;
                                        System.out.println("kierunek XY: " + getXYStickDir()+ " " + comps[xAxisIdx].getPollData() + " " + comps[yAxisIdx].getPollData());

View Full Code Here

      // Go trough all components of the controller.
      Component[] components = controller.getComponents();
      for (int i = 0; i < components.length; i++) {
        Component component = components[i];
        Identifier componentIdentifier = component.getIdentifier();
        log.info(componentIdentifier.getName() + ": "
            + component.getPollData());

        // Buttons
        if (!component.isAnalog()) {
          // Is button pressed?
          boolean isItPressed = true;
          if (component.getPollData() == 0.0f) {
            isItPressed = false;
          }

          // Button index
          String buttonIndex;
          buttonIndex = componentIdentifier.getName();

          // Create and add new button to panel.
          JToggleButton aToggleButton = new JToggleButton(
              buttonIndex, isItPressed);
          aToggleButton.setPreferredSize(new Dimension(48, 25));
View Full Code Here

     *
     * @return X Axis value.
     */
    public float getXAxisValue()
    {
        Identifier identifier = Component.Identifier.Axis.X;
        return controller.getComponent(identifier).getPollData();
    }
View Full Code Here

     *
     * @return Y Axis value.
     */
    public float getYAxisValue()
    {
        Identifier identifier = Component.Identifier.Axis.Y;
        return controller.getComponent(identifier).getPollData();
    }
View Full Code Here

     *
     * @return Z Rotation value.
     */
    public float getZRotationValue()
    {
        Identifier identifier = Component.Identifier.Axis.RZ;
        return controller.getComponent(identifier).getPollData();
    }
View Full Code Here

TOP

Related Classes of net.java.games.input.Component.Identifier

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.