Package net.java.games.input

Examples of net.java.games.input.Component


    if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE)
      return false;
    Component.Identifier.Key key_id = KeyMap.map(lwjgl_key);
    if (key_id == null)
      return false;
    Component key = getComponent(key_id);
    if (key == null)
      return false;
    float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
    event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds());
    return true;
View Full Code Here


    EventQueue queue = target.getEventQueue();

    while (queue.getNextEvent(event)) {
      // handle button event
      if (buttons.contains(event.getComponent())) {
        Component button = event.getComponent();
        int buttonIndex = buttons.indexOf(button);
        buttonState[buttonIndex] = event.getValue() != 0;

        // fire button pressed event
        Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
      }

      // handle pov events
      if (pov.contains(event.getComponent())) {
        Component povComponent = event.getComponent();
        int povIndex = pov.indexOf(povComponent);
        float prevX = getPovX();
        float prevY = getPovY();
        povValues[povIndex] = event.getValue();

        if (prevX != getPovX()) {
          Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
        }
        if (prevY != getPovY()) {
          Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
        }
      }

      // handle axis updates
      if (axes.contains(event.getComponent())) {
        Component axis = event.getComponent();
        int axisIndex = axes.indexOf(axis);
        float value = axis.getPollData();

        // fixed dead zone since most axis don't report it :(
        if (Math.abs(value) < deadZones[axisIndex]) {
          value = 0;
        }
        if (Math.abs(value) < axis.getDeadZone()) {
          value = 0;
        }
        if (Math.abs(value) > axesMax[axisIndex]) {
          axesMax[axisIndex] = Math.abs(value);
        }
View Full Code Here

    EventQueue queue = target.getEventQueue();

    while (queue.getNextEvent(event)) {
      // handle button event
      if (buttons.contains(event.getComponent())) {
        Component button = event.getComponent();
        int buttonIndex = buttons.indexOf(button);
        buttonState[buttonIndex] = event.getValue() != 0;

        // fire button pressed event
        Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
      }

      // handle pov events
      if (pov.contains(event.getComponent())) {
        Component povComponent = event.getComponent();
        int povIndex = pov.indexOf(povComponent);
        float prevX = getPovX();
        float prevY = getPovY();
        povValues[povIndex] = event.getValue();

        if (prevX != getPovX()) {
          Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
        }
        if (prevY != getPovY()) {
          Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
        }
      }

      // handle axis updates
      if (axes.contains(event.getComponent())) {
        Component axis = event.getComponent();
        int axisIndex = axes.indexOf(axis);
        float value = axis.getPollData();

        // fixed dead zone since most axis don't report it :(
        if (Math.abs(value) < deadZones[axisIndex]) {
          value = 0;
        }
        if (Math.abs(value) < axis.getDeadZone()) {
          value = 0;
        }
        if (Math.abs(value) > axesMax[axisIndex]) {
          axesMax[axisIndex] = Math.abs(value);
        }
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);
View Full Code Here

    c = this.getClass();
                return retobj;
      }
     
      private int findCompIndex(Component[] comps, Component.Identifier id, String nm) {
    Component c;
    for (int i = 0; i < comps.length; i++) {
      c = comps[i];
      if ((c.getIdentifier() == id) && !c.isRelative()) {
        System.out.println("Found " + c.getName() + "; index: " + i);
        return i;
      }
    }

    System.out.println("No " + nm + " component found");
View Full Code Here

            int yAxisPercentage = 0;
           
             Component[] components = controller.getComponents();
            for(int i=0; i < components.length; i++)
            {
                Component component = components[i];
                Component.Identifier componentIdentifier = component.getIdentifier();
               
                //System.out.println("component name: " + component.getName());
            
                // Buttons
               
               // Axes  
                if(component.isAnalog()){
                    float axisValue = component.getPollData();
                   
               //     if (axisValue >0 && axisValue <1.5){
               //      axisValueInPercentage = getAxisValueInPercentageDown(axisValue, component.getName());}
              //      if (axisValue <0 && axisValue > -1.5){
              //       axisValueInPercentage = getAxisValueInPercentageUP(axisValue, component.getName());}
                    //System.out.println("component name axisValue: " + component.getName()+ axisValueInPercentage);
                   
                    //window.txtLog.append(component.getName()+ axisValueInPercentage +"\n");
                   
                    // X axis
                    if(componentIdentifier == Component.Identifier.Axis.X){
                        axisValueInPercentage = getAxisValueInPercentageX(axisValue, component.getName());
                        yAxisPercentage = axisValueInPercentage;
                        System.out.println("X: " +  yAxisPercentage);
                       setJoystickData('X',  yAxisPercentage);
                        continue; // Go to next component.
                    }
                    // Y axis
                    if(componentIdentifier == Component.Identifier.Axis.Y){
                        axisValueInPercentage = getAxisValueInPercentageY(axisValue, component.getName());
                        yAxisPercentage = axisValueInPercentage;
                       System.out.println("Y: " + yAxisPercentage);
                      setJoystickData('Y', yAxisPercentage);
                        continue; // Go to next component.
                    }
                   
                    // Throtlle Oœ
                                 
                    if(component.getName().contains("Oœ")){
                         xAxisPercentage = getThrottleValueInPercentage(axisValue);
                       System.out.println("Throtlle L : " + xAxisPercentage);
                       setJoystickData('L', xAxisPercentage);
                        continue; // Go to next component.
                    }
                    // Throtlle Suwak
                    if(component.getName().contains("Suwak")){
                         xAxisPercentage =  getThrottleValueInPercentage(axisValue);
                       System.out.println("Throtlle R : " + xAxisPercentage);
                      
                       setJoystickData('P', xAxisPercentage);
                        continue; // Go to next component.
View Full Code Here

      buttonsPanel.setBounds(6, 19, 250, 250);

      // 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));
          buttonsPanel.add(aToggleButton);

          // We know that this component was button so we can skip to
          // next component.
          continue;
        }

        // Hat switch
        if (componentIdentifier == Component.Identifier.Axis.POV) {
          float hatSwitchPosition = component.getPollData();
          window.setHatSwitch(hatSwitchPosition);

          // We know that this component was hat switch so we can skip
          // to next component.
          continue;
        }

        // Axes
        if (component.isAnalog()) {
          float axisValue = component.getPollData();
          int axisValueInPercentage = getAxisValueInPercentage(axisValue);

          // X axis
          if (componentIdentifier == Component.Identifier.Axis.X) {
            xAxisPercentage = axisValueInPercentage;
            continue; // Go to next component.
          }
          // Y axis
          if (componentIdentifier == Component.Identifier.Axis.Y) {
            yAxisPercentage = axisValueInPercentage;
            continue; // Go to next component.
          }

          // Other axis
          JLabel progressBarLabel = new JLabel(component.getName());
          JProgressBar progressBar = new JProgressBar(0, 100);
          progressBar.setValue(axisValueInPercentage);
          axesPanel.add(progressBarLabel);
          axesPanel.add(progressBar);
        }
View Full Code Here

            return false;
       
        Component[] components = controller.getComponents();
       
        for(int i=0; i < components.length; i++) {
            Component component = components[i];
           
            // Add states of the buttons
            if(component.getName().contains("Button"))
                if(component.getPollData() == 1.0f)
                    buttonsValues.add(Boolean.TRUE);
                else
                    buttonsValues.add(Boolean.FALSE);
        }
       
View Full Code Here

     * @param identifier Identifier that correspond to component.
     * @return True if component exists or false if not exists.
     */
    public boolean componentExists(Identifier identifier)
    {
        Component component = controller.getComponent(identifier);
       
        if(component != null)
            return true;
        else
            return false;
View Full Code Here

TOP

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

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.