protected void addComponent( Component comp ) { Identifier id = comp.getIdentifier(); if( id instanceof Button ) { addButton(comp); } else if( id instanceof Axis ) { addAxis(comp); } else { logger.log(Level.FINE, "Ignoring: \"{0}\"", comp); } }
private ControllerAction convertEvent(Controller c, Event event) { Component comp = event.getComponent(); Identifier id = comp.getIdentifier(); float axisValue = comp.getPollData(); Input input; ButtonState state = ButtonState.UP;
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 button:" + comp ); } String name = comp.getName(); String original = id.getName(); try { Integer.parseInt(original); } catch (NumberFormatException e){ original = String.valueOf(buttonIndex.size()); } String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( logicalId != original ) { logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); } JoystickButton button = new DefaultJoystickButton( getInputManager(), this, getButtonCount(), name, logicalId ); addButton(button); buttonIndex.put( comp, button ); }
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 ); comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); addAxis(axis); axisIndex.put( comp, axis ); 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); 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);
bool xReleased = false, yReleased = false; Component[] components = controller.getComponents(); for(Component component : components) { if(component.isAnalog()) { //test that controller is analog Identifier id = component.getIdentifier(); float axisPosition = component.getPollData(); //range: -1 to 1 if(id == Component.Identifier.Axis.X && axisPosition == 0) xReleased = true; if(id == Component.Identifier.Axis.Y && axisPosition == 0) yReleased = true; } } if(xReleased && yReleased) { //do something... }
public final boolean isKeyDown(Component.Identifier.Key key_id) { Component key = getComponent(key_id); if (key == null) return false; return key.getPollData() != 0; } } // class Keyboard
private void addAxis(JPanel p, Component ax){ JPanel p2; if (ax.isAnalog()) { p2 = new AnalogAxisPanel(ax); } else { if (ax.getIdentifier() == Component.Identifier.Axis.POV) { p2 = new DigitalHatPanel(ax); } else { p2 = new DigitalAxisPanel(ax); } } p.add(p2); axes_to_panels.put(ax, p2); }
buffer.append(", "); buffer.append(components[i].getName()); buffer.append(": "); if (components[i].isAnalog()) { buffer.append(components[i].getPollData()); } else { if (components[i].getPollData() == 1.0f) { buffer.append("On"); } else {
@Override public String getName() { return component.getName(); }
public static float getDeadZone(Component component) { float deadZone = component.getDeadZone(); if (deadZone < minimumDeadZone) { deadZone = minimumDeadZone; } return deadZone; }
public BooleanYoVariableJoystickEventListener(YoBoolean variable, Component component, boolean toggle, boolean flip) { if (component.isAnalog()) throw new RuntimeException("component is analog; should be digital (i.e. an on/off button)"); this.variable = variable; this.component = component; this.flip = flip; this.toggle=toggle; }
System.out.println("Component Count: "+components.length); for(int j=0;j<components.length;j++){ System.out.println("Component "+j+": "+components[j].getName()); System.out.println(" Identifier: "+ components[j].getIdentifier().getName()); System.out.print(" ComponentType: "); if (components[j].isRelative()) { System.out.print("Relative"); } else { System.out.print("Absolute"); if (components[j].isAnalog()) { System.out.print(" Analog"); } else {
@Override public float getPollData(final Identifier identifier) { final Component comp = this.controller.getComponent(identifier); if (comp == null) { return 0; } return comp.getPollData(); }
private void addAxis(JPanel p, Component ax){ JPanel p2; if (ax.isAnalog()) { p2 = new AnalogAxisPanel(ax); } else { if (ax.getIdentifier() == Component.Identifier.Axis.POV) { p2 = new DigitalHatPanel(ax); } else { p2 = new DigitalAxisPanel(ax); } } p.add(p2); axisList.add(p2); //ax.setPolling(true); }
private String getControllerFieldText(String identifierName) { Component component = getControllerComponent(identifierName); if (component == null) { return identifierName; } String name = component.getName(); if (name == null) { // Use the Identifier name if the component has no name name = identifierName; } else if (name.length() > maxControllerFieldValueLength && identifierName.length() < name.length()) { // Use the Identifier name if the component name is too long to fit // into the display field name = identifierName; } return name; }
protected void renderData(){ String extra = ""; if (getAxis().getDeadZone() >= Math.abs(data)) extra = " (DEADZONE)"; analogState.setText(""+data+extra); analogState.repaint(); } }
Identifier id = e.getComponent().getIdentifier(); if (id == Identifier.Axis.POV){ float x = 0, y = 0;
protected ControllerInfo getControllerInfo(final Controller controller) { final List<String> axisNames = Lists.newArrayList(); final List<String> buttonNames = Lists.newArrayList(); for (final Component comp : controller.getComponents()) { if (comp.getIdentifier() instanceof Identifier.Axis) { axisNames.add(comp.getName()); } else if (comp.getIdentifier() instanceof Identifier.Button) { buttonNames.add(comp.getName()); } } return new ControllerInfo(controller.getName(), axisNames, buttonNames); }
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 ); comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); addAxis(axis); axisIndex.put( comp, axis ); 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); 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);